xsl-list
[Top] [All Lists]

Re: How to do this without updating a variable?

2005-09-07 15:15:24
I don't have my "tools" here, but from the top of my head, try
something like this:

<xsl:template match="reg">
   <xsl:value-of select="."/>:
   <xsl:value-of select="sum(preceding-sibling::reg/@count)"/>-
   <xsl:value-of select="sum(preceding-sibling::reg/@count|self::reg/@count)"/>
</xsl:template>

On 9/7/05, Agnisys Technology (P) Ltd. <agnisys(_at_)yahoo(_dot_)com> wrote:
Hi,
  I have seen past postings about the fact that variables cannot be updated. 
But I'm not sure how
to solve the following problem without variable update!

Input:

<top>
  <a>
    <reg count="5"> A0 </reg>
    <reg count="10"> A1 </reg>
  </a>
  <a>
    <reg count="10"> A2 </reg>
  </a>
</top>

Output:

  Node : start      end
  A0   :   1    -    5
  A1   :   6    -   15
  A2   :  16    -   25

--------------------------
So basically output of any node <reg> is based on all the <reg> nodes that 
have been processed
before it. If I could use a temporary variable, I would have just kept a 
running total of the
total "count" prior to processing that node.

Could someone suggest a solution or give me some pointer?

Thanks,
Anupam.





______________________________________________________
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>
--~--



--~------------------------------------------------------------------
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>
--~--