Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. XSLT grouping

XSLT grouping

Scheduled Pinned Locked Moved XML / XSL
xmlhelpquestion
2 Posts 2 Posters 9 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Catimus
    wrote on last edited by
    #1

    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

    Z 1 Reply Last reply
    0
    • C Catimus

      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

      Z Offline
      Z Offline
      Zdenek Navratil
      wrote on last edited by
      #2

      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>&

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups