[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: build group of elements
henry human wrote:
The input file was just a sample to show the xml data has more foo elements. <myxmlfile> <ss></ss>...<foo></foo>.................<foo></foo> </myxmlfile> //presume there are 100 foo elements in the xml file My sample output which is created througth xslt has groups of foo elment. Each group consists of three foo elements. (each three foo elments build a group). example <fooGroup>= foo[1], foo[2]. foo[3] <fooGroup>= foo[4], foo[5]. foo[6] <fooGroup>= foo[7], foo[8]. foo[9]
<xsl:template match="xmlfile"> <xsl:for-each-group select="foo" group-by="(position() - 1) idiv $size"> <fooGroup> <xsl:apply-templates select="current-group()"/> </fooGroup> </xsl:for-each-group> </xsl:template> <xsl:template match="foo"> <xsl:element name="foo{position()}"> <xsl:copy-of select="node()"/> </xsl:template> </xsl:template> -- Martin Honnen --- MVP Data Platform Development http://msmvps.com/blogs/martin_honnen/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|