RE: [xsl] Can grouping here the solution ?

Subject: RE: [xsl] Can grouping here the solution ?
From: Roelof Wobben <rwobben@xxxxxxxxxxx>
Date: Mon, 21 Nov 2011 19:13:51 +0000
Hello,



Supposed I only want to check the page number.

Can this then work.





<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns="http://www.w3.org/1999/xhtml"; version="2.0 />

<xsl:variable name="page"/> <!-- this has to be filled with the value of page
in the xml file  -->

<xsl:variable name="pagenumber /> <! on some way I have this to fill with the
url paramater @value which contains the 2005-02 --->

xsl:for-each group select="pagenumber eq page"  group-by="page" />

   <!-- Do display here   -->

<xsl: for-each />



Roelof





> From: Robby.Pelssers@xxxxxxx
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Date: Mon, 21 Nov 2011 19:10:15 +0100
> Subject: RE: [xsl] Can grouping here the solution ?
>
> Ok Ken, thx for the advice. I actually never used to do so but at some point
in time I figured it would express more clearly the intent. I guess I should
just always assume this by default to safe on typing.
>
> -----Original Message-----
> From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx]
> Sent: Monday, November 21, 2011 6:52 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Can grouping here the solution ?
>
> In all of my professional work with XSLT I have very rarely ever had
> to address text() nodes individually.
>
> At 2011-11-21 18:41 +0100, Robby Pelssers wrote:
> >You can do something like
> >
> ><xsl:for-each group select="display-articles/section/entry"
> >group-by="concat(substring(datum/text(), 1,7), '/', page/text())">
> > <!-- this way you group on unique combinations of e.g. strings
> > like '2005-02/1' -->
> ></xsl:for-each>
> >
> >Robby
>
> In your example above where you have "datum/text()" and
> "page/text()", you are better served by using simply "datum" and "page".
>
> Consider if your user has the following:
>
> <datum>2003<!--OCR read this '3' as an '8'-->-05-02</datum>
>
> The expression "substring(datum,6,2)" evaluates as "05" as expected.
>
> The expression "substring(datum/text(),6,2)" triggers a runtime error
> because of supplying more than one node for the first argument.
>
> Remember in XPath that the value of an element is the concatenation
> of that element's descendent text nodes.
>
> I tell my students if they ever think they need to address a text
> node directly, to think again because they probably don't.
>
> I hope this is helpful.
>
> . . . . . . . . . . Ken
>
>
> --
> 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@xxxxxxxxxxxxxxxxxxxx
> Google+ profile: https://plus.google.com/116832879756988317389/about
> Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread