xsl-list
[Top] [All Lists]

Re: how to select elements in a given namespace?

2003-03-17 13:54:32
On Mon, 17 Mar 2003, Jeni Tennison wrote:

Hi Robert,

if i want to select all nodes in a given namespace ("auth"), it
appears i can use:

  //namespace::auth

That will select all the *namespace*nodes* named "auth". Namespace
nodes are nodes that represent a prefix-namespace binding. Such a
namespace node will exist on every element within the scope of the
xmlns:auth="..." namespace declaration.

ah, right, so there will be a "child" namespace node for each element
within the scope of the declaration.  this would represent the parent
<auth:author xmlns:auth=...> element itself and its five children,
correct?
 
If you want to select all the elements in the namespace associated
with the prefix 'auth', use:

  //auth:*

All attributes in that namespace with:

  //@auth:*

Note that the 'auth' namespace must be declared in the stylesheet
(or in whatever context you're selecting the nodes). A stylesheet will
not automatically pick up on the fact that the namespace is declared
in the XML document.

in fact, those were two of the first things i tried.
both of the above generate "ERROR: Prefix auth has not been declared".
and since i'm using xpathtester, it can't be a stylesheet issue.
so i'm still a bit confused -- as i said before, tidwell's example
has, embedded in the XML, the excerpt:

  <auth:author xmlns:auth="...">
   <last-name>...
   ...
  </auth:author>

a couple pages later, he implies that the XPath expression
"/sonnet/auth::*" should return the <auth:author> element.  instead,
xpathtester simply gives me the above ERROR.

is this just an xpathtester thing?  time to switch utilities, methinks.

rday



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list