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

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"/>

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

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.

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.

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.


Daniel Veillard wrote:

On Wed, Jun 08, 2005 at 02:41:36PM -0400, Rob Richards wrote:
Looks like xml:space is broken as of 2.6.0 with sax2
Running xmllint --noblanks on the following:
    <e2 xml:space="preserve">
       <e3 id="E3"/>

ignores the preserve while it doesn't in 2.5.x (different function call)
xml:lang has the same issue

Attached is the patch I'm using for it - moved some things around as well.

 I'm not against applying the patch, but could you give a few lines of
explanations ? xmllint --noblanks is not conformant "by design", but I think
I understand what it's about, I would just like to be sure. I assume
the xml:lang is about checking the value, we (W3C XML Core WG) relaxed this a lot in the second edition of the XML specification. I would say xml:lang warnings should only be raised in pedantic mode at this point,
note also that xml:lang="" may be used too.


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