[Home] [By Thread] [By Date] [Recent Entries]
At 2010-11-09 18:07 -0800, Narayan wrote:
I have been scratching my head on how to return a value from a called template which includes a for loop. A snippet of the XML fragment is as follows: (the default for d-o-e is "no" so you don't have to say it)
Right. The scope of a local variable is the following siblings and their descendants. There are no such following siblings. What I was trying to do is to set a flag to indicate that the element exists and then return the appropriate string literal. Would there be a simpler way to do this? Yes ... don't use the flag. Something along the lines of: <xsl:template name="getOrderSource">
<xsl:for-each select="/ns0:Transaction-850/ns0:Loop-N1">
<xsl:choose>
<xsl:when test='ns0:Segment-N1/ns0:Element-66 = "21"'>NAEDI</xsl:when>
<xsl:otherwise>NAEDIBrokerage</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>I hope this helps. . . . . . . . Ken -- Contact us for world-wide XML consulting & instructor-led training Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|

Cart



