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

Kasimier Buchcik said:

on 9/15/2004 4:43 PM Agustín Villena wrote:

    In my last post I attached a TGZ with all example files


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);

I reversed the sequence (i.e. copy the nsDefs, then call xsltGetNamespace),
and that seems to fix the originally reported problem :

bill bbrack work $ ./test
In memory validation return Code = 0
From disk validation return Code = 0

The fixed code is in CVS (libxslt/transform.c).

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.

I'm afraid I don't quite follow that.  Could you give an example of where the
existing code would fail?  And it would be better to continue this discussion
on the xslt mailing list rather than here on xml :-).





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