Subject: [xsl] Grouping with contains From: Eric Baker <ericwaynebaker@xxxxxxxxx> Date: Tue, 10 Jan 2006 12:59:57 -0500 |
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] Recursion of variable, pt. 2, watchstone@xxxxxxxxx | Thread | RE: [xsl] Grouping with contains, Michael Kay |
[xsl] Recursion of variable, pt. 2, watchstone@xxxxxxxxx | Date | RE: [xsl] Grouping with contains, Michael Kay |
Month |