xsl-list
[Top] [All Lists]

Re: How to do this without updating a variable?

2005-09-08 10:54:50
Yeah this is much more elegant. A useful way to thing about this problem (for 
me atleast) is to
think that the datastructure is already there, to create the output I just have 
to traverse it
based on what information I need.
Slowly, I'm getting used to this new way of thinking ...

Thanks to Jay and Mukul for additional help.
Anupam.

--- JBryant(_at_)s-s-t(_dot_)com wrote:

A little more thinking reveals that:

<xsl:choose>
  <xsl:when test="position() = 1">
    <tr>
      <td><xsl:value-of select="."/></td>
      <td>1</td>
      <td><xsl:value-of select="@count"/></td>
    </tr>
  </xsl:when>
  <xsl:otherwise>
    <tr>
      <td><xsl:value-of select="."/></td>
      <td><xsl:value-of select="sum(preceding::reg/@count) + 1"/></td>
      <td><xsl:value-of select="sum(preceding::reg/@count) + 
@count"/></td>
    </tr>
  </xsl:otherwise>
</xsl:choose>


can be just:

<tr>
  <td><xsl:value-of select="."/></td>
  <td><xsl:value-of select="sum(preceding::reg/@count) + 1"/></td>
  <td><xsl:value-of select="sum(preceding::reg/@count) + @count"/></td>
</tr>

because the sum of the empty set will be 0.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





        
                
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>