|
Subject: [xsl] sort order="descending" question From: "Jessica P. Hekman" <jphekman@xxxxxxxxxxxx> Date: Thu, 7 Aug 2003 16:49:28 -0400 (EDT) |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Finding last node in recu, Jeff Kenton | Thread | Re: [xsl] sort order="descending" q, Abhijit Junnare |
| RE: [xsl] Sorting Upper-Case first., David Carlisle | Date | RE: [xsl] XPATH question, Michael Kay |
| Month |