[Mono-list] SgmlReader "There was no XML start tag open"

Atsushi Eno atsushi@ximian.com
Tue, 20 Apr 2004 01:22:14 +0900

Hello Morten,

Sorry for the late reply.

I found a bug in SgmlReader.MoveToAttribute(int) that incorrectly
loses the correct location.

Comment out the line 732 of SgmlReader.cs:
           this.node.CurrentState = this.state;//save current state.

(The resetting of CurrentState should only be done in Read().)

I also found why Mono does not allow it. It is because the
implementation detail of XmlWriter.WriteNode(). In Mono, I use
WriteAttributes() to write the attributes of a element. When I

	WriteAttributes (reader, defattr);
	reader.MoveToElement ();


	if (reader.HasAttributes) {
		for (int i = 0; i < reader.AttributeCount; i++) {
			reader.MoveToAttribute (i);
			WriteAttribute (reader, defattr);
		reader.MoveToElement ();

It worked.

So probably MS.NET is implemented as such. I am wondering whether
I had better change the behavior and let developers implement
buggy XmlReader, or leave XmlWriter as is so that developers can
make sure if they can implement correct XmlReader.

Anyways, feel free to report Chris Lovett about this bug.

Atsushi Eno