[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.
> 
Welcome.

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
'x'".

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

Hope this helps -

Francis.



C:\xml>type t.xml
<?xml version="1.0" encoding="UTF-8"?>
<ex>
  <qs>
    <q type="S">
      <as>
        <a>txt</a>
      </as>
    </q>
  </qs>
</ex>

C:\xml>type t.xslt
<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:output indent="yes"/>
  <!-- the identity transform - passes anything straight through ... -->
  <xsl:template match="@*|node()[not(self::as)]" >
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
  <!-- -->
  <!-- ... 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="."/>
    </xsl:for-each>
  </xsl:template>
  <!-- -->
</xsl:transform>

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

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


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.