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

grouping data

Subject: grouping data
From: =?big5?b?qkwgpGyq5A==?= <minikittygo@xxxxxxxxxxx>
Date: Fri, 05 Jul 2002 00:24:50 +0000
2006 raheem hotmail.com

hi, i was wander anyone could help me on this topic


i have a structure like this:

<books>
<book isbn="1">
<author>
<name>author1</name>
<brithday>13/2/1965</brithday>
<description>...</description>
</author>
<type>adventure</type>
<name>bookName</name>
</book>
<book isbn="2">
<author>
<name>author2</name>
<brithday>13/2/1965</brithday>
<description>...something else </description>
</author>
<type>sci-fi</type>
<name>bookName</name>
</book>
<book isbn="3">
<author>
<name>author1</name>
<brithday>13/2/1965</brithday>
<description>...something else again </description>
</author>
<type>sci-fi</type>
<name>bookName</name>
</book>
<book isbn="4">
<author>
<name>author3</name>
<brithday>02/11/1975</brithday>
<description>...something else </description>
</author>
<type>novel</type>
<name>bookName</name>
</book>
...
</books>

i wish to group them in few way: first by the name of the author, then by type, with the following result output:

<list>
<authors>
<author name="author1"> <isbn>1</isbn> <!-- the attribute of its parents-->
<isbn>3</isbn>
</author>
<author name="author2">
<isbn>2</isbn>
</author>
...
</authors>
<booktype>
<type name="sci-fi">
<book>
<isbn>2</isbn>
<name>bookname</name>
</book>
<book>
<isbn>3</isbn>
<name>bookname</name>
</book>
...
</booktype>
...
</list>


i was i wondering how it could be achieve it. i have try to set the following keys up:

xsl:key name="sort_author_name" match="author" use="name"/>
<xsl:key name="sort_booktype" match="book" use="type"/>

and sort them with the following template:
...
<xsl:template match="books">
<list>
<!-- for the sort by author name part -->
<authors>
<xsl:for-each select="book/author[generate-id()=generate-id(key(sort_author_name, name[1])]">
<unit><xsl:attribute name="name"><xsl:value-of select="name"/></xsl:attribute>
<isbn><xsl:value-of select="../@isbn"/></isbn>
</xsl:for-each>
</authors>
...


</list>
</xsl:template>

however, i could not get anything out of it, can somebody comment on my code, to see what went wrong?

Many thanks

regards
Kit

_________________________________________________________________
使用全球最多人使用的電子郵件服務 MSN Hotmail:http://www.hotmail.com


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



Current Thread
  • grouping data
    • =?big5?b?qkwgpGyq5A==?= - Thu, 4 Jul 2002 20:24:46 -0400 (EDT) <=

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.