[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Sorting help
Hi, To ensure you output all the 'Cancel' transactions first, process them first. Not tested. <xsl:template select="pd:PIPEDocument" > <xsl:apply-templates select="pd:PIPTransaction[pd:Usage/@UsagePurpose eq 'Cancel']"/> <xsl:apply-templates select="pd:PIPTransaction[not(pd:Usage/@UsagePurpose eq 'Cancel')]"> <xsl:sort select="pd:Usage/UsagePurpose" /> </xsl:apply-templates > </xsl:template> By your description, this is really a simple grouping problem. If you do not need to sort non-cancel transactions, then remove the sort instruction. Don't forget to copy the transactions: <xsl:template select="pd:PIPTransaction" > <xsl:copy-of select="." /> </xsl:template> Brad -----Original Message----- From: Vandna Sharma [mailto:sharmav@xxxxxxxxxxxxx] Sent: May 23, 2007 10:08 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Sorting help I need help sorting XML file. This is the XSLT I am using. I am trying to sort the PIPTransaction based on Usage tag, UsagePurpose. UsagePurpose="Cancel" transaction should be at the starting of the file and than rest of the transaction. Thanks In advance. <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:pd="http://www.oeb.gov.on.ca" exclude-result-prefixes="pd"> <xsl:template name="Usage"> <xsl:apply-templates mode="copynode"/> </xsl:template> <xsl:template match="@*" mode="copynode"> <xsl:copy> <xsl:apply-templates select="@*" mode="copynode"/> <xsl:apply-templates mode="copynode"/> <xsl:for-each select="pd:Usage"> <xsl:sort select="@UsagePurpose" order="descending" data-type="text"/> </xsl:for-each> </xsl:copy> </xsl:template> <xsl:template match="*" mode="copynode"> <!--xsl:element name="{local-name()}" namespace=""--> <xsl:element name="{local-name()}"> <xsl:apply-templates select="@*" mode="copynode"/> <xsl:apply-templates mode="copynode"/> </xsl:element> </xsl:template> </xsl:stylesheet>
|
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
|