cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Berin Loritsch" <blorit...@infoplanning.com>
Subject Re: If...then
Date Mon, 25 Sep 2000 19:23:40 GMT
----- Original Message ----- 
From: "Gergely Imre" <gimre@nextra.ro>
To: <cocoon-users@xml.apache.org>
Sent: Monday, September 25, 2000 2:11 PM
Subject: Re: If...then


> How can I check an element's value in an <xsl:choose>...<xsl:when>
> clause?
> 
> I.e. I have
> <unit>10<unit>
> 
> and I want to:
> 
> <xsl:choose>
> <xsl:when test="unit" value="10"> <--- this obviously doesn't work
>   The value is 10!
> <xsl:when test="unit" value="100">
>   The value is 100!
> </xsl:choose>

try this instead:

<xsl:choose>
  <xsl:when test="{test}=10">
    The value is 10!
  </xsl:when>
  <xsl:otherwise>
    I am full of it.
  </xsl:otherwise>
</xsl:choose>

It took me a while to figure out that if you want to access the value
of nodes or attributes inside quotes in XSLT that you had to surround
the name with curly braces.  If you wanted to find the value of an
attribute use this structure:

<xsl:choose>
  <xsl:when test="{@test}=10">
    The value is 10!
  </xsl:when>
  <xsl:otherwise>
    I am full of it.
  </xsl:otherwise>
</xsl:choose>

Hope this helps!

---------------------------------------------------------
If you lust for Ham and Eggs, you have
committed breakfast in your heart
already.   -- C. S. Lewis



Mime
View raw message