[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Returning a value from a template
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) </xsl:otherwise> </xsl:choose> </xsl:template> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|