Subject: Re: [xsl] UNIQUE List of nodes attributes that have a particular value From: Andrew Watt <andrew@xxxxxxxxxxxxxx> Date: Sun, 20 Apr 2003 10:43:29 +0100 |
I am trying to find all the attributes in an XML document that contain a particular value.
Given the following data...
<ExampleData> <NodeA name="foo"/> <NodeA name="larry"/> <NodeA name="foo"/> <NodeB author="foo"/> <NodeB author="larry"/> <NodeC reporter="foo"/> </ExampleData>
I would like to write an XPATH statement that returns this:
<NodeA name="foo"/> <NodeB author="foo"/> <NodeC reporter="foo"/>
Note that I am only returning UNIQUE instances of element/attribute combinations with the attribute value.
Is this possible using XPATH?
<?xml version='1.0'?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:template match="/"> <ExampleData> <xsl:apply-templates select="ExampleData/*[@*='foo']" /> </ExampleData> </xsl:template>
<xsl:template match="*"> <xsl:if test="not( name(.)=name(preceding-sibling::*) )" > <xsl:copy-of select="." /> </xsl:if> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] UNIQUE List of nodes attr, David Carlisle | Thread | [xsl] Re: UNIQUE List of nodes attr, Dimitre Novatchev |
[xsl] Re: Intermediate XML file cre, Dimitre Novatchev | Date | RE: [xsl] Reusing XPath statements , Michael Kay |
Month |