xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] combining common data within groups.


Subject: [xsl] combining common data within groups.
From: <Andy.Lewis@xxxxxxxxxxx>
Date: Mon, 3 Nov 2008 15:05:38 -0500

This is a new area for me. Need to eliminate duplicates that occur
within sub-groups.

XML Input example:
<?xml version="1.0"?>
<root>
	<boxes>
		<box_sizes>
			<value>square</value>
		</box_sizes>
		<box_sizes>
			<value>square</value>
		</box_sizes>
	</boxes>
	<boxes>
		<box_sizes>
			<value>round</value>
		</box_sizes>
		<box_sizes>
			<value>square</value>
		</box_sizes>
	</boxes>
	<color1>red</color1>
	<color2>blue</color2>
</root>


Desired output:
<?xml version="1.0" encoding="utf-8"?>
<root>
	<color1>red</color1>
	<boxes>
		<box_sizes>
			<value>square</value>
		</box_sizes>
	</boxes>
	<boxes>
		<box_sizes>
			<value>round</value>
			<value>square</value>
		</box_sizes>
	</boxes>
</root>


As you can see, I want to eliminate duplicate occurances of
<box_sizes/value> within  the <boxes> group.


Here's what I'm trying to do, but it's not working.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:key name="uniqueWithinParent" match="//value"
use="concat(generate-id(parent::box_sizes),.)"/>
	<xsl:template match="/">
		<root>
			<color1>
				<xsl:value-of select="root/color1"/>
			</color1>
			<xsl:for-each select="root/boxes">
				<boxes>
					<box_sizes>
						<xsl:for-each
select="box_sizes/value">
							<value>

<xsl:value-of select="value"/>
							</value>
						</xsl:for-each>
					</box_sizes>
				</boxes>
			</xsl:for-each>
		</root>
	</xsl:template>
</xsl:stylesheet>

Thanks so much for any help!!!


Current Thread
Keywords
xml
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor