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

Sorting issue, sorting by description given code

Subject: Sorting issue, sorting by description given code
From: "Tony Rowe" <tony.rowe@xxxxxxxxxxxxxx>
Date: Wed, 29 Oct 2003 11:19:55 +1100
tony rowe
Hi all.

I have the following problem.

This is the xml...

<SEEDB>
...

	<Groups>
  	<Group displayed="true" name="DEFAULT" num="0" /> 
	<Group displayed="true" name="GROUP1" num="1" />
	.
	.
	.
	<Group displayed="true" name="TREES" num="15" />
	.
	.
	.
  	<Group displayed="true" name="LOTS" num="19" /> 
	.
	.
	.
	</Groups>
	...

	<Points>
  	<Point group="19"  /> 
  	<Point group="15" /> 
  	<Point group="0" /> 
	</Points>

...
</SEEDB>

Aim: To output a list of those Group names for which a Point belongs to,
sorted alphabetically.

>From above we have three points, so the desired result would be thus

Group List...

DEFAULT
LOTS
TREES 



This is an extract from my xsl stylesheet to process this file, showing
that I am using a key to get unique group names based upon the Points
node set .

<xsl:key name="groups" match="Point" use="@group" /><!-- For Lines,
change match to Line-->

 <xsl:template match="SEEDB">
    <table class = "style1" border="1" cellspacing="0" cellpadding="2"
width="650">
      <tr > 
        <th align="center">Point Groups</th>
      </tr>
      	<!--xsl:for-each select="./Points/Point"-->

		<xsl:for-each select="./Points/Point[generate-id(.) =
generate-id(key('groups',@group)[1])]"> <!--For Lines, change to
./Lines/Line[gen...etc] -->

		<xsl:sort select="./@group" data-type="text"/>
			<xsl:apply-templates select="."/>
		</xsl:for-each>	 
    </table>
</xsl:template>

	<xsl:template match="Point"><!--For Lines, change match to
Line-->

		<tr>
			<td align="center"><xsl:value-of
select="/SEEDB/Groups/Group[@num=$group]/@name"/></td>

		</tr>
	</xsl:template>




I am using sort to order by the Point @group attribute, and applying a
template match on Point and the following result is achieved...

DEFAULT
TREES
LOT

I know why this is happening, since it is being sorted by num rather
than by name, but how can I apply a sort to the name attribute of the
group, since the name attribute is not an attribute of Point?

I expect that I could do this setting up a nodeset variable, storing all
the names node in this variable (instead of outputting immediately),
sort the nodeset, and then output, but I wanted to avoid this if
possible, since I am led to believe that some parsers don't have an
equivalent "msxsl:node-set" function.

Hope this makes sense.

Tony Rowe

 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.