xsl-list
[Top] [All Lists]

Re: [xsl] Listing keywords

2006-06-12 03:44:11
On 6/12/06, Phillip B Oldham <phillip(_dot_)oldham(_at_)kilo75(_dot_)com> 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>