[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
line numbering in XSL FO, Sebastian Rahtz | Thread | RE: I/O of iso-8859-1 characters?, Miles Sabin |
Re: Newbie Question, Sebastian Rahtz | Date | RE: Weird IE5 behaviour, Senthil Vaiyapuri |
Month |