Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort order - dynamic select

Status
Not open for further replies.

MrT2005

Programmer
Mar 8, 2005
22
CA
Is it possible to use a parameter as the select element in a sort tag?

<xsl:sort order="{$sorder}" select="$searchTerm"/>

Im trying to get the order based on the $searchTerm

ie.

so if $searchTerm = books/authors then in the xsl it would
sort by books/authors.

<xsl:sort order="{$sorder}" select="$searchTerm"/>


is this possible?
I cant get it working, is there another way to do this?

thanks!
 
Code:
<xsl:sort select="*[name()=$sorder]"/>
Although you must be careful that this always points to a node.
 
so instead of including the $searchTerm I have to use the $order in the select field?

the $order value is ascending/descending
and the $searchTerm is a node item.

when I use:
<xsl:sort order="{$sorder}" select="*[name()=$searchTerm]" />

it makes the page load infinately, no error or content shown.

any ideas?
 
Sorry, should do:
Code:
<xsl:sort select="*[name()=$searchTerm]"/>
The order is either "ascending" or "descending".
 
still doesnt work, I think the problem is that $searchTerm will only work if its just the name of one element, but not if it's a full path.

any ideas on full path string variable?
 
Ok I found the solution

<xsl:sort order="{$sorder}" select="
texte/fichetitre[$sterm='a'] |
texte/typeheberg[$sterm='b'] |
region/regionnseo[$sterm='c']
"/>


works 100% =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top