|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Re: Recursive calls to a named template
> -----Original Message-----
> From: Kevin Jones <kjones@xxxxxxxxxxx>
> Subject: Re: 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@xxxxxxxxxx - email
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
|

Cart








