-----Original Message-----
From: Kevin Jones <kjones(_at_)sarvega(_dot_)com>
Subject: Re: [xsl] Recursive calls to a named template
I tried your solution, which sounds like a better tack than the one I proposed,
but no <signature> elements were copied from related <group> elements.
Here is the stylesheet:
=================
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:key name="GroupByIdentifier" match="group" use="identifier[1]"/>
<xsl:template match="signature">
<xsl:choose>
<xsl:when test="count(../identifier[2])>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>
</xsl:stylesheet>
and here is the output:
=================
<?xml version = '1.0' encoding = 'UTF-8'?>
<formatted-xml>
<group>
<identifier>a</identifier>
<signature>signature
<identifier>DNSQuery1</identifier>
<in>in
<long>long</long>
<identifier>ant</identifier>
</in>
</signature>
</group>
<group>
<identifier>b</identifier>
<identifier>a</identifier>
<signature>signature
<identifier>DNSQuery1</identifier>
<in>in
<long>long</long>
<identifier>ant</identifier>
</in>
</signature>
</group>
<group>
<identifier>c</identifier>
<identifier>b</identifier>
<signature>signature
<identifier>DNSQuery1</identifier>
<in>in
<long>long</long>
<identifier>ant</identifier>
</in>
</signature>
</group>
</formatted-xml>
What did I miss in your explanation?
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list