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

Re: sorting and merging

Subject: Re: sorting and merging
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Tue, 03 Apr 2001 19:31:30 +0100
xslt sort with merging

Riboni Ugo wrote:
> hi everybody,
> i'm new ot this list but maybe someone can can give me some help
> to solve this problem i have.

This is a nice problem to demonstrate the advantages of "push" style
xslt programming, where the flow of control is determined by the
structure of the data being transformed, not directly by the transform.
It's a bit like event driven programming, and makes it very easy to do
things like saying "pass everything straight through unless it's an

I copied your fragment file directly, and just tidied up your main file
a bit. The transform is nice and simple.

Hope this helps -


C:\xml>type t.xml
<?xml version="1.0" encoding="UTF-8"?>
    <q type="S">

C:\xml>type t.xslt
<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  <xsl:output indent="yes"/>
  <!-- the identity transform - passes anything straight through ... -->
  <xsl:template match="@*|node()[not(self::as)]" >
      <xsl:apply-templates select="@*|node()"/>
  <!-- -->
  <!-- ... except for "as" elements - a specific match has a higher
priority -->
  <xsl:template match="as">
    <xsl:for-each select="document('new-vals.xml')/temproot/a">
      <xsl:sort select="@new" data-type="number"/>
      <xsl:copy-of select="."/>
  <!-- -->

C:\xml>saxon t.xml t.xslt
<?xml version="1.0" encoding="utf-8"?>
      <q type="S">
         <a new="1">txt</a>
         <a new="2">txt</a>
         <a new="3">txt</a>

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

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.