Re: [xml] C14N does not handle empty-namespace declarations as the implementation in Java

just that I get this right:

The namespace nodes of a node are not just the namespaces declared at that node, but all namespaces that are known at that node? Is that correct?

thanks for your help,

2008/8/27 Aleksey Sanin <aleksey aleksey com>
Yes, namespace nodes are *nodes* and all the usual rules apply.


Arne Müller wrote:
Hi Aleksey,

thanks for pointing me to those test-files. With them I also do not get xmlns="".
So then I checked, where there were differences between my code and the one in testC14N.c.
I realized, that the xmlns="" appears, because I use a nodeset.
It seems, if I use a default namespace, I have to add for each descandant a copy of it into the NodeSet, else it will not find it and will not set, that it has found a default-namespace.
(see line 623 in c14n.c)
Is this the intended behavior? I thought it would be sufficient to add the namespace for the namespace-declaring node into the nodeset and not for all descendant nodes.

Somehow the example code does this correctly (when given the XPath "/descendant::* | /descendant::*/attribute::* | /descendant::*/namespace::*").

So XPath seems to add namespace declarations everywhere and thus avoid the problem, while I have build the nodeset myself and not added as many namespace declarations (which I actually think create very much overhead).

I think I could now avoid the problem by modifying my NodeSet-creation code, to make it add namespaces for all descendants into the nodeset.
But maybe it would be better non the less to simply check if the nodeset contains a namespace-declaration for a parent node? Or am I missing something?


2008/8/26 Aleksey Sanin <aleksey aleksey com <mailto:aleksey aleksey com>>


   Could you please give an exact example that shows the problem
   using the testC14N command? For example, for the xml snippet
   from your previous email I generated C14N and I see no xmlns=""

   $ testC14N --with-comments test.xml > test-c14n.xml


   Arne Mueller wrote:

       Am Sonntag, den 24.08.2008, 21:21 -0700 schrieb Aleksey Sanin:

           Hi, Arne!

           Sorry, but as I have replied in xmlsec mailing list, I believe
           that libxml2 is doing the right thing here.


       Hi Aleksey,
       you might be perfectly right with adding one empty namespace.

       But I think one thing is buggy non the less, in the
       it says:

       4.6 Superfluous Namespace Declarations
       Unnecessary namespace declarations are not made in the canonical
       Whether for an empty default namespace, a non-empty default
       or a namespace prefix binding, the XML canonicalization method
       omits a
       declaration if it determines that the immediate parent element
       in the
       canonical form has an equivalent declaration in scope. The root
       element is handled specially since it has no parent element. All
       namespace declarations in it are retained, except the
       declaration of an
       empty default namespace is automatically omitted.

       Thus, there should be at most one empty namespace declaration,
       an parent element has already defined the empty namespace
       The same holds for the redefinition of "dsig" in the XPath element.


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