On 28/05/2010 20:46, Eric wrote:
What is missing in the output your XSLT produced is Folder number 18 in
Box 12,
sorry I just copied * (ie the children of the first item of the group)
rather than current-group()/* the children of all the items.
then you also needed another for-each-group on folder, so something a
bit more like:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="r">
<r>
<xsl:for-each-group select="Record" group-by="string(Series)">
<Series id="{current-grouping-key()}">
<xsl:for-each-group select="current-group()" group-by="string(Subseries)">
<Subseries id="{current-grouping-key()}">
<xsl:for-each-group select="current-group()" group-by="string(Box)">
<Box id="{current-grouping-key()}">
<xsl:for-each-group select="current-group()" group-by="string(Folder)">
<Folder id="{current-grouping-key()}">
<xsl:copy-of select="* except (Series,Subseries,Box,Folder)"/>
<xsl:copy-of select="current-group()[position()!=1]/Item"/>
</Folder>
</xsl:for-each-group>
</Box>
</xsl:for-each-group>
</Subseries>
</xsl:for-each-group>
</Series>
</xsl:for-each-group>
</r>
</xsl:template>
</xsl:stylesheet>
bash-3.2$ saxon9 records.xml records.xsl | tee records2.xml
<r>
<Series id="2">
<Subseries id="1">
<Box id="12">
<Folder id="17">
<FolderTitle>Symphonic Poem</FolderTitle>
<FolderID>223</FolderID>
</Folder>
<Folder id="18">
<FolderTitle>Requeim Mass</FolderTitle>
<FolderID>224</FolderID>
</Folder>
</Box>
</Subseries>
<Subseries id="2">
<Box id="12">
<Folder id="19">
<FolderTitle>Symphony no. 4</FolderTitle>
<FolderID>225</FolderID>
</Folder>
</Box>
</Subseries>
</Series>
<Series id="3">
<Subseries id="">
<Box id="12">
<Folder id="20">
<FolderTitle>Symphony no. 5</FolderTitle>
<FolderID>226</FolderID>
</Folder>
</Box>
<Box id="13">
<Folder id="1">
<FolderTitle>Chamber music</FolderTitle>
<FolderID>227</FolderID>
<Item>String Quartet</Item>
<Item>String Quartet no. 2</Item>
<Item>Piano Trio Quartet</Item>
</Folder>
</Box>
</Subseries>
</Series>
</r>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--