[xsl] Proper use of AVTs (was RE: (no subject))

Subject: [xsl] Proper use of AVTs (was RE: (no subject))
From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx>
Date: Tue, 25 Nov 2003 09:26:53 -0700
> From: Amir Yiron [mailto:amir@xxxxxxxxxxxxxxxxxx]
> Sent: Tuesday, November 25, 2003 8:29 AM
> Subject: 

Please use a subject line when posting to the list--it will make message
threading in the archives more reliable.

> I have the following line in my xslt file:
> 
> <xsl:sort select="MIB[@name=&quot;{$sortby}&quot;]"  
> order="{$sortorder}" />
> 
> when 'sortby' and 'sortorder' are valid pre-defined 
> parameters (I checked
> that both are valid at
> that point). Result shows that the sort considers the 'order' 
> but ignores
> the 'select'.
>
> When I replace the {$sortby} by a valid value, it works fine!
> Any suggestion?

Learning more about attribute value templates--when you can and can't use
them in XSLT--would be a good start.

There is no need, nor is it legal, to use an AVT in an XPath expression.  It
may not generate an error, but as you've discovered the content of the curly
braces are ignored.  There's also no need to enclose the variable within
quotes:

<xsl:sort select="MIB[@name=$sortby]" order="{$sortorder}"/>

(The order attribute does use an AVT, so that is unchanged.)

hth,
b.

| brian martinez                           brian.martinez@xxxxxxxxxxx |
| lead gui programmer                                    303.357.3548 |
| cheap tickets, part of trip network                fax 303.357.3380 |
| 6560 greenwood plaza blvd., suite 400           englewood, co 80111 |
| cendant travel distribution services   http://www.cheaptickets.com/ |

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread