Click here to Skip to main content
15,921,203 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: Group problem Pin
Ranjan Banerji28-Aug-02 7:18
Ranjan Banerji28-Aug-02 7:18 
GeneralGroup problem Pin
Ahmet Orkun GEDiK26-Aug-02 11:29
sussAhmet Orkun GEDiK26-Aug-02 11:29 
Generalsorting Pin
Sonu Kapoor26-Aug-02 9:36
Sonu Kapoor26-Aug-02 9:36 
GeneralRe: sorting Pin
Ranjan Banerji26-Aug-02 9:52
Ranjan Banerji26-Aug-02 9:52 
GeneralRe: sorting Pin
Sonu Kapoor26-Aug-02 20:17
Sonu Kapoor26-Aug-02 20:17 
GeneralRe: sorting Pin
12-Sep-02 4:23
suss12-Sep-02 4:23 
GeneralXSLT grouping Pin
Catimus22-Aug-02 10:50
Catimus22-Aug-02 10:50 
GeneralRe: XSLT grouping Pin
Zdenek Navratil22-Aug-02 21:40
Zdenek Navratil22-Aug-02 21:40 
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></xsl:text>
</xsl:when>
<xsl:otherwise>
<p><xsl:value-of select="position()"/>
<xsl:apply-templates/></p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

HTH,
Zdenek


"I would have written a shorter letter, but I didn’t have the time." [Blaise Pascal]

GeneralProblem with 'contains' function Pin
SigEpUCI19-Aug-02 14:39
SigEpUCI19-Aug-02 14:39 
GeneralRe: Problem with 'contains' function Pin
Michael A. Barnhart20-Aug-02 1:53
Michael A. Barnhart20-Aug-02 1:53 
QuestionAttribute value choking parser? Pin
SigEpUCI16-Aug-02 17:07
SigEpUCI16-Aug-02 17:07 
AnswerRe: Attribute value choking parser? Pin
Michael A. Barnhart17-Aug-02 9:48
Michael A. Barnhart17-Aug-02 9:48 
AnswerRe: Attribute value choking parser? Pin
Zdenek Navratil21-Aug-02 3:04
Zdenek Navratil21-Aug-02 3:04 
GeneralXPath query Pin
Jan R Hansen15-Aug-02 5:00
Jan R Hansen15-Aug-02 5:00 
GeneralRe: XPath query Pin
Christopher Lord15-Aug-02 7:27
Christopher Lord15-Aug-02 7:27 
GeneralRe: XPath query Pin
Jan R Hansen15-Aug-02 22:13
Jan R Hansen15-Aug-02 22:13 
GeneralRe: XPath query Pin
Philip Fitzsimons16-Aug-02 0:28
Philip Fitzsimons16-Aug-02 0:28 
QuestionWhat wrong with this clause?? Pin
Tida13-Aug-02 9:51
Tida13-Aug-02 9:51 
AnswerRe: What wrong with this clause?? Pin
Christopher Lord14-Aug-02 16:43
Christopher Lord14-Aug-02 16:43 
GeneralRe: What wrong with this clause?? Pin
Tida15-Aug-02 2:55
Tida15-Aug-02 2:55 
AnswerRe: What wrong with this clause?? Pin
Ranjan Banerji15-Aug-02 3:33
Ranjan Banerji15-Aug-02 3:33 
QuestionSchema: exclude element from occuring within itself? Pin
Jonnie White13-Aug-02 1:49
Jonnie White13-Aug-02 1:49 
GeneralEmbedded html Pin
Lilian Chan-Grant6-Aug-02 10:03
Lilian Chan-Grant6-Aug-02 10:03 
GeneralRe: Embedded html Pin
Lilian Chan-Grant7-Aug-02 9:28
Lilian Chan-Grant7-Aug-02 9:28 
Generalexslt set:distinct template order Pin
Chris_D5-Aug-02 6:30
Chris_D5-Aug-02 6:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.