[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Sorting problem
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|