Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Nesting forces repeated code? Nesting forces repeated code?To: NULL Date: 9/6/2006 8:24:00 AM Hi. I've recently started looking into XSLT and in my exploration so far I've found something that, I hope, must have an easier solution. My test case is a table where, based on one condition, the cell background has to be a different colour. To do this I have something like this: <tr> <xsl:choose> <xsl:when test="NAME='smith'"> <td valign='top' bgcolor='#D0E0E0'> <i><xsl:value-of select="NAME"/>:</i> </td> </xsl:when> <xsl:otherwise> <td valign='top'> <i><xsl:value-of select="NAME"/>:</i> </td> </xsl:otherwise> </xsl:choose> </tr> What I'd _like_ to do is this: <tr> <xsl:choose> <xsl:when test="NAME='smith'"> <td valign='top' bgcolor='#D0E0E0'> </xsl:when> <xsl:otherwise> <td valign='top'> </xsl:otherwise> </xsl:choose> <i><xsl:value-of select="NAME"/>:</i> </td> </tr> but I can't because the element nesting is broken. So I have to repeat my table cell for each case, i.e. <i><xsl:value-of select="NAME"/>:</i> appears multiple times. Given that the contents of the cell could be potentially huge, and I could have many different test cases for different cell colours, and I don't want to have to make the same change in multiple places when I re-work the cell content, this seems like a really bad scheme. I'm sure, therefore, there is some 'standard' way of dealing with these cases, and I'd be grateful for anyone to tell me what it is. Thanks, Colin | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
