This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Searching for a particular node
- From: "Elovirta Jarno (NBI/Espoo)" <Jarno dot Elovirta at nokia dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 25 Mar 2002 13:01:07 +0200
- Subject: RE: [xsl] Searching for a particular node
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi,
> Is it possible using XSL to select a node based on a
> particular value ...
> for example in the following xml, I want to select the
> <entity> node with an
> id of 'e14'. My question is, how do I accomplish this with
> XSL using @id?
<xsl:template match="tree">
<xsl:apply-templates select="entity[@id = 'e14']" />
<xsl:template match="entity">
or if the id attribute is declared ID in the DTD
<xsl:template match="tree">
<xsl:apply-templates select="id('e14')" />
<xsl:template match="entity">
or if you have a zillioin entity elements, declare a key
<xsl:key name="entities" match="entity" use="@id" />
<xsl:template match="tree">
<xsl:apply-templates select="key('entities', 'e14')" />
<xsl:template match="entity">
Santtu
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list