W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2002

Re: Select specific node and namespaces

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 13 Jun 2002 09:42:26 +0100
Message-ID: <52137382213.20020613094226@jenitennison.com>
To: "Snow, Corey" <csnow@deltadentalwa.com>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>

Hi Corey,

Coming late to the thread...

> It fails, because objXMLDoc has a namespace, which is not
> represented by the XPath query, so the selectSingleNode call returns
> NULL. However, if I add the namespace before the query:
> objXMLDoc.setProperty "SelectionNamespaces", "xmlns:myns="mynamespaceURN"
> It still fails unless I modify the XPath to something like:
> /myns:topic[1]/myns:content[1]/myns:para[1]/myns:link[1]
> I guess my question is, how can I select a node in this fashion
> without having to modify the Location string so much? I could simply
> replace all the "/" characters with "/myns:" but that just seems
> kludgy. I have a feeling that this is the result of my limited
> experience with XPath.

It's less of a kludge than the other option, which is adjusting your
location path to:

  /*[namespace-uri() = 'mynamespaceURN' and
     local-name() = 'topic'][1]
    /*[namespace-uri() = 'mynamespaceURN' and
       local-name() = 'content'][1]
      /*[namespace-uri() = 'mynamespaceURN' and
         local-name() = 'para'][1]
        /*[namespace-uri() = 'mynamespaceURN' and
           local-name() = 'link'][1]

Don't feel bad about having namespace prefixes in the location path.
It's how XPath works and there's really no getting away from it.



Jeni Tennison
Received on Thursday, 13 June 2002 04:42:29 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:57 UTC