Subject: RE: Re: Recursive calls to a named template
From: cknell@xxxxxxxxxx
Date: Thu, 20 Nov 2003 14:13:52 -0500
|
> -----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
| Current Thread |
- Recursive calls to a named template
- Ram - Thu, 20 Nov 2003 08:28:47 -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)
|
|