[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Grouping with contains

Subject: Grouping with contains
From: Eric Baker <ericwaynebaker@xxxxxxxxx>
Date: Tue, 10 Jan 2006 12:59:57 -0500
eric baker
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.