|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Conditionally enclosing something in multiple 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








