xsl-list
[Top] [All Lists]

RE: RE: Elminitate redundancy by using variables

2004-03-24 06:30:00
Thanks, I'll keep an eye on spambayes.sourceforge.net.
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     <Jarno(_dot_)Elovirta(_at_)nokia(_dot_)com>
Sent:     Wed, 24 Mar 2004 09:07:46 +0200
To:       <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject:  RE: [xsl] Elminitate redundancy by using variables

Hi,

Imagine I have xsl similar to this:

<xsl:choose>
      <xsl:when test="number($count) mod 2 = 0">

You don't need to cast $count to a number, it will be done automatically for 
you; then again, with XPath 2.0 you need to start being more careful about the 
data types, so I suppose it's a good habit to have.

              <tr style="background-color: #FFFFFF;">
                 <td class="fieldInfo">
                      <xsl:value-of
select="substring(LineItemName,1,45)"/>
                 </td>
              </tr>
      </xsl:when>
      <xsl:otherwise>
              <tr style="background-color: #E7EEFF;">
                 <td class="fieldInfo">
                      <xsl:value-of
select="substring(LineItemName,1,45)"/>
                 </td>
              </tr>
      </xsl:otherwise>
</xsl:choose>

You can easily see that this would be a nightmare if I had 
even just 5 <td>
elements being repeated.  Is there a way to save the value from the
beginning of the <td> to the end, including the generate value of
LineItemName?

  <tr>
    <xsl:attribute name="style">
      <xsl:text>background-color: </xsl:text>
      <xsl:choose>
        <xsl:when test="$count mod 2 = 0">#FFFFFF</xsl:when>
        <xsl:otherwise>#E7EEFF</xsl:otherwise>
      </xsl:choose>
      <xsl:text>;</xsl:text>
    </xsl:attribute>
    <td class="fieldInfo">
      <xsl:value-of select="substring(LineItemName,1,45)"/>
    </td>
  </tr>

Cheers,

Jarno - Chris C: The Zurich Mix

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
You are subscribed as: cknell(_at_)onebox(_dot_)com
To unsubscribe, go to: 
http://lists.mulberrytech.com/unsub.php/xsl-list/cknell(_at_)onebox(_dot_)com
or e-mail: 
<mailto:xsl-list-unsubscribe-cknell=onebox(_dot_)com(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--