Subject: Re: [xsl] how with xPath 1 From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 14 Apr 2012 17:14:20 -0400 |
Hi Ken
thank you for your lines.
The question came up in class. I teach xPath and asked the students how to retrieve the first CD of each artist.
Here the xPath 1 which does the job:
//cd[not(artist = preceding-sibling::cd/artist)]
A student asked how to retrieve the newest CD of each artist.
I told the student, that I know how to do that with xPath 2.0 and gave this solution
for $i in distinct-values(//artist) return (//cd[artist eq $i and year= max(//cd[artist eq $i ]/year)])
The problem is, that in xPath 1 we have neither "for" nor "distinct-values()". So I wonder, is it possible to retrieve the newest cd of each artist with xPath 1 only.
Your proposition with XSLT 1 is nice, thank you.
-- Public XSLT, XSL-FO, UBL and code list classes in Europe -- May 2012 Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] how with xPath 1, Leo Studer | Thread | Re: [xsl] how with xPath 1, Liam R E Quin |
Re: [xsl] how with xPath 1, Leo Studer | Date | Re: [xsl] how with xPath 1, Liam R E Quin |
Month |