Re: [xml] xpath selection of node with namespace



On Fri, Aug 24, 2001 at 02:19:13PM +1000, Keith Isdale wrote:
Hi all,

I've being tring out the example given on xmlsoft website
http://www.xmlsoft.org/gjobs.xml (with the windows binaries and a
linux version built from a fairly recent cvs copy) and viewing with
xmllint using the --shell option. Even though you can select a node within
this example by matching content eg

  XPath specification was not designed to be used "standalone", but
intended for reuse by other specifications (XSLT and XPointers), 
and those provide the namespace mapping needed for the XPath engine.

  You must understand that 
     a:b
 has a clear defined meaning only if the a prefix is defined. And
you can have a:b points to elements from different namespaces in a single
document, because namespaces prefixes are not defined document wide but
for a subtree.

  For the XPath query to complete you have to give a single meaning to
the prefix a . You can do that at the API level but not in the XPath
expression, check the archive I explained this already:
    http://mail.gnome.org/archives/xml/2001-July/msg00097.html

  The only way to make taht query without specifying the namespace
at the API level is to actually avoid using the prefix by using
the dedicated local-name and namespace-uri functions like:
    http://www.w3.org/TR/xpath#function-local-name

   //*[ namespace-uri() = "http://example.com"; and local-name() = "b" ]

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
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]