[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hello
Firstly, I am an inexperienced xslt user, so please forgive me if this a no-brainer.
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">
<!-- 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>
<!-- More data from node is output here..... --!>
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
[xsl] Help with staregies for outputting an incremental number in xslt
Subject: [xsl] 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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Matching namespaces - one, Michael Kay | Thread | RE: [xsl] Help with staregies for o, Michael Kay |
RE: [xsl] Matching namespaces - one, Michael Kay | Date | Re: [xsl] recursive sorting by elem, Davis Ford |
Month |
Keywords