まず、またはタグ<xsl:sort...
内に表示する必要があります。<xsl:apply-templates...
<xsl:for-each...
必要に応じて主観的な論理で並べ替えるには、いくつかの方法があります。最も簡単なのはおそらくこれです:
XML
<root>
<item>dog</item>
<item>cat</item>
<item>horse</item>
<item>dragonfly</item>
</root>
XSL
<!-- this sheet vars -->
<xsl:variable name='sort_order' select='"dragonfly|horse|dog|cat"' />
<!-- root and static content -->
<xsl:template match="/">
<xsl:apply-templates select='root/item'>
<xsl:sort select='string-length(substring-before($sort_order, current()/text()))' data-type='number' />
</xsl:apply-templates>
</xsl:template>
<!-- iteration content - animal -->
<xsl:template match='item'>
<p><xsl:value-of select='.' /></p>
</xsl:template>
この XMLPlayground セッションでテストできます。
おそらくご覧のとおり、目的のソート順を文字列として宣言し、そのソート文字列内の各ノードのテキスト値の位置に基づいてノードを繰り返しソートするという概念です。