Wrox Programmer Forums
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 17th, 2005, 02:07 PM
Registered User
 
Join Date: Jul 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sort @*

Can someone tell me why this doesn't sort:
Code:
<xsl:apply-templates select="$structure//item" mode="edit-news-item-index">
    <xsl:sort select="@*[name() = $sort]" order="ascending" />
</xsl:apply-templates>
$sort is declared earlier in the document:
Code:
<xsl:param name="sort" select="'@type'" />
Its value is changed dynamically (using ASP), depending on which attribute I need to sort by, and can be either: '@type' or '@live'.

I don't think the problem has anything to to with the XML data but, just in case, here is a sample:
Code:
<item type="article" status="display" live="20050707" home="20050707">
    <headline>London Terror Attack</headline>
    <meta />
    <content src="ITE20050707001"/>
</item>                
<item type="article" status="display" live="20050707" home="20050707">
    <headline>Temporary Closure</headline>
    <meta />
    <flash date="200500707" expires="20050712"><p>The school will be closed on Friday 8th July.</p></flash>            
    <content src="ITE20050707002"/>
</item>                
<item type="article" status="display" live="20050707" href="http://news.bbc.co.uk/1/hi/education/4659861.stm">
    <headline>Schools Closed Following Blasts</headline>
    <meta />
    <content src="ITE20050707003"/>
</item>
This has really got me stumped. Please let me know if you need more information to be able to help.

 
Old July 17th, 2005, 02:57 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The name() of the attribute node is "type", not "@type".

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 17th, 2005, 04:01 PM
Registered User
 
Join Date: Jul 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I can't believe that didn't occur to me! I'm so sorry for wasting your time - thank you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic sort order or sort datatype kapy_kal XSLT 2 September 18th, 2007 02:10 PM
how to sort cross tab.sort based on row total joxa83 Crystal Reports 7 March 2nd, 2006 09:12 AM
Unable to sort using xsl sort command sly_jimmy_boy XSLT 3 June 17th, 2005 05:15 AM
sort by question elladi Classic ASP Databases 1 March 29th, 2005 11:12 AM
SORT pallone XSLT 13 February 25th, 2005 11:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.