XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
giancarlo rossiSubject: Sort before paging
Author: giancarlo rossi
Date: 25 Aug 2006 10:07 AM
Originally Posted: 25 Aug 2006 10:08 AM
I need to sort a xml document before paging.

I use this kind of paging :
<xsl:param name="start" select="1"/>
<xsl:param name="range" select="5"/>
<xsl:template match="/">

<xsl:for-each select="/CommandList/CheckRouting/RouterList/Router/GroupList/Group/OutwardList/Outward[position() &gt;=$start and position() &lt; $start + $range]" >
<xsl:sort select="Price/Amount" data-type="number" order="ascending" />
'my code
</xsl:for-each>
</xsl:template>

The problem is that the whole document is not sorted by price,
so for each page the xsl display only the results order by price...
page per page.

infact the last value of page (1) is not greater then the first of the following page.

So I need to sort all the document by price ascending before paging.

How can I do it.
I hope you can help me.

Regards.


Postnext
James DurningSubject: Sort before paging
Author: James Durning
Date: 25 Aug 2006 01:50 PM
One way is to create a function that takes a parameter of the sorted list, and filters by position.

<xsl:param name="start" select="1"/>
<xsl:param name="range" select="5"/>
<xsl:template match="/">
<xsl:call-template name="positionfilter">
<xsl:with-param name="sortedlist">
<xsl:for-each select="/CommandList/CheckRouting/RouterList/Router/GroupList/Group/OutwardList/Outward[position() &gt;=$start and position() &lt; $start + $range]" >
<xsl:sort select="Price/Amount" data-type="number" order="ascending" />
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:with-param>
</xsl:call-template/>
</xsl:template>


<xsl:template name="positionfilter">
<xsl:param name="sortedlist"/>
<xsl:for-each select="$sortedlist/*[(position() &gt;= $start) and (position() &lt; $start + $range)]">
'my code
</xsl:for-each>
</xsl:template>

Postnext
giancarlo rossiSubject: Sort before paging
Author: giancarlo rossi
Date: 25 Aug 2006 04:17 PM
Thanks.
I think that is the right solution, but now it goes on error...

"the stylesheet is empty or is it should be a not valid Document xml"
I translate from Italian this error.

It's possible that I must change all the path inside tha main template
"positionfilter" for example :

<xsl:variable name="router" select="$sortedlist/CommandList/CheckRouting/TotalRouters"/>

or

<xsl:value-of select="count($sortedlist/CommandList/CheckRouting/RouterList/Router/GroupList/Group/OutwardList/Outward)"/>


please advice me.












Posttop
giancarlo rossiSubject: Sort before paging
Author: giancarlo rossi
Date: 26 Aug 2006 05:02 AM
The error it given by

<xsl:call-template name="positionfilter">
<xsl:with-param name="sortedlist">

in the function one.

IF I omitted it works but of course is not able to create ant sorted list...


 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.