Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Nesting forces repeated code?

From: "Colin" <colin_mac2002@-----.--.-->
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



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent