Re: [xsl] Testing for presence of node, etc.

Subject: Re: [xsl] Testing for presence of node, etc.
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Tue, 21 May 2002 13:01:20 -0700
Hash: SHA1

Using <xsl:key> is the obvious solution:

<xsl:key name="link-type" match="link" use="@type"/>

<xsl:template match="/">
  <xsl:if test="key('link-type', 'the-specific-value')">
    Special Header
  <xsl:for-each select="key('link-type', 'the-specific-value')">
    String of text

It sounds like 'the-specific-value' is the same for the entire document, and 
you don't need to repeat the process for other values.  If this is the case 
then the above code should be exactly what you want.  You can of course 
replace 'the-specific-value' with a string retrieved from some other node.

On Tuesday 21 May 2002 12:39, Joel Konkle-Parker wrote:
> In my xml document, I have several nodes of type <link type=""
> url=""></link>, where type may one of several different things, and
> more than one node may have the same @type. I want to be able to test
> whether any nodes exist that have a specific @type and if so, output
> a certain heading. I then need to output a string of text for each
> occurrance of a specific @type. Obviously I don't want the heading to
> output for each occurance.
> If I haven't confused everyone already, what suggestions do you have
> about the best way to do this?
> -joeljkp
> ---------------------------------------
>  XSL-List info and archive:

- -- 
Peter Davis
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see


 XSL-List info and archive:

Current Thread