Subject: RE: [xsl] Grouping with contains From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 10 Jan 2006 18:22:39 -0000 |
It looks to me as if you are partitioning the URLs into two groups. You don't need Muenchian grouping where the number of groups is fixed and the grouping keys (in this case a boolean: contains(., 'globalfolder')) are known statically. You can just write: <table> <xsl:apply-templates select="R[contains(URL,'globalfolder')]"/> </table> <br/> <table> <xsl:apply-templates select="R[not(contains(URL,'globalfolder'))]"/> </table> Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Eric Baker [mailto:ericwaynebaker@xxxxxxxxx] > Sent: 10 January 2006 18:00 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Grouping with contains > > Hi all, > > I'm a *newbie* to XSLT, and while I'm an experienced Java programmer, > XSLT has challenged me more than anything else in recent memory. > > I've checked the FAQ, and I haven't seen a solution to my problem, so > I thought that I'd post. I need to group items based on a the content > of a string. I've tried the Muenchian method, but very few examples > search within strings. > > Given the following XML: > > <ABC> > <DEF> > <R N="1"> > > <URL>http://www.test.com/myfolder/anotherfolder/test1.htm</U> > <RANK>10</RANK> > </R> > <R N="2"> > > <URL>http://www.test.com/somefolder/anotherfolder/testa.htm</U> > <RANK>10</RANK> > </R> > <R N="3"> > > <URL>http://www.test.com/somefolder/anotherfolder/testb.htm</U> > <RANK>10</RANK> > </R> > <R N="4"> > > <URL>http://www.test.com/somefolder/anotherfolder/testc.htm</U> > <RANK>10</RANK> > </R> > <R N="5"> > > <URL>http://www.test.com/myfolder/anotherfolder/test2.htm</U> > <RANK>10</RANK> > </R> > </DEF> > </ABC> > > I need to produce a list where the URL containing "myfolder" are > listed first, followed by the remaining URLs, so: > > <table> > <tr><td>http://www.test.com/myfolder/anotherfolder/test1.htm</td></tr> > <tr><td>http://www.test.com/myfolder/anotherfolder/test2.htm</td></tr> > </table> > > <br/> > > <table> > <tr><td>http://www.test.com/somefolder/anotherfolder/testa.htm > </td></tr> > <tr><td>http://www.test.com/somefolder/anotherfolder/testb.htm > </td></tr> > <tr><td>http://www.test.com/somefolder/anotherfolder/testc.htm > </td></tr> > </table> > > I've tried to build an index using the following: > > <xsl:key name="myFolderIndex" match="//ABC/DEF/R" > use="URL[contains(.,'globalfolder')]"/> > > and > > <xsl:key name="myFolderIndex" match="//ABC/DEF/R/URL" > use="contains(.,'globalfolder')"/> > > and while the XPath evaluates correctly (actually > //ABC/DEF/R/URL[contains(.,'myfolder')]), I can't seem to successfully > pull the elements out of the index. > > Any help you can provide is appreciated.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Grouping with contains, Eric Baker | Thread | [xsl] Web-sevices in xslt, António Mota |
[xsl] Grouping with contains, Eric Baker | Date | [xsl] Web-sevices in xslt, António Mota |
Month |