1

Topic: Dynamic sorting

Hello, respected!
Is XML:

<? xml version = "1.0" encoding = "utf-8"?>
<TABLE>
<ROW>
<FIO> Ivanova A.I. </FIO>
<JOB> the Steelmaker </JOB>
<SEX> 0 </SEX>
</ROW>
<ROW>
<FIO> Petrov H.Z. </FIO>
<JOB> the Engineer </JOB>
<SEX> 1 </SEX>
</ROW>
<ROW>
<FIO> Sidorov T.H. </FIO>
<JOB> the Master </JOB>
<SEX> 1 </SEX>
</ROW>
<ROW>
<FIO> Pupkin V. V </FIO>
<JOB> the Smith </JOB>
<SEX> 0 </SEX>
</ROW>
</TABLE>

There is a XSLT-transformation where at transformation fragment XML with some adjustments is transferred by parameter:

<? xml version = "1.0" encoding = "utf-8"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl = "urn:schemas-microsoft-com:xslt"
exclude-result-prefixes = "msxsl">
<xsl:param name = "p0">
<! - such fragment XML comes, for example, here:
<field name = "SEX" data-type ='number ' order ='ascending '> </field>
Naturally, the name, type and the order can be others
-->
</xsl:param>
<xsl:template match = "/">
<xsl:apply-templates select = "//ROW">
<! - how dynamic to generate this phrase:
<xsl:sort select ='SEX ' order ='ascending ' data-type ='number '/>
-->
</xsl:apply-templates>
</xsl:template>
<xsl:template match = "ROW">
<!-...->
</xsl:template>
</xsl:stylesheet>

Whether it is possible to generate dynamic somehow a phrase "sort" by a call "apply-templates"?

2

Re: Dynamic sorting

<xsl:sort select = "{$ p0/field@name}" order = ' {$ p0/field@order} ' data-type = ' {$ p0/field@data-type} '/>

Check up, probably, instead of {$p0/field@name} it is necessary to write {$p0@name}

3

Re: Dynamic sorting

_Vasilisk _;
Thanks, with type and rather turned out, and here c attribute select are not present, the studio underlines also transformation does not transit.
It was necessary to make here so:

<xsl:sort select = ' * [name () = $p0 / name] ' order = ' {$ p0 / order} ' data-type = ' {$ p0 / data-type} '/>