RE: [xsl] Is it possible to create xsl:sort from input parameters using XSLT 2.0 (Saxon)?

Subject: RE: [xsl] Is it possible to create xsl:sort from input parameters using XSLT 2.0 (Saxon)?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 31 Jul 2006 17:52:53 +0100
> <xsl:param name="sortField"/>
> 
> And into this param i pass the XML:
> 
> <SortFields>
> 	<SortField>
> 		<Sort>lendername</Sort>
> 		<Order>ascending</Order>
> 		<DataType>text</DataType>
> 		<CaseOrder>lowercasefirst</CaseOrder>
> 	</SortField>
> </SortFields>
> 
> 
> rather than use 12 parameters (four for each <xsl:sort/>), I 
> had hoped that using this XML I would be able to read the 
> values out like so:
> 
> 	<xsl:sort select="$sortField/SortField[1]/Sort"
> order="{$sortField/SortField[1]/Order}"/> 

You want $sortField/SortFields/SortField[1]/Order
> 
> 
> As far as I can tell the order attribute should read 
> "acsending" out of the XML but I've no real way of finding 
> out what it is reading.

Take a look at the trace() function, or simply do <xsl:copy-of
select="$sortField"/>.

Better still, write a little schema for this XML document and make your
stylesheet schema-aware, and then the error will be reported to you at
compile time.

Michael Kay
http://www.saxonica.com/

Current Thread