[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Nestled <xsl:choose>

Subject: Nestled <xsl:choose>
From: "dante" <dante@xxxxxxxxxxxxx>
Date: Sat, 14 Jul 2001 15:16:28 +0800
non fiction template
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.