xsl-list
[Top] [All Lists]

Re: [xsl] Can grouping here the solution ?

2011-11-21 09:19:11
[1] is item at position 1 (first) as in book[1] would be first book.

On Mon, Nov 21, 2011 at 4:17 PM, Roelof Wobben <rwobben(_at_)hotmail(_dot_)com> 
wrote:

thanks. I will study this well as it supposed to do what I want.



Roelof



----------------------------------------
Date: Mon, 21 Nov 2011 10:12:29 -0500
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com; 
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
From: gkholman(_at_)CraneSoftwrights(_dot_)com
Subject: Re: [xsl] Can grouping here the solution ?

At 2011-11-21 15:00 +0000, Roelof Wobben wrote:
I have this xml :
...
Now I can put the articles and the pagenumbers together with grouping I 
think.

Indeed you can. Using XSLT 2.0 is easier than using XSLT 1.0.

But how can I achieve that only one month and one page is displayed
depending on the month and pagenumber in the url of the webpage ?

By applying the grouping logic of the second criterion on the groups
created by the first criterion.

I hope the example below helps.

. . . . . . . . . Ken

t:\ftemp>type roelof.xml
<?xml version="1.0" encoding="UTF-8"?>
<display-articles>
<section id="1" handle="blog">Blog</section>
<entry id="1">
<titel handle="zwanger">Zwanger ??</titel>
<datum time="23:00" weekday="5">2005-02-04</datum>
<page>1</page>
<tekst mode="formatted"><p>Hoera, het is zover, eindelijk (...)</p>
</tekst>
</entry>
<entry id="2">
<titel handle="7-weken-echo">7 weken echo</titel>
<datum time="22:00" weekday="1">2005-02-21</datum>
<page>1</page>
<tekst mode="formatted"><p>Ik stond al onder behandeling (...)</p>
</tekst>
</entry>
<entry id="3">
<titel handle="appelgebak">Appelgebak</titel>
<datum time="23:00" weekday="6">2005-02-26</datum>
<page>2</page>
<tekst mode="formatted"><p>Met appelgebak zijn we naar jouw (...)</p>
</tekst>
</entry>
</display-articles>

t:\ftemp>xslt2 roelof.xml roelof.xsl
Group of month "02" and page "1":
Zwanger ??
7 weken echo
Group of month "02" and page "2":
Appelgebak

t:\ftemp>type roelof.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">
<xsl:output method="text"/>
<xsl:template match="display-articles">
<xsl:for-each-group select="entry" group-by="substring(datum,6,2)">
<xsl:for-each-group select="current-group()" group-by="page">
<xsl:text>Group of month "</xsl:text>
<xsl:value-of select="substring(datum,6,2)"/>
<xsl:text>" and page "</xsl:text>
<xsl:value-of select="page"/>
<xsl:text>":
</xsl:text>
<xsl:for-each select="current-group()">
<xsl:value-of select="titel"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
t:\ftemp>


--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal


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

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


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

<Prev in Thread] Current Thread [Next in Thread>