This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Sorting works with String literal but not with variable


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]