Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. How to sort all data use xslt?

How to sort all data use xslt?

Scheduled Pinned Locked Moved XML / XSL
xmlcsharphtmlcomregex
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    guiqul163
    wrote on last edited by
    #1

    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
    天气常如二三月,花技不断四时春。

    P 1 Reply Last reply
    0
    • G guiqul163

      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
      天气常如二三月,花技不断四时春。

      P Offline
      P Offline
      Prateek G
      wrote on last edited by
      #2

      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

      G 1 Reply Last reply
      0
      • P Prateek G

        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

        G Offline
        G Offline
        guiqul163
        wrote on last edited by
        #3

        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
        天气常如二三月,花技不断四时春。

        P 1 Reply Last reply
        0
        • G guiqul163

          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
          天气常如二三月,花技不断四时春。

          P Offline
          P Offline
          Prateek G
          wrote on last edited by
          #4

          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...

          G 1 Reply Last reply
          0
          • P Prateek G

            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...

            G Offline
            G Offline
            guiqul163
            wrote on last edited by
            #5

            Yes, you are right. Thanks very much for your help.

            ========================================= Make friends with you all. My Blog, welcome
            天气常如二三月,花技不断四时春。

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups