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

Re: What is the simplest method for using xsl:sort wi

Subject: Re: What is the simplest method for using xsl:sort without losing attribute names and values?
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Mon, 21 Jul 2008 13:55:41 +0200
Re:  What is the simplest method for using xsl:sort  wi
Mark Wilson wrote:

In the example below, only one <Item> is shown. I tried the template you suggested.

I suggested to start with the identity transformation template and then to add a template or templates to perform the changes you want.
So you would at least need


<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

  <xsl:strip-space elements="*"/>
  <xsl:output method="xml" indent="yes"/>

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

  <xsl:template match="List">
       <xsl:copy>
           <xsl:apply-templates select="@*"/>
           <xsl:apply-templates>
               <xsl:sort select="Article/Year" />
               <xsl:sort select="Article/IssueNumber"/>
               <xsl:sort select="Article/Page" />
           </xsl:apply-templates>
       </xsl:copy>
   </xsl:template>

</xsl:stylesheet>

that way attributes (like pofis) are copied trough and the child elements of List elements, the Item elements, are sorted on Article/Year, Article/IssueNumber, Artice/Page.

The only change you probably need is to adapt the xsl:sort instructions to add the data type e.g.
<xsl:sort select="Article/Page" data-type="number"/>



--


	Martin Honnen
	http://JavaScript.FAQTs.com/

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.