This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Nestled <xsl:choose>
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Nestled <xsl:choose>
- From: "dante" <dante at vianet dot net dot au>
- Date: Sat, 14 Jul 2001 15:16:28 +0800
- References: <Pine.SGI.4.21.0107132226200.150279-100000@burn.cs.utah.edu>
- Reply-To: xsl-list at lists dot mulberrytech dot com
I'm trying to create a testing structure to assign a different template
depending on the content of the element attributes "variant" & "style".
in pseudo code:
---------------------------------
if variant = book
then
if style = fiction
use fiction template
else
use non-fiction template
endif
elseif variant = graphic novel
use graphic novel template
elseif variant = magazine
use magazine template
else
show error massage
endif
---------------------------------
Is this possible in xsl?
Or should I create a separate template to test the "fiction" attribute.
Here's the xsl code that I'm using.
<!--CHECK VARIANT-->
<xsl:attribute name="variant">
<xsl:choose>
<!--BOOK VARIANT-->
<xsl:when test="variant = 'Book'">
<!--CHECK STYLE-->
<xsl:attribute name="style">
<xsl:choose>
<!--FICTION STYLE-->
<xsl:when test="style = 'Fiction'">
<xsl:for-each select="fiction">
<xsl:apply-templates select="." />
</xsl:for-each>
</xsl:when>
<!--END FICTION STYLE-->
<!--NON-FICTION STYLE-->
<xsl:otherwise>
<xsl:for-each select="non-fiction">
<xsl:apply-templates select="." />
</xsl:for-each>
</xsl:otherwise>
<!--END NON-FICTION STYLE-->
</xsl:choose>
</xsl:attribute>
<!--END CHECK STYLE-->
<!--END BOOK VARIANT-->
</xsl:when>
<!--GRAPHIC_NOVEL VARIANT-->
<xsl:when test="variant = 'Graphic_Novel'">
<xsl:for-each select="graphic_novel">
<xsl:apply-templates select="." />
</xsl:for-each>
</xsl:when>
<!--END GRAPHIC_NOVEL VARIANT-->
<!--MAGAZINE VARIANT-->
<xsl:when test="variant = 'Magazine'">
<xsl:for-each select="magazine">
<xsl:apply-templates select="." />
</xsl:for-each>
</xsl:when>
<!--END MAGAZINE VARIANT-->
<!--ERROR TRAP-->
<xsl:otherwise>
<xsl:text>Error</xsl:text>
</xsl:otherwise>
<!--END ERROR TRAP-->
</xsl:choose>
</xsl:attribute>
<!--END CHECK VARIANT-->
Thanks,
Oliver
p.s. does this list have a tip harvester or something similar?
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list