XSLT grouping
-
hola, i have this xml recordset which looks like this JoeG Joli Gantz 400-00-0000 Joe4 Joseph Gour 500-00-0000 Joe4 Joseph Gour 500-00-0000 Basically I am trying to find a way to transform this xml into something that will have two or however many users in a page element so the output would be something like this. JoeG Joli Gantz 400-00-0000 Joe4 Joseph Gour 500-00-0000 Joe4 Joseph Gour 500-00-0000 Joe90 Joseph90 Ninety 500-00-0000 any one have any ideas as to how i can achieve this? I can get a page attribute around every user, but i would like to be able to put it around every X number of users, if anyone has any ideas i would really appreciate the help. sorry for the length of this post. thanks
-
hola, i have this xml recordset which looks like this JoeG Joli Gantz 400-00-0000 Joe4 Joseph Gour 500-00-0000 Joe4 Joseph Gour 500-00-0000 Basically I am trying to find a way to transform this xml into something that will have two or however many users in a page element so the output would be something like this. JoeG Joli Gantz 400-00-0000 Joe4 Joseph Gour 500-00-0000 Joe4 Joseph Gour 500-00-0000 Joe90 Joseph90 Ninety 500-00-0000 any one have any ideas as to how i can achieve this? I can get a page attribute around every user, but i would like to be able to put it around every X number of users, if anyone has any ideas i would really appreciate the help. sorry for the length of this post. thanks
I just pasted in a snippet from a similar problem solution. The requirement here was to sort items before gouping them between DIV tags. It may shed some light on the grouping you need. XML: <?xml version="1.0"?> <list> <item at="d">d</item> <item at="e">e</item> <item at="i">i</item> <item at="k">k</item> <item at="l">l</item> <item at="a">a</item> <item at="b">b</item> <item at="c">c</item> <item at="j">j</item> <item at="f">f</item> <item at="g">g</item> <item at="h">h</item> <item at="a">a</item> <item at="b">b</item> <item at="c">c</item> <item at="f">f</item> </list> XSL: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:param name="group">5</xsl:param> <!-- grouping size--> <xsl:variable name="items" select="count(//item)"/> <!-- total number of items--> <xsl:template match="list"> <HTML> <BODY> <xsl:apply-templates select="item"> <xsl:sort select="@at" order="ascending"/> </xsl:apply-templates> </BODY> </HTML> </xsl:template> <xsl:template match="item"> xsl:choose <xsl:when test="position() mod $group =1"> <!-- Begin new group with gn = group # --> <xsl:variable name="gn" select="concat('g', (position() + 4) div 5)"/> <!-- DIV id="g#" --> <xsl:text disable-output-escaping="yes"><DIV id="</xsl:text> <xsl:value-of select="$gn"/><xsl:text disable-output-escaping="yes">"></xsl:text> <p><xsl:value-of select="position()"/> xsl:apply-templates/</p> </xsl:when> <xsl:when test="position() mod $group =0"> <!-- End group --> <p><xsl:value-of select="position()"/> xsl:apply-templates/</p> <!-- /DIV --> <xsl:text disable-output-escaping="yes"></DIV></xsl:text><hr /> </xsl:when> <xsl:when test="not(position() mod $group =0) and position() = $items"> <!-- last item in sorted list--> <p><xsl:value-of select="position()"/> xsl:apply-templates/</p> <!-- /DIV --> <xsl:text disable-output-escaping="yes"></DIV>&