That's because $formslist/*
selects forms
element.
You could declare $formlist as:
<xsl:variable name="formlist" as="element()">
<forms>
<FORM form_name="form1" print_seq="1200"/>
<FORM form_name="form2" print_seq="1500"/>
<FORM form_name="form3" print_seq="9000"/>
<FORM form_name="form4" print_seq="5500"/>
</forms>
</xsl:variable>
But you will loose the forms
element in the copy.
Other solution will be an identity rule with sorting. This stylesheet:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="formlist">
<forms>
<FORM form_name="form1" print_seq="1200"/>
<FORM form_name="form2" print_seq="1500"/>
<FORM form_name="form3" print_seq="9000"/>
<FORM form_name="form4" print_seq="5500"/>
</forms>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="$formlist" mode="copy"/>
</xsl:template>
<xsl:template match="node()|@*" mode="copy">
<xsl:copy>
<xsl:apply-templates select="node()|@*" mode="copy">
<xsl:sort select="self::FORM/@print_seq"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Output:
<forms>
<FORM form_name="form1" print_seq="1200"/>
<FORM form_name="form2" print_seq="1500"/>
<FORM form_name="form4" print_seq="5500"/>
<FORM form_name="form3" print_seq="9000"/>
</forms>