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

Muenchian grouping help - removing 'duplicates' from a

Subject: Muenchian grouping help - removing 'duplicates' from a nodeset
From: <Laura@xxxxxxx>
Date: Thu, 9 Oct 2003 14:32:12 +0100
xslt removing duplicates
Hi all,

This is probably quite a basic question, but I've been scratching my head
over it all day and I could use some guidance.

I have an XML file which is going to be used as a "dictionary" for an
internationalised web application. The structure of he file is like so:

<dictionary>
	<text>foo</text>
	<text>bar</text>
	<text>foo</text>
	<text>baz</text>
	<text>foobar</text>
	(etc...)
</dictionary>

The file contains quite a few "duplicates" (in terms of the text() content
of the node), and I've been trying to figure out a way to strip out all the
dupicates, leaving me with an XML file with only unique <text> elements. 

I wrote an XSL to identify all the duplicates, and print them out [basically
using: test="current() = following-sibling::text or current() =
preceding-sibling::text"] But now I want to actually remove the duplicates
and create a new XML file in the output tree. 

I think they way to do this is via Muenchian grouping. I know what I need to
do: group all the <text> elements by their text() content; and select only
the first one in each group. But I've followed the guidelines on Jeni
Tennison's XSLT pages and I can't seem to get my head around how keys
actually work. 

So far I have tried (these are obviously just sample lines from my XSL):

<xsl:key name="text-by-content" match="text" use="normalize-space(text())"
/>

And then:

<xsl:apply-templates select="text[generate-id(.) =
generate-id(key('text-by-content', text())[1])]"/>

But this produces no output at all. 

I'm sure what I'm missing is blatently obvious... :-/

I'm using Sablotron 1.0, if that makes any difference. 

Thanks in advance,
Laura.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.