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

RE: Help with staregies for outputting an incremental

Subject: RE: Help with staregies for outputting an incremental number in xslt
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 29 Nov 2007 16:29:43 -0000
RE:  Help with staregies for outputting an incremental
I don't understand what you mean by "omitted nodes" (I have trouble
discussing non-existent objects). If position() counts it, then it must be
there. Please show us your XML to illustrate what you are talking about.

Incidentally, please don't do this:

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

when you mean this:

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

It's the kind of thing that gives XSLT an undeserved reputation for being
verbose and slow.

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Adam Lipscombe [mailto:adam.lipscombe@xxxxxxxxxx] 
> Sent: 29 November 2007 16:16
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Help with staregies for outputting an 
> incremental number in xslt
> 
> 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/expensy
> s: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

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-2013 All Rights Reserved.