Altova Mailing List Archives


RE: [xsl] XSL - using for-each with sort - can't access previoussorted nod e

From: "Wickersty, Jeff" <Jeff.Wickersty@------------------->
To:
Date: 11/25/2003 12:33:00 PM
Yes - I've got that in there. That's not the problem.

If we follow my <xsl:sort data-type="number" select="@page"/> line, my
output will be in this order:

   <question id="3" page="1"/>
   <question id="1" page="4"/>
   <question id="6" page="5"/>
   <question id="2" page="6"/>
   <question id="5" page="7"/>
   <question id="4" page="18"/>

Now - as I'm outputting the second item, I want to access the first one and
find out that its ID is "3". That's what I cant do.




-----Original Message-----
From: Rick Taylor [mailto:taylor@xxxxxxxx]
Sent: Tuesday, November 25, 2003 5:16 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] XSL - using for-each with sort - can't access
previous sorted nod e


Jeff,

Make sure that when you sort you specify the data-type
<xsl:sort select="@page" data-type="number"/>
or the 18 will come after the 1 and before the 2.

rick

At 04:45 PM 11/25/2003 -0500, you wrote:
>Hi all... just joined this list. Greetings :)
>
>I was wondering if someone might have an answer for me on this...
>
>Here's sample XML:
>
><quiz>
>    <question id="1" page="4"/>
>    <question id="2" page="6"/>
>    <question id="3" page="1"/>
>    <question id="4" page="18"/>
>    <question id="5" page="7"/>
>    <question id="6" page="5"/>
></quiz>
>
>In my XSLT, I want to sort by page. So I have:
>
><xsl:for-each select="question">
><xsl:sort select="@page"/>
>
>Now - as I am doing things to each question during the for-each, I want to
>be able to access the "id" attribute in the question outputted JUST PRIOR
to
>the one currently being outputted. I can't seem to be able to do this. I've
>tried using position() and <xsl:number> and combinations of the two, and
>have been unsuccessful. Could anyone give me some advice?
>
>Thanks,
>
>Jeff
>
>
>***************************************************************************
*
>This email may contain confidential material.
>If you were not an intended recipient,
>please notify the sender and delete all copies.
>We may monitor email to and from our network.
>
>***************************************************************************
*
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Rick Taylor
XML Developer
PPDM Association


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


****************************************************************************
This email may contain confidential material.
If you were not an intended recipient, 
please notify the sender and delete all copies.
We may monitor email to and from our network.

****************************************************************************



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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.