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

RE: How to sort?

Subject: RE: How to sort?
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Thu, 14 Oct 2004 12:28:58 +0300
food state
Hi,

> If this is the XML with previously missing root-elements
>
> <Documents>
>        <Document title="1" chapter="i" href="file1.xml" filter="food">
>                <Article title="1.1" info="sub" filter="drink"
> state="1"/>
>                <Article title="1.2" info="main" filter="food"
> state="3"/>
> 			   <Article title="1.3" info="main"
> filter="drink" state="2"/>
>        </Document>
>        <Document title="2" chapter="ii" href="file2.xml"
> filter="drink">
>                <Article title="2.1" info="main"
> filter="drink" state="1"/>
>                <Article title="2.1" info="sub" filter="drink"
> state="3"/>
>                <Article title="2.2" info="main" filter="food"
> state="2"/>
>        </Document>
>        <Document title="3" chapter="1" href="file2.xml" filter="">
>                <Article title="3.1" info="sub" filter="drink"
> state=""/>
>                <Article title="3.2" info="child" filter="" state="8"/>
>        </Document>
>        <Document title="4" chapter="2" href="file2.xml" filter="">
>                <Article title="3.1" info="sub" filter="drink"
> state=""/>
>                <Article title="3.2" info="main" filter="food"
> state="1"/>
>        </Document>
> </Documents>
>
>
> could this be correct XSLT for my output. Could you check it? It runs
> very slow for some reason.

I get (Saxon 6.5.3, intended in Xselerator)

<?xml version="1.0" encoding="utf-8"?>
<Documents>
  <Document title="1" chapter="i" href="file1.xml" filter="food">
    <Article title="1.3" info="main" filter="drink" state="2"/>
    <Article title="1.2" info="main" filter="food" state="3"/>
  </Document>
  <Document title="2" chapter="ii" href="file2.xml" filter="drink">
    <Article title="2.1" info="main" filter="drink" state="1"/>
    <Article title="2.2" info="main" filter="food" state="2"/>
  </Document>
  <Document title="4" chapter="2" href="file2.xml" filter="">
    <Article title="3.2" info="main" filter="food" state="1"/>
  </Document>
</Documents>

Which engine are you using? Also, is you stylesheet

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Documents>
   <xsl:apply-templates select="Documents/Document[Article/@info = 'main']"/>
</Documents>
 </xsl:template>
 <xsl:template match="Document">
   <xsl:copy>
     <xsl:copy-of select="@*"/>
     <xsl:for-each select="Article[@info = 'main']">
       <xsl:sort select="@state" data-type="number"/>
       <xsl:copy-of select="."/>
     </xsl:for-each>
   </xsl:copy>
 </xsl:template>
</xsl:stylesheet>

or did you embed the templates into some other stylesheet your've not showing
us?

Cheers,

Jarno - Seabound: Contact

Current Thread
  • How to sort?
    • Mike G - Thu, 14 Oct 2004 10:06:35 +0200
      • <Possible follow-ups>
      • Jarno.Elovirta - Thu, 14 Oct 2004 11:45:38 +0300
        • Mike G - Thu, 14 Oct 2004 11:17:44 +0200
      • Jarno.Elovirta - Thu, 14 Oct 2004 12:28:58 +0300 <=
        • Mike G - Thu, 14 Oct 2004 11:43:11 +0200
      • Jarno.Elovirta - Thu, 14 Oct 2004 12:51:07 +0300

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.