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

Re: Listing keywords

Subject: Re: Listing keywords
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 12 Jun 2006 11:43:55 +0100
andrew word
On 6/12/06, Phillip B Oldham <phillip.oldham@xxxxxxxxxx> wrote:
Hi all

I'm trying to get my head around the following problem... I've got a doc
with the following structure:

<item>
    <keywords>Chair, Sofa, Cabinet</keywords>
</item>
<item>
    <keywords>Chair, Sofa</keywords>
</item>
<item>
    <keywords>Cabinet</keywords>
</item>
<item>
    <keywords>Chair</keywords>
</item>

What I need to get out of that is a list of unique keywords, eg:

<keyword>Cabinet</keyword>
<keyword>Chair</keyword>
<keyword>Sofa</keyword>

That's fine.


Anyone know how I can do this? I'm using XSL/XPath 1.0.

Oh. That makes it more long winded.


I would do this in two stages - the first is to create a nodeset of
words by processing each <keywords> element using a recursive named
template to get something like:

<word>Chair</word>
<word>Sofa</word>

Once you have stage 1 complete, use the node-set extension function of
your processor to turn the result-tree-fragment into a nodeset, then
use grouping to do a distinct on the values.

Splitting a string:
http://www.dpawson.co.uk/xsl/sect2/N7240.html#d9590e343

Grouping:
http://sources.redhat.com/ml/xsl-list/2000-07/msg00458.html

cheers
andrew

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-2011 All Rights Reserved.