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

Sorting problem...

Subject: Sorting problem...
From: "David M. Goudreau" <david_goudreau@xxxxxxxxxxxxxxxxx>
Date: Tue, 13 Feb 2001 18:29:03 -0800
david goudreau
Hi list -

I'm trying to sort some concatenated strings in a dropdown box in my XSL.
(I'm also sure there's a more compact way to write my XSL, frankly).  My XML
is:

<root sub_id="84">
	<folder name="c" cdate="2/13/01" id="f_49">
		<folder name="m" cdate="2/13/01" id="f_42" />
	</folder>
	<folder name="y" cdate="2/13/01" id="f_45" />
	<folder name="d" cdate="2/13/01" id="f_43" />
	<folder name="r" cdate="2/13/01" id="f_44" />
	<folder name="d" cdate="2/13/01" id="f_49">
		<folder name="t" cdate="2/13/01" id="f_42">
			<folder name="z" cdate="2/13/01" id="f_42">
		</folder>
	</folder>
</root>

I want my output to look alphabetical like the following:

-c
--c:m
-d
--d:t
---d:t:z
-r
-y

My XSL looks like this:

<xsl:template match="root">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="folder">
		<xsl:if test="count(ancestor::node())='2'">
			<option>
				<xsl:attribute name="value">
					<xsl:value-of select="@id"/>
				</xsl:attribute>
				-<xsl:value-of select="@name"/>
			</option>
		</xsl:if>
		<xsl:if test="count(ancestor::node())='3'">
			<option>
				<xsl:attribute name="value">
					<xsl:value-of select="@id"/>
				</xsl:attribute>
				--<xsl:value-of select="../@name"/>:<xsl:value-of select="@name"/>
			</option>
		</xsl:if>
		<xsl:if test="count(ancestor::node())='4'">
			<option>
				<xsl:attribute name="value">
					<xsl:value-of select="@id"/>
				</xsl:attribute>
				---<xsl:value-of select="../../@name"/>:<xsl:value-of
select="../@name"/>:<xsl:value-of select="@name"/>
			</option>
		</xsl:if>
		<xsl:apply-templates/>
</xsl:template>



The results are not currently sorted at all.  Thanks much for your help!


-dmg


 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.