|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: [xslt transform & grouping] Using the Muenchian M
Hi,
I have tried to implement the grouping by using the Muenchian Method according to http://www.jenitennison.com/xslt/grouping/muenchian.html, but I still receive errors when I transform. I am trying to start with Jeni's example, but keep my XML structure. (below) "Let's take our address book above. We want to group the contacts according to their surname, so we create a key that assigns each contact a key value that is the surname given in the record. The nodes that we want to group should be matched by the pattern in the 'match' attribute. The key value that we want to use is the one that's given by the 'use' attribute:" xml-file structure <?xml version="1.0" encoding="utf-8"?> <Records> <Contact id="0001"> <Doc title="Mr"/> <Doc forename="John"/> <Doc surname="Smith"/> </Contact> <Contact id="0002"> <Doc title="Dr"/> <Doc forename="Amy"/> <Doc surname="Jones"/> </Contact> </Records> xslt-file <?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="contacts-by-surname" match="Doc" use="surname" /> <xsl:template match="Records"> <xsl:for-each select="Doc[count(. | key('contacts-by-surname', surname)[1]) = 1]"> <xsl:sort select="surname" /> <xsl:value-of select="surname" />,<br /> <xsl:for-each select="key('contacts-by-surname', surname)"> <xsl:sort select="forename" /> <xsl:value-of select="forename" /> (<xsl:value-of select="title" />)<br /> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> What is the problem? Can anybody see it ? Thanx, /Michael From: Anton Triest <anton@xxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: XSLT, XML and Identity transform Date: Mon, 27 Sep 2004 18:49:54 +0200 _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








