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

Daniel Veillard veillard at redhat.com
Tue May 11 14:11:12 PDT 2004


On Tue, May 11, 2004 at 01:59:14PM -0700, Aleksey Sanin wrote:
> I am talking about attribute namespace and it is different from "namespace
> declaration". For example, if I remember everything correctly then you 
> parse the following element
> 
>     <test:something xmlns:test="http://www.example.org/test"
>                     test:data="aaa"/>
> 
> with LibXML2 then the xmlNodePtr for "test:data" attribute will have a
> pointer to namespace xmlNodePtr and it will be *different* from the
> xmlNodePtr created for "xmlns:test" namespace declaration.

  Hum, no. that should not be the case.
  The something element will have an nsDef with the test namespace
and the something element ns should point to it as well as the data
attribute ns.
  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.

> Now if we make the example slightly more complex:
> 
>    <test1:something xmlns:test1="http://www.example.org/test1
>                     xmlns:test2="http://www.example.org/test2">
> 	<test2:somethingelse test1:data="aaa">
> 	</test2:somethingelse>
>    </test1:something>
> 
> and suppose that we have XPath expression that selects all attributes
> in the test2:something element
> 
> 	//test1:something//test2:somethingelse@*
> 
> In this case, the xmlNodePtr that represents test1 namespace in the
> test1:data attribute would not be included in the resulting XPath
> nodeset. I am not sure if it is a problem with LibMXL2 XPath engine
> or not.

  This is not, because namespace are not part of the attribute axis.
Sot you will get returned an xmlAttr pointer, that pointer will have an
ns, and that ns will be the namespace declaration made on the test1:something
element.

> >  How is the weird serialization generated ? Is the redundant
> >xmlns information pushed as an attribute instead of a namespace ?
> >Maybe there is some fixup needed at the libxml2 tree API too.
> 
> 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.

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard at redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



More information about the xmlsec mailing list