Subject: Re: [xsl] how to select elements in a given namespace? From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 17 Mar 2003 20:40:32 +0000 |
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. 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. > so what is the XPath expression to match, say, the <last-name> > elements within this namespace? XPath expressions don't match elements, they select them. If you want to select the last-name element in the 'auth' namespace, use: //auth:last-name or, better: /auth:author/auth:last-name To *match* the auth:last-name element with an XSLT pattern, you can use: auth:last-name Note that in your example, the <last-name> element is not in the namespace associated with the 'auth' prefix since it does not have a prefix and there is no default namespace declaration. In your example, only the <auth:author> element is in the 'auth' namespace. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] how to select elements in, Lars Huttar | Thread | Re: [xsl] how to select elements in, Robert P. J. Day |
RE: [xsl] how to select elements in, Lars Huttar | Date | RE: [xsl] how to select elements in, David . Cantrell |
Month |