View Single Post
  #2 (permalink)  
Old June 15th, 2006, 07:29 AM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's easier in 2.0 than in 1.0. In 2.0:

<xsl:for-each-group
  select="(doc('file1.xml),doc('file2.xml'))/*/thingy"
  group-by="@name">
  <thingy>
    <xsl:copy-of select="current-group()/*"/>
  </thingy>
</xsl:for-each-group>

In 1.0 it's tricky because most of the standard grouping techniques (see http://www.jenitennison.com/xslt/grouping) only work on a single document. You could merge the documents first with one stylesheet, then do the grouping in another.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote