Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XSL-How to get value of a variable from inside loop-->to the outside loop?

843834May 28 2009 — edited May 29 2009
Pls help
hi im currently working on this xsl file..
This works on generating a txt file,my problem right now is
' how can i get the value of a variable generated from the inside forloop,
i have to get the total,sum value of this variables after performing the loop


***this is the for loop
<xsl:for-each select="OutboundPayment">

<xsl:variable name='id' select='generate-id(OutboundPayment)'/>
<xsl:sort select="PaymentNumber/CheckNumber" data-type="text" />


<xsl:variable name='PValue' select='format-number(100*PaymentAmount/Value,"0000000000000")'/>
<xsl:value-of select='$id'/>
<xsl:text>D</xsl:text>
<xsl:value-of select='$DDate'/>
<xsl:value-of select='$Batch'/>
<xsl:text>3</xsl:text>
<xsl:value-of select='format-number(PaymentNumber/PaymentReferenceNumber,"0000000000")'/>
<xsl:value-of select='format-number(PayeeBankAccount/BankAccountNumber,"0000000000")'/>
<xsl:value-of select='substring(Payee/Name,1,20)'/>
<xsl:value-of select='$PValue'/>

<xsl:variable name='Addend' select='concat($DDate,substring($DAcct,5,5),$Batch)'/>

<xsl:variable name="LHash">
<xsl:call-template name="GetHash">
<xsl:with-param name="A1" select="$PValue" />
<xsl:with-param name="A2" select="$Addend" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="concat('[',$LHash,']')" />

<!--LHash*i have to get the total amount of this one from the outside loop /---->
<xsl:call-template name='NewLine'/>
</xsl:for-each>

<!--I have to put in here the total value of that LHash/---->



<!--This is the template on how to get the value of that variable in the inside loop/---->
<xsl:template name="GetHash">
<xsl:param name='A1'/>
<xsl:param name='A2'/>
<xsl:variable name='TwoSum' select='format-number($A1+$A2,"000000000000000")'/>
<xsl:variable name='Weight' select='317191314191112'/>
<xsl:call-template name="WDigit">
<xsl:with-param name="Cnt" select="15"/>
<xsl:with-param name="Sum" select="$TwoSum"/>
<xsl:with-param name="Wgt" select="$Weight"/>
<xsl:with-param name="Tot" select="0"/>
</xsl:call-template>
</xsl:template>

<xsl:template name='WDigit'>
<xsl:param name='Cnt'/>
<xsl:param name='Sum'/>
<xsl:param name='Wgt'/>
<xsl:param name='Tot'/>
<xsl:choose>
<xsl:when test="$Cnt > 0">
<xsl:variable name='Multip' select='substring($Wgt,$Cnt,1)'/>
<xsl:variable name='Factor' select='substring($Sum,$Cnt,1)'/>
<xsl:variable name='Prduct' select='$Multip$Factor'/>
<!--xsl:value-of select="concat($Tot,'[',$Cnt,']')"/-->
<!--xsl:value-of select="concat($Multip,'x',$Factor,'=',$Prduct)"/-->
<!--xsl:call-template name='NewLine'/-->
<xsl:call-template name="WDigit">
<xsl:with-param name="Cnt" select="$Cnt - 1"/>
<xsl:with-param name="Sum" select="$Sum"/>
<xsl:with-param name="Wgt" select="$Wgt"/>
<xsl:with-param name="Tot" select="$Tot+$Prduct"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="Rem" select="$Tot mod 11"/>
<xsl:variable name="Chk" select="11 - $Rem"/>
<xsl:value-of select="format-number(concat($Tot,$Chk),'00000')"/>
</xsl:otherwise>
</xsl:choose>


<xsl:template name='GetTotal'>

</xsl:template>


Thanks in advance for those who are willing to help.

-Leighya
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 26 2009
Added on May 28 2009
1 comment
543 views