Re: [xsl] sorting and merging

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

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="";
  <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:

Current Thread