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

Re: Recursive calls to a named template

Subject: Re: Recursive calls to a named template
From: Kevin Jones <kjones@xxxxxxxxxxx>
Date: Thu, 20 Nov 2003 18:34:29 +0000
javascript recursive calls
On Thursday 20 November 2003 13:28, Ram wrote:
> Hi,
>  Can anyone please give me hint how to copy the previous
> operations? Actually, the input xml file is a dynamic one and
> the number of 'group' is arbitrary. The xml source would look
> like this:
>

Cut ...

While on the surface this looks like something you could solve 
using recursion and preceding searches your XML would allow the 
groups to appear in any order since each contains a direct 
reference to the group that should be used to replace the 
signature. In this case the replacing signature could appear 
either before or after the group you are processing. These types 
of operations are normally easier to handle by introducing a key 
such as,

<xsl:key name="GroupByIdentifier" match="group" 
use="identifier[1]"/>

You can then process using a modified identity transform, 
something like this should work,

<xsl:template match="signature">
 <xsl:choose>
  <xsl:when test="count(../identifier[2])&gt;0">
   <xsl:apply-templates 
select="key("GroupByIdentifier",../identifier[2])/signature"/>
   </xsl:when>
   <xsl:otherwise>
    <xsl:copy>
     <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
   </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="node()|@*">
 <xsl:copy>
  <xsl:apply-templates select="node()|@*"/>
 </xsl:copy>
</xsl:template>

This isn't the most efficient implemetation you could create but 
for small to medium sized number of groups it should be 
sufficient.

Regards,
Kev.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • Recursive calls to a named template
    • Ram - Thu, 20 Nov 2003 08:28:47 -0500 (EST)
      • Kevin Jones - Thu, 20 Nov 2003 13:34:49 -0500 (EST) <=
      • <Possible follow-ups>
      • cknell - Thu, 20 Nov 2003 14:13:59 -0500 (EST)
      • cknell - Thu, 20 Nov 2003 15:42:18 -0500 (EST)
        • Ram - Fri, 21 Nov 2003 03:44:31 -0500 (EST)

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.