[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Re: Returning a value from a template

Subject: Re: Re: Returning a value from a template
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Nov 2010 13:04:35 -0500
Re:  Re: Returning a value from a template
At 2010-11-10 09:36 -0800, Narayan wrote:
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>
...
Thanks Ken. The problem with the above approach is that if there are 3 Loop-N1's
then the output would be:
<corecom:ID>NAEDIBrokerageNAEDIBrokerageNAEDIBrokerage</corecom:ID>


Thats why I was trying to set a flag inside the loop and then return a Single
value.

Then you *don't* need the loop at all:


  <xsl:template name="getOrderSource">
    <xsl:choose>
      <xsl:when test='/ns0:Transaction-850/ns0:Loop-N1/
                      ns0:Segment-N1/ns0:Element-66 = "21"'>NAEDI</xsl:when>
      <xsl:otherwise>NAEDIBrokerage</xsl:otherwise>
    </xsl:choose>
  </xsl:template>

In XPath when you address a set of nodes as an operand in a test, the test is repeated for every member of the node set until either a true() value is returned by any member (you aren't told which), or until the node set is exhausted and a false() value is returned.

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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.