This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Testing for presence of node, etc.


-----BEGIN PGP SIGNED MESSAGE-----
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:if>
  <xsl:for-each select="key('link-type', 'the-specific-value')">
    String of text
  </xsl:for-each>
</xsl:template>

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
>
> ---------------------------------------
> http://www.ballsome.com
>
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

- -- 
Peter Davis
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE86qeSNSZCJx7tYycRApb0AJ9KbikI4Z9KRQKvwZbvK5ENccbLiACbB5Ti
o5VyrOrTBGcsaZfNGTb9ESE=
=PfXo
-----END PGP SIGNATURE-----


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]