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

RE: Sorting problem

Subject: RE: Sorting problem
From: "Dion Houston" <dionh@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 23 Feb 2003 16:28:32 -0800
crestall
Hi Chris:

Your XML is not in the format you're expecting... removing attributes
for clarity:

	<DeliveryDays ... >
		<DeliveryMethod ...>
			<Day ... />
			<Day ... />
		</DeliveryMethod>
		<DeliveryMethod ... />
			<Day ... />
		</DeliveryDays>

If you look on the second delivery method, you have the closing tag
inside the start tag.  The Day element below it is indented, but
logically it's the same level as DeliveryMethod, hence the unexpected
response.

HTH!

Dion

-----Original Message-----
From: crestall@xxxxxxxxxxx [mailto:crestall@xxxxxxxxxxx] 
Sent: Sunday, February 23, 2003 3:59 PM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx

Hi All,

I'm stumped on this one.  I'm attempting to duplicate this xml but with
the <days> sorted by @sortID for each <DeliveryMethod>.  The first
sorting of <days> for the first <DeliveryMethod> works as it should
however <days> for the second <DeliveryMethod> are not output.  I've
tried various methods but cannot get the second grouping to output.  Any
suggestions:

----Sample XML-----
<CustomerDeliveryDays>
	<DeliveryDays Calculate="1" TimeOffset="0" MaxDaysOut="7">
		<DeliveryMethod Type="1" Desc="Standard (Truck)">
			<Day OrderDate="0" DayIndex="4"
DeliveryTime="00:00" DeliveryDescription="" DeliveryDate="2/26/2003
12:00:00 AM" DateDifference="0" SortID="111"/>
			<Day OrderDate="0" DayIndex="2"
DeliveryTime="00:00" DeliveryDescription="" DeliveryDate="2/24/2003
12:00:00 AM" DateDifference="0" SortID="63"/>
			
		</DeliveryMethod>
		<DeliveryMethod Type="2" Desc="Will Call / Pickup "/>
			<Day OrderDate="0" DayIndex="4"
DeliveryTime="00:00" DeliveryDescription="" DeliveryDate="2/26/2003
12:b00:00 AM" DateDifference="0" SortID="111"/>
			<Day OrderDate="0" DayIndex="2"
DeliveryTime="00:00" DeliveryDescription="" DeliveryDate="2/24/2003
12:00:00 AM" DateDifference="0" SortID="63"/>
		</DeliveryDays>
</CustomerDeliveryDays>


----XSL----
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<CustomerDeliveryDays>
			<xsl:apply-templates
select="CustomerDeliveryDays/DeliveryDays"/>
		</CustomerDeliveryDays>
	</xsl:template>		
	<xsl:template match="CustomerDeliveryDays/DeliveryDays">
		<DeliveryDays>
			<xsl:call-template name="AddAllAttributes" />
			<xsl:for-each select="DeliveryMethod">
				<DeliveryMethod>
					<xsl:call-template
name="AddAllAttributes" />
					<xsl:call-template
name="GetDays" />				
				</DeliveryMethod>
			</xsl:for-each>
		</DeliveryDays>
	</xsl:template>	
	<xsl:template name="GetDays">
		<xsl:for-each select="Day">
			<xsl:sort select="@sortID" order="ascending"/>
				<Day>
					<xsl:call-template
name="AddAllAttributes" />
				</Day>	
		</xsl:for-each>	
	</xsl:template>
	<xsl:template name="AddAllAttributes">
		<xsl:for-each select="@*">
			<xsl:attribute name="{name(.)}"><xsl:value-of
select="."/></xsl:attribute>
		</xsl:for-each>	 
	</xsl:template>			
</xsl:stylesheet>

Thanks in advance,

Chris Restall

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




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


Current Thread
  • Sorting problem
    • crestall - Sun, 23 Feb 2003 18:57:20 -0500 (EST)
      • <Possible follow-ups>
      • Dion Houston - Sun, 23 Feb 2003 19:26:31 -0500 (EST) <=

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.