Subject: RE: [xsl] XSL distinct group by date From: "Mindy McCutchan" <karma@xxxxxxxxxxxxxx> Date: Sun, 01 May 2005 14:12:13 -0500 |
Peter, My apologies for the late reply. I had another project pop up in between this one. Thank you for the suggestion. That solved my problem. However, I've encountered another issue. I've been using this as a guide: http://sources.redhat.com/ml/xsl-list/2000-07/msg00458.html I've slightly altered that XML set to fit the structure of my XML and it doesn't do as I would have expected. I'm hoping someone can explain why to me. Altered XML: <company> <projects> <project> <name>Customer 1</name> </project> <project> <name>Customer 2</name> </project> <project> <name>Customer 2</name> </project> </projects> <papers> <paper> <title>A Paper Title</title> </paper> </papers> </company> Now if I use the XSLT in the above link (http://sources.redhat.com/ml/xsl-list/2000-07/msg00458.html), it does return the distinct customer name values, but it also writes out the value of the nodes outside the /projects level, yielding: Customer 1Customer 2 A Paper Title Any explanation of this behavior would be very helpful. Thank you and again, my apologies for the delay in response. Mindy > >-----Original Message----- > >Date: Mon, 25 Apr 2005 13:23:55 -0400 > >To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> > >From: "Jacoby, Peter R." <PJACOBY@xxxxxxxxxxxx> > >Subject: RE: [xsl] XSL distinct group by date > >Message-ID: > ><3CFEFF6C55FB5C42A6E68E9521D5C436DBC219@xxxxxxxxxxxxxxxxxxxx> > > > >Mindy, > > > >If you want to group your elements by only the year portion > >of the date, = > >then > >you need to change your xsl:key use attribute to only look > >at the year. > >Something like: > > > ><xsl:key name=3D"documents-by-date" match=3D"newsitem" = > >use=3D"substring(date, > >string-length(date)-3, 4)" /> > > > >Then you would call it with the same=20 > >key('document-by-date', '2004')=20 > > > >or in your code > >key('documents-by-date', substring(date, string-length(date)-3, 4)) > > > >One other piece that you may want to try is grouping more than just = > >newsitem > >elements together (I couldn't tell from your original post > >if this is = > >what you > >are looking for or not). You can use the union operator | > >to match on = > >more than > >one named element. Something like: > ><xsl:key name=3D"documents-by-date" match=3D"newsitem | > >whitepapers | > >pressreleases" use=3D"substring(date, string-length(date)-3, 4)" /> > > > >As you said, you could make it (slightly) simpler by storing > >the year in = > >a > >separate element (or attribute), but it's not necessary to get the = > >desired > >functionality. > > > >Hope this helps. > > > >-Peter
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSLT stylesheet to convert so, Sebastien Arbogast | Thread | RE: [xsl] XSL distinct group by dat, Wendell Piez |
[xsl] XSLT stylesheet to convert so, Sebastien Arbogast | Date | [xsl] Newbie question on Recusrion , Marco Mastrocinque |
Month |