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

Conditionally enclosing something in multiple elements

Subject: Conditionally enclosing something in multiple elements
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Thu, 12 Aug 1999 10:58:34 -0600
something about an elements
I'm using XT to output HTML 4.0.
Is there a more elegant solution to the following problem, using just one
template?

1. If attribute 'weight' of element 'foo' = 'bold', wrap value of <bar> in
<b>...</b>
2. If attribute 'style' of element 'foo' = 'italic', wrap same thing in
<i>...</i>
3. Do both if necessary

Example:

<xsl:template name="Format_Some_Text">
    <xsl:choose>
        <xsl:when test="foo/@weight='bold' and foo/@style='italic'">
            <b><i><xsl:value-of select="bar"/></i></b>
        </xsl:when>
        <xsl:when test="foo/@weight='bold'>
            <b><xsl:value-of select="bar"/></b>
        </xsl:when>
        <xsl:when test="foo/@style='italic'>
            <i><xsl:value-of select="bar"/></i>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="bar"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

This is ugly in that I have to account for every combination of possible
enclosing elements, of which there will be more than just the two I show in
this example. How else can one approach this? It seems like there must be
another way, but I'm short-circuiting as I try to think of what it may be.


 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.