Re: [xsl] Merging multiple documents and combining their nodes

Subject: Re: [xsl] Merging multiple documents and combining their nodes
From: "Mark Peters" <flickrmeister@xxxxxxxxx>
Date: Wed, 13 Jun 2007 10:13:35 -0400
Hi Michael,

Thanks for the suggestion. My team's currently limited to XSLT 1.0,
using Apache Xalan-J 2.6.0.

Regards,
Mark


On 6/13/07, Michael Kay <mike@xxxxxxxxxxxx> wrote:
Are you constrained to XSLT 1.0? If you can use 2.0, it's simple:

<xsl:variable name="docs" select="document(('file1.xml', 'file2.xml',
'file3.xml'))"/>
<xsl:variable name="comps" select="$docs/components/component"/>

<components>
 <xsl:for-each-group select="$comps" group-by="@name">
   <component name="{current-grouping-key()}"
              description="{@description}">\\\
     <xsl:copy-of select="current-group()/*"/>
   </component>
 </xsl:for-each-group>
</components>

Michael Kay
http://www.saxonica.com/

Current Thread