How to sort all data use xslt?
-
One page show 4 records. Then the first page should show as follow: 1 w 2 a 3 l 5 z But in fact, the result like this: 1 w 2 a 3 l 9 n <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="SortTest.xsl"?> <Table> <RecordSet Myid="2" title="a">2 a</RecordSet> <RecordSet Myid="1" title="w">1 w</RecordSet> <RecordSet Myid="3" title="l">3 l</RecordSet> <RecordSet Myid="9" title="n">9 n</RecordSet> <RecordSet Myid="7" title="m">7 m</RecordSet> <RecordSet Myid="6" title="k">6 k</RecordSet> <RecordSet Myid="4" title="z">5 z</RecordSet> </Table> <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://dotnet.aspx.cc/" exclude-result-prefixes="msxsl user"> <xsl:output method="html" omit-xml-declaration="yes"/> <xsl:template match="/"> <table width="100%" border="0" cellspacing="2" cellpadding="2"> <xsl:for-each select="./Table/RecordSet[position() < 5]"> <xsl:sort select="./@Myid" data-type="number" order="ascending"/> <tr> <td> <xsl:value-of select="."/> </td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> How to resolve it?
========================================= Make friends with you all. My Blog, welcome
天气常如二三月,花技不断四时春。 -
One page show 4 records. Then the first page should show as follow: 1 w 2 a 3 l 5 z But in fact, the result like this: 1 w 2 a 3 l 9 n <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="SortTest.xsl"?> <Table> <RecordSet Myid="2" title="a">2 a</RecordSet> <RecordSet Myid="1" title="w">1 w</RecordSet> <RecordSet Myid="3" title="l">3 l</RecordSet> <RecordSet Myid="9" title="n">9 n</RecordSet> <RecordSet Myid="7" title="m">7 m</RecordSet> <RecordSet Myid="6" title="k">6 k</RecordSet> <RecordSet Myid="4" title="z">5 z</RecordSet> </Table> <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://dotnet.aspx.cc/" exclude-result-prefixes="msxsl user"> <xsl:output method="html" omit-xml-declaration="yes"/> <xsl:template match="/"> <table width="100%" border="0" cellspacing="2" cellpadding="2"> <xsl:for-each select="./Table/RecordSet[position() < 5]"> <xsl:sort select="./@Myid" data-type="number" order="ascending"/> <tr> <td> <xsl:value-of select="."/> </td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> How to resolve it?
========================================= Make friends with you all. My Blog, welcome
天气常如二三月,花技不断四时春。 -
I guess its working properly. U r giving position()<5 so its getting firts four rows- 2 a 1 w 3 l 9 n and then sorting it based on myId. If u want to get desired result u have mentioned u need to change ur condition
First thanks for your reply. But I don't want to get the RecordSet which Myid <5, I want do this: First sorted all RecordSet based the Myid, and get 5 Records as first page. You know, if show 5 RecordSet/page, I need 2 pages to show all RecordSet.
========================================= Make friends with you all. My Blog, welcome
天气常如二三月,花技不断四时春。 -
First thanks for your reply. But I don't want to get the RecordSet which Myid <5, I want do this: First sorted all RecordSet based the Myid, and get 5 Records as first page. You know, if show 5 RecordSet/page, I need 2 pages to show all RecordSet.
========================================= Make friends with you all. My Blog, welcome
天气常如二三月,花技不断四时春。 -
What you are doing in ur code is first you are selecting first 5 rows and then you are applying sorting...
I guess it should work, But how u are u applying paging I am apprehensive whether u can apply it in this way, Lemme me know if have any issue...
Yes, you are right. Thanks very much for your help.
========================================= Make friends with you all. My Blog, welcome
天气常如二三月,花技不断四时春。