|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] grouping data
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
|
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








