Sort Column In Table (ascending) Using attributes

Discussion in 'XML' started by AwanJohnie, Oct 1, 2004.

  1. AwanJohnie

    AwanJohnie Guest

    I have an XML doc and successfully transformed into a table using XSL.
    The Challenge is how to sort the information by columns. I am writting
    diffrent XSL for the diffrent sorts (i.e per column) but I can't just
    get the basic one to work. I get no errors but the data is not sorted.
    Please help.

    1. To order by Title===@name
    2. To Order by Author ===../attribute[@attid='5']
    3. To order by Date === .../attribute[@attid='3']

    XSL

    <xsl:template match="/">
    <html>
    <body>
    <xsl:apply-templates select="live" />
    </body>
    </html>
    </xsl:template>

    <xsl:template match="live">

    <table >
    <tr >
    <th>Title</th>
    <th>Author</th>
    <th>Date</th>
    </tr>
    <xsl:for-each select="llnode">

    <xsl:sort select = "./@name" order="descending"/>

    <xsl:apply-templates select="llnode" />
    </xsl:for-each>

    </table>
    </xsl:template>

    <xsl:template match="llnode">

    <tr>

    <td width="44%"> <A>
    <xsl:attribute name="HREF">
    http://www.whateverurl.org=<xsl:value-of
    select="@id"/>&amp;objAction=open </xsl:attribute>
    <xsl:value-of select="@name"/> </A> </td>
    <td ><xsl:value-of select="category/attributeset/attribute
    [@attid='5']"/></td>

    <td>
    <xsl:value-of select="substring-before(category/attributeset/attribute[@attid='3'],'T')"/></td>
    </tr>
    </xsl:template>
    </xsl:stylesheet>
     
    AwanJohnie, Oct 1, 2004
    #1
    1. Advertising

  2. AwanJohnie

    Joris Gillis Guest

    > <xsl:for-each select="llnode">
    >
    > <xsl:sort select = "./@name" order="descending"/>
    >
    > <xsl:apply-templates select="llnode" />
    > </xsl:for-each>


    Why do you use the for-each?
    I think this should work.

    <xsl:apply-templates select="llnode">
    <xsl:sort select = "./@name" order="descending"/>
    </xsl:apply-templates>



    Joris Gillis
     
    Joris Gillis, Oct 2, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Chatham

    Ascending & Descending sort in datagrid

    Steve Chatham, Feb 19, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,900
    =?Utf-8?B?U3VyZXNo?=
    Feb 19, 2004
  2. sudhir
    Replies:
    8
    Views:
    828
    Kenny McCormack
    Dec 6, 2005
  3. Eric Lilja
    Replies:
    3
    Views:
    376
    Eric Lilja
    Jan 27, 2007
  4. Navin
    Replies:
    1
    Views:
    705
    Ken Schaefer
    Sep 9, 2003
  5. Paganoni
    Replies:
    22
    Views:
    323
    Robert Klemme
    Jun 9, 2009
Loading...

Share This Page