Re: Recursive calls to a named template
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"/> 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)>0"> <xsl:apply-templates select="key("GroupByIdentifier",../identifier)/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
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