'Re: "Re: [xml] Possible bug : inconsistency between xsl:copy-of, namespaces and xsd validation"'
- From: Kasimier Buchcik <kbuchcik 4commerce de>
- To: Agustín Villena <avillena tutopia com>
- Cc: xml gnome org
- Subject: 'Re: "Re: [xml] Possible bug : inconsistency between xsl:copy-of, namespaces and xsd validation"'
- Date: Thu, 16 Sep 2004 00:05:08 +0200
Hi,
on 9/15/2004 4:43 PM Agustín Villena wrote:
Hi!
In my last post I attached a TGZ with all example files
[... snipp (example files)]
On Wed, Sep 15, 2004 at 09:50:33AM -0400, Agustín Villena wrote:
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
[...]
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
node->ns points to a otherNode->nsDef (a chained list of xmlNs structs).
(which is the examinated in the schema validation routine), but to
node's
nsDef field
line 1039
xmlNewNs(copy, (*cur)->href, (*cur)->prefix);
Copying the nsDef(s) is OK, since this is where they are declared; this
is the reason why the serialized representation had it's ns declarations
in the right place.
The devil seems to dwell in line 1020+:
if (node->ns != NULL)
copy->ns = xsltGetNamespace(ctxt, node, node->ns, copy);
xsltGetNamespace calls xmlSearchNs, which searches an aquivalent
namespace by prefix; since the nsDef(s) (ns declarations) are not copied
yet, it cannot find the correct one.
It appears to be a timing issue of first calling xsltGetNamespace,
before the nsDefs are copied:
line 1038+:
xmlNewNs(copy, (*cur)->href, (*cur)->prefix);
and line 1048+:
xsltCopyNamespaceListInternal(copy, node->nsDef);
Additionally a more robust check is needed in namespaces.c
(xsltGetNamespace), line 439+:
ret = xmlSearchNs(out->doc, out, ns->prefix);
if ((ret == NULL) && (ns->prefix != NULL))
ret = xmlSearchNsByHref(out->doc, out, URI);
}
The above performs a search by prefix only; a check for equal namespace
needs to be added.
Regards,
Kasimier
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]