Passing global variable to sort in apply-temp
Added by Anonymous over 16 years ago
Legacy ID: #4800881 Legacy Poster: geek.shrek (geek-shrek)
Hi, I'm using xslt 2 and I set my global variable from java Transformer. the variable has passed from java code to XSLT. Is it possible to pass a global variable to apply-templates? my variable: <xsl:param name="SortBy" /> my apply-templates <xsl:apply-templates> <xsl:sort select="$SortBy" data-type="text" order="ascending"/> </xsl:apply-templates> Thanks,
Replies (1)
RE: Passing global variable to sort in apply- - Added by Anonymous over 16 years ago
Legacy ID: #4802549 Legacy Poster: Michael Kay (mhkay)
What you have written is perfectly valid syntax, but the value of a global variable is constant for the duration of a transformation, and using a constant as a sort key is not very useful. I suspect that $sortBy might be a string in the form of an XPath expression, and that what you really want to do is to evaluate this XPath expression once for each item in the sequence to be sorted. You can do this using saxon:evaluate().
Please register to reply