Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - What does this XPath expression mean ? [Thread Next] Re: What does this XPath expression mean ?To: NULL Date: 3/18/2008 12:42:00 PM
zw wrote:
> Can anyone interpret this ?
> select="/Results/*[not(@label = preceding::*/@label)]
It selects the child elements of the root element 'Result' for which
there is no preceding element with the same value for the 'label'
attribute. So it selects the child elements with a distinct 'label'
attribute value, for example if we have
<Results>
<foo label="a">1</foo>
<foo label="b">2</foo>
<foo label="a">3</foo>
<foo label="c">4</foo>
<foo label="b">5</foo>
</Results>
then the following stylesheet
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="/Results/*[not(@label = preceding::*/@label)]">
<xsl:value-of select="concat(., ' ')"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
outputs
1
2
4
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
