[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
hi, i was wander anyone could help me on this topic
i have a structure like this:
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:
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>
...
however, i could not get anything out of it, can somebody comment on my code, to see what went wrong?
Many thanks
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
[xsl] grouping data
Subject: [xsl] grouping data From: 林 子芯 <minikittygo@xxxxxxxxxxx> Date: Fri, 05 Jul 2002 00:24:50 +0000 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Still Time to Submit Abstract, Deborah Aleyne Lapey | Thread | Re: [xsl] grouping data, Vasu Chakkera |
Re: [xsl] Unwanted Empty Elements f, Raheem Rufai | Date | Re: [xsl] Unwanted Empty Elements f, Jarkko . Moilanen |
Month |