Re: [xml] Why does XML::LibXSLT (= the Perl 5 / CPA N wrappers for libxslt) Fails a Basic Test on some BSD and ot her systems?



Hi!

I tried investigate this bug and as far I can see problem in a different behavior of the function 
xmlNodeGetSpacePreserve from libxml2.

We can simplify the existing template to reproduce bug:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/root">
    <test xml:space="preserve"><!-- !!! EXTRA WHITESPACES HERE !!! -->
        <xsl:attribute name="aaa">bbb</xsl:attribute>
    </test>
</xsl:template>
</xsl:stylesheet>

With libxml2 >= 2.8.0 it's OK, but with version < 2.8.0 whitespaces are not removed and remains empty text 
element after which we can no longer use "xsl:attribute".

Here is function from libxml2 2.9.0:
int
xmlNodeGetSpacePreserve(xmlNodePtr cur) {
    xmlChar *space;

    if ((cur == NULL) || (cur->type != XML_ELEMENT_NODE))
        return(-1);
    while (cur != NULL) {
    space = xmlGetNsProp(cur, BAD_CAST "space", XML_XML_NAMESPACE);
    if (space != NULL) {
        if (xmlStrEqual(space, BAD_CAST "preserve")) {
        xmlFree(space);
        return(1);
        }
        if (xmlStrEqual(space, BAD_CAST "default")) {
        xmlFree(space);
        return(0);
        }
        xmlFree(space);
    }
    cur = cur->parent;
    }
    return(-1);
}

Here is function from libxml2 2.7.8:
int
xmlNodeGetSpacePreserve(xmlNodePtr cur) {
    xmlChar *space;

    while (cur != NULL) {
    space = xmlGetNsProp(cur, BAD_CAST "space", XML_XML_NAMESPACE);
    if (space != NULL) {
        if (xmlStrEqual(space, BAD_CAST "preserve")) {
        xmlFree(space);
        return(1);
        }
        if (xmlStrEqual(space, BAD_CAST "default")) {
        xmlFree(space);
        return(0);
        }
        xmlFree(space);
    }
    cur = cur->parent;
    }
    return(-1);
}

In this case, two lines play a crucial role here:
    if ((cur == NULL) || (cur->type != XML_ELEMENT_NODE))
        return(-1);

You can also try to change template and move 'xml:xpace="preserve"' after 'xsl:attribute' to resolve problem.

-- 
Yuriy Ustushenko (YOREEK)

Shlomi Fish < shlomif shlomifish org >:
Hi all,

[I am posting this message in separate copies to both  xml gnome org and
perl-xml listserv ActiveState com ].

after I added a test to the XML::LibXSLT test suite to check for the successful
run of a Perl XSLT stylesheet I wrote, I've been getting many CPAN Testers
Failures:

http://matrix.cpantesters.org/?dist=XML-LibXSLT+1.87

While most Linux systems work fine, I've been getting many failures from BSD
systems. The longer story is that this test script was a port of part of a test
of a dependent CPAN package that's been getting testing failures after it was
attempted to be installed after a successful testing and installation of
XML::LibXSLT (whose test coverage was and probably still is incomplete).

You can find the offending test here:

https://bitbucket.org/shlomif/perl-xml-libxslt/src/8d9cfd4ce6381853c2c3c185842daa2f81107c79/t/xml-grammar-failures.t?at=default

(just note it uses some external files specified in the $input_fn and $xslt_fn
variables).

Now someone I talked with said that libxslt and/or libxml2 were incompatible
with clang/LLVM (and possibly other non-GCC compilers). If that's true, is it
a known issue? Is it ultimately a bug of clang/LLVM? Or alternatively, is it a
dependency on a non-standard GCCist behaviour in libxslt and libxml2? Is the
problem with the Perl bindings?

Please enlighten me.

Regards,

Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish  http://www.shlomifish.org/
Buffy Factoids -  http://www.shlomifish.org/humour/bits/facts/Buffy/

I hope that if it had not been clear before, it isn’t less clear now.
    — One of Shlomi Fish’s Technion Lecturers

Please reply to list if it's a mailing list post -  http://shlom.in/reply .
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
https://mail.gnome.org/mailman/listinfo/xml


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