Re: [xml] xml:space and xml:lang problem



On Wed, Jun 08, 2005 at 04:45:10PM -0400, Rob Richards wrote:
The xmllint example was just a way to exemplify the issue using xmllint. 
I was loading xml using dom methods and told it to stip out whitespaces.
This works fine, except the xml:space attribute when set to preserve 
should prevent the removal of whitespaces in its context.

When the xml is output it looks like:
<?xml version="1.0"?>
<doc><e1><e2 xml:space="preserve"><e3 id="E3"/></e2></e1></doc>

while it should look like:
<?xml version="1.0"?>
<doc><e1><e2 xml:space="preserve">
        <e3 id="E3"/>
     </e2></e1></doc>

which it does using 2.5.x as well as 2.6 with the patch.

  okay that was my guess, sounds fine.

Hadn't played with the xml:lang, but saw it has the same problem as 
xml:space. The code in xmlParseAttribute was carried over to 
xmlParseAttribute2, but within xmlParseAttribute2, the attribute is 
broken out into prefix and name, so the tests xmlStrEqual(name, BAD_CAST 
"xml:space") and (xmlStrEqual(name, BAD_CAST "xml:lang")) will never be 
true like they are in xmlParseAttribute.

  hum, right ...

As far as moving code around, I made a test just for 
xmlStrEqual(*prefix, BAD_CAST "xml") and if that is true will fall into 
the block to check for name equal to space or lang. figured it would be 
faster rather than testing everything twice when the prefix may not even 
be correct in the first place.

  string interning should even allow to reduce that to a pointer comparison
with ctxt->str_xml 

The logic is the same as that used in xmlParseAttribute, which does only 
check lang if pedantic is used. The change was just to get the checks to 
actually kick in as they would never be true in xmlParseAttribute2.

  thanks for the explanations.

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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