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

Lookup, eliminating duplicates and sorting

Subject: Lookup, eliminating duplicates and sorting
From: "Manfred Staudinger" <manfred.staudinger@xxxxxxxxx>
Date: Wed, 19 Jul 2006 13:29:00 -0700
sort eliminate duplicates
Hi list,
xslt 1.0 - I've a set of nodes, for which I want
a. to replace some values (most will not change), then
b. eliminate the duplicates and sort them.
Sample input xml:
<?xml version="1.0" encoding="UTF-8" ?>
		<f c="abe" b1="abc"/>
		<f c="abf" b1="abj"/>
		<f c="abg" b1="abi"/>
		<f c="abh" b1="abi"/>
The input table _e1_ will be transformed using _f_ to
and finally should become
=== what I would like to have ===
The text nodes represent URI's and are then used to
create html links. So far I was only able to write in
2 different task what should be done in one:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
<xsl:output method="xml" indent="yes" />

<xsl:template match="node() | @*">
		<xsl:apply-templates select="node() | @*"/>
<xsl:key name="dupl" match="b" use="."/>
<xsl:template match="e1">
		<xsl:for-each select="b[count(self::b|key('dupl',self::b)[1])=1]">
			<xsl:sort select="."/>
			<b><xsl:value-of select="."/></b>
<xsl:template match="e2"/>
<xsl:template match="e3"/>

<xsl:template match="node() | @*" mode="trans">
		<xsl:apply-templates select="node() | @*" mode="trans"/>
<xsl:key name="trans" match="f" use="@c"/>
<xsl:template match="e1" mode="trans">
		<xsl:for-each select="b">
				<xsl:when test="key('trans', .)/@b1">
					<b><xsl:value-of select="key('trans', .)/@b1"/></b>
					<b><xsl:value-of select="."/></b>
<xsl:template match="e2" mode="trans"/>
<xsl:template match="e3" mode="trans"/>

<xsl:template match="/">
	<xsl:apply-templates mode="trans"/>

Many thanks in advance,

Current Thread


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.
First Name
Last Name
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.