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

Xslt transform & grouping, Using the Muenchian Method?

Subject: Xslt transform & grouping, Using the Muenchian Method?
From: "row.filter" <row.filter@xxxxxxxxx>
Date: Sun, 10 Oct 2004 19:58:57 +0200
xslt muenchian method
Hi,

I would like to group following, by attribute Title, and then filter
by attribute filter="food". Title-attribute exists in both Document
and Article elements.

That is, groups should be created based on attribute Title in Document
element, and filtered by attribute e.g. filter="food".

Currently I am using grouping and filtering in following stylesheet.

All other elements, where filter != "food" should be ignored.
Filter is global parameter.

Thank you!


Some help on the way:

XSL:

<?xml version='1.0' encoding='UTF-8'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

<xsl:key name="by-info" match="Article" use="@info"/>

<xsl:param name="filter" select="'food'"/>

<xsl:template match="Documents">
	<Documents>
		<xsl:for-each select="Document[@filter='' or
@filter=$filter]/Article[generate-id()=generate-id(key('by-info',@info)[@filter=$filter])]">
			<Document name="{@info}">
				<xsl:copy-of select="key('by-info',@info)[@filter=$filter]"/>
			</Document>
		</xsl:for-each>
	</Documents>
</xsl:template>

</xsl:stylesheet>


XML:

<Documents>
	<Document title="1" chapter="1" href="file1.xml" filter="food">
		<Article title="1.1" info="sub" filter="food"/>
		<Article title="1.2" info="main" filter="food"/>
	</Document>
	<Document title="2" chapter="2" href="file2.xml" filter="drink">
		<Article title="2.1" info="sub" filter="drink"/>
		<Article title="2.2" info="main" filter="food"/>
	</Document>
	<Document title="3" chapter="3" href="file2.xml" filter="">
		<Article title="3.1" info="sub" filter="drink"/>
		<Article title="3.2" info="child" filter=""/>
	</Document>
</Documents>


-- 

[row.filter]

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.