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

Grouping and sorting nodes by the values of the 2 elem

Subject: Grouping and sorting nodes by the values of the 2 elements, and displaying only 1 in the HTML output
From: ghostrider <ghostrider@xxxxxxxxxxx>
Date: Thu, 28 Jun 2001 17:15:01 +0200
xsl sorting nodes
Hi everyone,

I'm trying to process the following XML file:

<----------XML-------------------------------->

<root>
	<Bugs>
		<Bug>
			<Category1>aaa</Category1>
			<Category2>111</Category2>
			<Description>Some text</Description>
		</Bug>
		<Bug>
			<Category1>aaa</Category1>
			<Category2>222</Category2>
			<Description>Some text</Description>
		</Bug>
		...
	</Bugs>
</root>

<----------XML-------------------------------->



... where Cat2 is a subcategory of Cat1.


What I need is to get in the output is this:


<----------HTML-------------------------------->

<H1>aaa</H1>

    <H2>111<H2>
    <p>Some text</p>
    ...

    <H2>222<H2>
    <p>Description text2</p>
    ...

<H1>bbb</H2>

    <H2>333<H2>
    <p>Some text</p>

<----------HTML-------------------------------->


So all Bugs should be sorted by Category1, then by Category2, but i don't want 
to output the value of Category1 for each Bug.

The second issue is that I need to generate a linked table of contents based 
on Category1 element values:

-------------
Contents
	aaa
        bbb
	ccc
--------------

Below is part of the XSL that I already have, and which outputs both cat1 and 
cat2 (sorted) for each Bug node.

Someone please have a quick look at this - thanks!

Armin


<----------XSL-------------------------------->

<xsl:template match="root">
   <html>
      <body>
<xsl:apply-templates select="Bugs/Bug">
		<xsl:sort select="Category1" order="ascending" />
		<xsl:sort select="Category2" order="ascending" />      
</xsl:apply-templates>

                        
</body>
</html>


</xsl:template>

<xsl:template match="Bug">

 	<span >
         <p>
            <a name="Type"><xsl:value-of select="Category1"/></a></p>
	 <p><xsl:value-of select="Category2"/></p></span>

  <div>
	<p><xsl:value-of select="Description"/></p></div>

</xsl:template>


<----------XSL-------------------------------->



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


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.