This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Problem with xsl:choose
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] Problem with xsl:choose
- From: Goetz Bock <bock at blacknet dot de>
- Date: Wed, 8 Aug 2001 10:06:40 +0200
- References: <000d01c11fdf$5ed3a020$64604c0f@india.hp.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
On Wed, Aug 08 '01 at 13:24, Lakshmi Narayanan K wrote:
> I have an xml file in the following format
>
> <main>
> <timer> On </timer>
> </main>
>
> My xsl file was
> <!-- main/timer -->
> <xsl:template match = "main/timer">
> <xsl:choose>
> <xsl:when test=" main/timer = 'On'">
> <xsl:text>Timer is On</xsl:text>
> </xsl:when>
> <xsl:when test="main/timer = 'Off'">
> <xsl:text>Timer is Off</xsl:text>
> </xsl:when>
> <xsl:otherwise>
> <xsl:text>Timer is Manual</xsl:text>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
Your match changes the context to main/timer. In the when, you ask for a
main/timer there. For your xsl-t to work your xml must look like:
<main>
<timer>
<main>
<timer> On </timer>
</main>
</timer>
</main>
what you want is either:
<xsl:template match="/">
...
</xsl:template>
or
<xsl:when test=".='On'">
--
Goetz Bock IT Consultant
Dipl.-Inf. Univ.
PGP signature