This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Sorting works with String literal but not with variable
- From: "Tengshe, Ashish" <Tengshe dot Ashish at principal dot com>
- To: "'XSL-List at lists dot mulberrytech dot com'" <XSL-List at lists dot mulberrytech dot com>
- Date: Thu, 8 Aug 2002 09:48:18 -0500
- Subject: [xsl] Sorting works with String literal but not with variable
- Reply-to: xsl-list at lists dot mulberrytech dot com
I want to sort the following XML Dynamically:
<CustomerList>
<Customer>
<FName>John</FName>
<LName>Doe</LName>
<Age>26</Age>
<Phone>515-248-5025</Phone>
</Customer>
<Customer>
<FName>Josh</FName>
<LName>Ratliff</LName>
<Age>24</Age>
<Phone>515-909-0909</Phone>
</Customer>
<sortBy>Age</sortBy> //This is the element I use for determing the sort
</CustomerList>
This is working for me
<xsl:apply-templates select="/CustomerList/Customer">
<xsl:sort select="Age" />
</xsl:apply-templates>
But this is not:
<xsl:variable name="sortvar">
<xsl:value-of select="//sortBy"/>
</xsl:variable>
<xsl:apply-templates select="/CustomerList/Customer">
<xsl:sort select="$sortvar" />
</xsl:apply-templates>
Any issues with using sort like this, I tried putting an XPath directly in select of sort but still doesn't do the trick.
Thanks!
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list