Re: [xml] Problem with XML Query



On Mon, Apr 28, 2008 at 03:47:06PM +0200, Martin Landl wrote:
Hi!

I've got a problem with the following XML
<OBJECT xmlns="http://somenamespace"; xmlns:ns0="http://somenamespace"; myAttribute="myAttributeValue">
      <STRING xmlns="http://somenamespace"; xmlns:ns1="http://somenamespace"; reference="COOSYSTEM 1 
1:objname">stringvalue1</STRING>
      <STRING xmlns="http://somenamespace"; xmlns:ns2="http://somenamespace"; reference="COOSYSTEM 1 
1:objsubject">stringvalue2</STRING>
</OBJECT>

When I try to query the XPath "/ns1:OBJECT/@ns1:myAttribute" (having "http://somenamespace"; added as "ns1") 
added the query returns no nodes.

  and that's normal. default namespace does not apply to attrbutes.
The spec isn't that long, worth spending an hour or so reading it, really
as it's rather important. See section 6.2 it defines it only for elements.
I't confirmed in 6.3 
 "However, each of the following is legal, the second because the default namespace does not apply to 
attribute names:"

   http://www.w3.org/TR/REC-xml-names/

If I change the XML "myAttribute" to "ns0:myAttribute", the same XPath query returns the attribute node 
properly.

  yes, that's normal.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/



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