need to use result of for each outside the loop
Posted: Fri May 24, 2024 1:23 am
I have a function which uses a for each to find the element desired and return a substring. I assign a variable from within the for-each loop, but I don't know how to make the scope more global, at least within this function. Once this function call returns the field, $lineAllocPct, the main part will use it in calculations.
Thank you,
Code: Select all
<xsl:function name="custom:getAllocPct">
<xsl:param name="allocDetailStr"/>
<xsl:param name="costCenter"/>
<xsl:variable name="lineAllocPct"/>
<xsl:for-each select="$allocDetailStr">
<xsl:if test ="contains($allocDetailStr,$costCenter)">
<xsl:variable name="lineAllocPct" select="normalize-space(substring-after($allocDetailStr,'having'))"/>
<xsl:sequence select="$lineAllocPct"/>
</xsl:if>
</xsl:for-each>
<xsl:sequence select="$lineAllocPct"/>
</xsl:function>
Thank you,