Thank you for being so patient with me! I did look at the XML grammar, but I only got far enough to suggest that the prolog was optional. I should have continued on, but I was confused by the error message from LibXML2 ("Extra content at the end of the document") which seemed to indicate that it had (somehow) found a "document" and that it was then objecting to text coming after it. I'm trying to take pains to ensure that the library is not presented with any text which isn't well-formed XML, so I'm trying to figure out what I've done wrong. Is it possible that the error message is wrong? (I concur that my text is erroneous, but it would be helpful if the error message were pertinent.) Thanks, again! Webb On 9/17/19 1:45 AM, Liam R E Quin
wrote:
On Tue, 2019-09-17 at 00:47 -0400, Webb Scales wrote:Would a file containing just an XML comment, e.g., <!-- My comment. --> be an acceptable input to LibXML2?Let's look at the specification of XML, https://www.w3.org/TR/REC-xml/ We see in section 2.1, [[ [Definition: A textual object is a well-formed XML document if:] Taken as a whole, it matches the production labeled document. It meets all the well-formedness constraints given in this specification. Each of the parsed entities which is referenced directly or indirectly within the document is well-formed. ]] So we need our input to match Document. The immediately following text in the spec has, [[ Document [1] document ::= prolog element Misc* ]] If you follow these you find "element" means we need exactly one top- level element, <foo>...</foo>, and your example has a comment but no element. So, it is not well-formed. You will find it helpful to become moer familiar with the grammar in the XML specification. Best, Liam --
Webb Scales
|