[xml] Possible bug : inconsistency between xsl:copy-of, namespaces and xsd validation



Hi!
    I'm developing a series of xsl function extensions which implements
xmldsig signatures. My client need that any transformed document pass
through a schema validation. I'm using the new XSD schema validation from
libxml 2.6.13, and libxslt 1.1.10

The next XML is the result of the XSL transformation

<?xml version="1.0" encoding="ISO-8859-1"?>
<DTE xmlns="http://www.sii.cl/SiiDte";>
    <Documento ID="T33F100"/>
    <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"/>
</DTE>

The "Signature" element was created using xsl:copy-of
The problem is when I validate the resulting in-memory doc from the
transformation, the validation fails. I trace back the problem to

xmlschemas.cl, line 13200+

if (child->ns != NULL)
    nsUri = child->ns->href;

When "child" is the Signature element, the namespace obtained is
"http://www.sii.cl/SiiDte";, instead of the expected
http://www.w3.org/2000/09/xmldsig#
Surprisingly, if I serialize the transformedDoc and then read back from
disk, the validation is OK! (and the namespace obtained for Signature
element now is the correct one!).

I traced back the problem to libxslt's transform.c, at the implementation of
xslCopyOf, more exactly at xsltCopyTree / xmlNewNs part, which seems to not
copy the namespace declared in the Signature node to the xmlNode's ns field
(which is the examinated in the schema validation routine), but to node's
nsDef field

line 1039
xmlNewNs(copy, (*cur)->href, (*cur)->prefix);


Since my limited knowdlege of namespace handling iin libxml, I'm not really
sure if the problem is in xsl:copy-of or in the namespace checking part of
XSD validation. Therefor I attach a sample program that exemplifies the
inconsitency between "in memory" and "from disk" validation of the same
transformed doc.

Any help will be really appreciated

Agustin

Attachment: copy-of-xsd-bug-demo.tgz
Description: application/compressed



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