RE: [xsl] Searching for a particular node

Subject: RE: [xsl] Searching for a particular node
From: "Elovirta Jarno (NBI/Espoo)" <Jarno.Elovirta@xxxxxxxxx>
Date: Mon, 25 Mar 2002 13:01:07 +0200
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


Current Thread