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

sort order="descending" question

Subject: sort order="descending" question
From: "Jessica P. Hekman" <jphekman@xxxxxxxxxxxx>
Date: Thu, 7 Aug 2003 16:49:28 -0400 (EDT)
order by descending
I'm getting some weird behavior, and I've tried using three different XSLT 
processors, all of which do the same thing; so it must be me 
misunderstanding XSLT.

Basically, I have a list of elements in the input document, and I'm trying
to reverse their order in the output document.

Input:

  <bar>
    <baz>1</baz>
    <baz>2</baz>
    <baz>3</baz>
    <baz>4</baz>
    <baz>5</baz>
    <baz>6</baz>
    <baz>7</baz>
    <baz>8</baz>
    <baz>9</baz>
    <baz>10</baz>
    <baz>11</baz>
    <baz>12</baz>
  </bar>

XSL:

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

  <xsl:template match="/">
    <bar>
      <xsl:apply-templates select="/bar/baz">
        <xsl:sort select="position()" order="descending"/>
      </xsl:apply-templates>
    </bar>
  </xsl:template>

  <xsl:template match="baz">
    <baz><xsl:apply-templates/></baz>
  </xsl:template>

</xsl:stylesheet>


Output:

<bar>
  <baz>9</baz>
  <baz>8</baz>
  <baz>7</baz>
  <baz>6</baz>
  <baz>5</baz>
  <baz>4</baz>
  <baz>3</baz>
  <baz>2</baz>
  <baz>12</baz>
  <baz>11</baz>
  <baz>10</baz>
  <baz>1</baz>
</bar>


So I'd expect the output to be 12, 11, 10, 9, 8... But it's out of order. 
If I have only 9 elements, they are output in order; it's when I add the 
tenth that this misordering starts. All processors I tried (Sablotron, 
xsltproc, and Xalan) produced exactly the same output.

Does anyone know what's going on?

Thanks very much,
Jessica



 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.