Re: [xml] Bug 502960: XML namespaces and SAX



On Dec 21, 2007 6:59 PM, Daniel Veillard <veillard redhat com> wrote:
Retake your example but make the content

<foo>
 <bar xmlns="bar">&test;</bar>
 <bar xmlns="bar2">&test;</bar>
</foo>

When the person who wrote the entity test in your document system
maybe it assumed a "bar" namespace, maybe it assumed no namespace,
but it certainly didn't expect the entity to be used for two different
kind of element.

Who's to say what the document author expected? The only thing we can safely say is that he most likely expected that whichever parser was applied to his document, it would comply with the XML specification.  That specification says pretty clearly at 4.4.2 that an entity reference is to be treated as if its replacement text were simply pasted in place of the reference.
 
The only safe thing is taht if you use/expect namespace for content within
a parsed entity you should put the namespace declaration in the entity itself
to guarantee this.

That's nice, but sometimes you don't have the option of mucking with the XML, and a well-formed document shouldn't need to be messed with in order to be parsed. In this particular case, the documents in question were some of the W3C's layout tests for SVG (see e.g. http://www.w3.org/Graphics/SVG/Test/20061213/svggen/coords-viewattr-01-b.svg and http://www.w3.org/Graphics/SVG/Test/20061213/svggen/coords-viewattr-02-b.svg.) Shall I contact the W3C and tell them they need to change their perfectly well-formed tests because libxml chokes on them?

The patch as is is not acceptable, as it breaks the ABI.

Sorry, I wasn't aware that the ABI was considered immutable... had I known, I'd have submitted a different patch. Previous versions of the parser handled internal entity references by inserting the entity's replacement text into the input stream at the appropriate location. What was wrong with that?



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