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

Re: Sorting help

Subject: Re: Sorting help
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 23 May 2007 16:27:29 +0200
Re:  Sorting help
Hi Vandna,

Your XML sample was huge, try to create a minimal testing set, that's easier to make us understand the problem.

You seem to want a modified copy template or something. The XSL code you showed, does not do much, except running the default template (which, in this case, outputs only text).

This what you can use for sorting your XML, it will output all PIPTransaction elements, starting with 'Cancel' and ending with the ones that do not have that attribute at all:

<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 match="/">
<xsl:apply-templates select="pd:PIPEDocument/pd:PIPTransaction" >
<xsl:sort select="pd:Usage[@UsagePurpose = 'Cancel']" order="descending"/>

   <xsl:template match="@* | node()">
           <xsl:apply-templates select="@* | node()" />


Cheers, -- Abel Braaksma

Vandna Sharma wrote:
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 match="@*" mode="copynode">
<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: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>

Current Thread


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.
First Name
Last Name
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.