RE: [xsl] Multi-grouping with keys (back of book index)

Subject: RE: [xsl] Multi-grouping with keys (back of book index)
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 22 Oct 2006 10:02:38 +0100
> I am not sure how to go about it. Should I use a Key to index 
> all the indexterms from all the XML files? 

xsl:key always works within a single document, but xsl:for-each-group works
on any sequence, including a sequence containing nodes from multiple
documents. So stick with for-each-group.
> 
> Here is my XSLT so far with the added Document function. All 
> it does is loop through each XML but doesn't group all the 
> indexterms into one:
> 
> <xsl:for-each select="$XML1">
> 	<xsl:for-each select="manual">
> 	  <xsl:for-each select="title">
> 		<xsl:variable name="thetitle" select="."/>
> 			<xsl:for-each-group
> select="document($thetitle)//indexterm" 
> group-by="substring(@name,1,1)">

Not sure of the details here, haven't got time to look into it: but you need
to move the for-each-group to the outer level, so it's processing a sequence
containing nodes from multiple documents. Something like

for-each-group select="$XML1/manual/title/document(.)//indexterm"

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

Current Thread