xsl-list
[Top] [All Lists]

Re: sort order="descending" question

2003-08-07 14:31:54
Its taking the result as a Strint and not a number I
guess and thats the problem.
Thanks
Abhi

--- "Jessica P. Hekman" <jphekman(_at_)arborius(_dot_)net> wrote:
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



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



<Prev in Thread] Current Thread [Next in Thread>