Re: [xml] Patch for XML declaration detection (standalone=-2)

On Mon, Dec 04, 2006 at 11:11:39AM +1100, Michael Day wrote:

Here is a patch that fixes a minor bug in my earlier patch that enabled 
detection of whether an XML declaration was specified. It also adds some 
documentation explaining the different values of "standalone":

 standalone=1 ---> standalone="yes"
 standalone=0 ---> standalone="no"
 standalone=-1        ---> no XML declaration
 standalone=-2        ---> XML declaration, but no standalone attribute

The use case for all this is that I wish to use the XML reader, read up 
to the start tag of the root element, and then check the standalone 
value in order to see if an XML declaration was seen. This is in order 
to do content sniffing between XML and HTML.

The bug was that standalone was defaulting to -1 instead of -2 in 
xmlParseSDDecl, even though if we get to xmlParseSDDecl it means that an 
XML declaration has been seen. It was only triggering in situations like 

<?xml version="1.0"  ?>

note the space after the version attribute, which was causing 
xmlParseSDDecl to be called, then straight away returning -1, as no 
standalone attribute was found. Now it returns -2, indicating that no 
standalone attribute was found, but the XML declaration is present.

  Okay, this looks clean, I hope this new extra value won't be a problem 
in existing code, I doubt it will, so I applied the patch and commited it,

  thanks a lot !


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]