[xml] Re: [xmlsec] exc c14n w/o comments bug

Aleksey Sanin aleksey at aleksey.com
Tue May 11 17:08:12 PDT 2004


>   However when you ask for namespace from an XPath query, then
> libxml2 XPath engine will return different namespace element, because in
> the XPath model, you don't see namespace declarations, but in scope
> namespaces and to mimic those (and the fact that the parent of an 
> in-scope namespace on an element is the element and not the element declaring
> it), the XPath engine need to create namespaces on-the fly.
Yes, this is exactly the problem :) I am sorry I gave slightly wrong
example in my previous message. The better one is the following
(I am using a modified example xpath2.c):

$ cat test.xml
<test1:Root xmlns:test1="http://www.example.org/test1"
	    xmlns:test2="http://www.example.org/test2">
	<test2:Something test1:attr="value"/>
</test1:Root>

$ xpath1 test.xml \
  "(//. | //@* | //namespace::*)[ancestor-or-self::test2:Something]" \
  "test1=http://www.example.org/test1 test2=http://www.example.org/test2"

Result (5 nodes): 
         = element node ptr=00349E50 (ns-ptr=00349B20)
   "http://www.example.org/test2:Something" 
                                              = attribute node 
ptr=00349F10 (ns-ptr=00349A28)
   "http://www.example.org/test1:attr" 
                                            = namespace ptr=0034AE28 
(node-ptr=00349E50)
   "xml"="http://www.w3.org/XML/1998/namespace" for
   node http://www.example.org/test2:Something
= namespace ptr=0034ADC0 (node-ptr=00349E50)
   "test2"="http://www.example.org/test2" for
   node http://www.example.org/test2:Something
= namespace ptr=0034ABA0 (node-ptr=00349E50)
   "test1"="http://www.example.org/test1" for
   node http://www.example.org/test2:Something


As you can see, that attribute node points to namespace object 00349A28
which is different from namespace declaration object 0034AE28.

>>The problem is that during exc-c14n I have to check if particular
>>namespace is visible or not. This works just great for element
>>namespaces but for attributes it fails because of the reasons described
>>above.
> 
> 
>   Hum, this is a bit unclear to me. I can't comment on this.
Sorry, the long description is basically repeating the spec:
the particular namespace declaration node is rendered in exc-c14n output
if and only if the following conditions are true:
   1) The namespace declaration node is "visible" (i.e. it is
    in the XPath nodeset).
   2) The namespace is "visibly utilized" (i.e. it is used by the
   a "visible" attribute of this node or the node itself).
   3) The namespace declaration node with the same prefix and URI was
   not rendered in the ancestor of this node.

The problem caused by the fact that "visible" namespace declaration
node is different from the "visibly utilized" one.


Aleksey



More information about the xmlsec mailing list