[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Help with staregies for outputting an incremental numb

Subject: Help with staregies for outputting an incremental number in xslt
From: Adam Lipscombe <adam.lipscombe@xxxxxxxxxx>
Date: Thu, 29 Nov 2007 16:15:37 +0000
 Help with staregies for outputting an incremental numb
Hello


Firstly, I am an inexperienced xslt user, so please forgive me if this a no-brainer.


My problem is this:
I have a list of nodes, and I need to output a node count with each node.
I use the position() function to output the node count. So far so good.

Recently however, the requirement has changed: under certain circumstances a node is ommited from the output. When a node is ommitted, the node count of the subsequent node is incorrect - because the position() function counts all nodes, including the omitted ones.


e.g.:


<xsl:for-each select="expensys:Lines/expensys:Line/expensys:Accruals/expensys:Accrual">

  <xsl:variable name="description">
    <xsl:value-of select="../../expensys:ItemDescription"/>
  </xsl:variable>

<!-- Node ommission
Set includeLine=false for personal spend lines with CorpCardRec personal settlement
as we dont want to output these -->
<xsl:variable name="includeLine">
<xsl:choose>
<xsl:when test="$description = 'Personal Spend'">
<xsl:if test="$transactionType = 'CorporateCardReconciliation'"> <xsl:if test="$corporateCardSettlementType = 'corporate'"> <xsl:value-of select="true()"/> </xsl:if> <xsl:if test="$corporateCardSettlementType = 'personal'"> <xsl:value-of select="false()"/> </xsl:if>
</xsl:if>
<xsl:if test="$transactionType != 'CorporateCardReconciliation'"> <xsl:value-of select="true()"/>
</xsl:if>
</xsl:when>
<xsl:otherwise> <xsl:value-of select="true()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>


   <xsl:if test="$includeLine='true'">
     <txn:Line>											
       <txn:Number>											         <xsl:value-of select="position()"/>
       <txn:Number>

<!-- More data from node is output here..... --!>

     </txn:Line>											
   </xsl:if>



I need the value of txn:Number to increment contigously, but this recent node ommission has thrown a spanner in the works :-(

I have searched through the forums and discovered its not possible to increment a variable in a for-each loop. Can anyone guide me to a solution?.



Many thanks in advance....

Adam

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.