PDA

View Full Version : InvalidOperationException while reading SGML with root's attribute missing quotes



straudlater
06-18-2010, 02:58 PM
I have two sgml files that differ only in the root attribute (removed the rest of the sgml for clarity):

SGML A starts with: <sgml attr="-//TEST//TEST SGML//EN">

SGML B starts with: <sgml attr=-//TEST//TEST SGML//EN>

Notice that the only difference is that SGML A has double quotes that delimit the attr value.

Now, when I try to load each file into an xml stream, SGML A loads onto the xml stream with no errors, but SGML B gets an InvalidOperationException with a "There was no XML start tag open." error message.

Here's the snippet of code where SGML B fails:


sgmlReader.Read();
while (!sgmlReader.EOF)
{
xmlOutputWriter.WriteNode(sgmlReader, true);
}
xmlOutputWriter.Flush();

Is there any property that I need to set for SMGL B in order for it to work?

Update: After further tests, I may have figured out why the quotes make such a difference: the trailing /EN> of SGML B causes SgmlReader to think that this is the end of the <EN> tag, which doesn't exist! Could this be a bug in SgmlReader?

Thanks,
George

SteveB
07-02-2010, 03:36 PM
Yes, that sounds like a bug. In general, SgmlReader should never throw an exception, regardless of how poorly the input is formatted. Please submit a bug report with the input that caused the error. Thanks!

straudlater
07-19-2010, 04:13 PM
Thanks! I've submitted a bug report (http://bugs.developer.mindtouch.com/view.php?id=8451), along with a real-world SGML file.

SteveB
07-20-2010, 08:09 PM
Wonderful. Thank you!

straudlater
01-11-2011, 02:06 PM
Any updates to this issue?

I noticed in the bug report that it was downgraded from "Open" to "To be discussed" back in October 2010...just curious I guess.