|
Subject: RE: [xsl] how to select elements in a given namespace? From: "Passin, Tom" <tpassin@xxxxxxxxxxxx> Date: Mon, 17 Mar 2003 15:48:53 -0500 |
[Robert P. J. Day]
>
> [xpathtester is steadfastly refusing to be helpful since it does
> not highlight selected nodes based on attributes or namespaces.]
>
> from tidwell's book, if i have an excerpt from an XML file:
>
> <auth:author xmlns:auth=...>
> <last-name>...
> <first-name>...
> <nationality>...
> <year-of-birth>...
> <year-of-death>...
> </auth:author>
>
> if i want to select all nodes in a given namespace ("auth"), it
> appears i can use:
>
> //namespace::auth
>
> and while xpathtester refuses to highlight the matches, it
> does at least
> tell me there were 6 of them. i'm assuming that these matches are the
> auth:author element itself, and the 5 children, right?
>
> so what is the XPath expression to match, say, the
> <last-name> elements
> within this namespace?
>
Think simple ...
auth:author/last-name
("last-name" is not qualified by the "auth" namespace, while "author"
is). OR, if the context is already set to auth:author, then simply use
last-name.
For example -
<xsl:template match='auth:author'>
<xsl:value-of select='last-name'/>
</xsl:template>
Remember that you have to declare the "auth" namespace - put the
declaration into the xsl:stylesheet element.
Cheers,
Tom P
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] how to select elements in, Robert P. J. Day | Thread | RE: [xsl] how to select elements in, Passin, Tom |
| RE: [xsl] how to select elements in, David . Cantrell | Date | Re: [xsl] how to select elements in, Robert P. J. Day |
| Month |