xsl:value-of には、xsl:sortなどの次の xsl 要素を含めることはできません。sort コマンドは、実際にはxsl:for-eachまたはxsl:apply-templatesのいずれかにのみ適用されます。
<xsl:for-each select="short_name/value" >
<xsl:sort select="."/>
<xsl:value-of select="." />
</xsl:for-each>
または、for-each よりもテンプレートを使用する方が望ましいため、次のようにすることもできます。
<xsl:apply-templates select="short_name/value">
<xsl:sort select="."/>
</xsl:apply-templates>
この場合、XSLT プロセッサのデフォルトの動作はテキストを出力するため、テキスト値以外のものを出力する場合を除き、値要素に一致するテンプレートは必要ありません。
注意すべきことの 1 つは、サンプルでは、オプション要素を 1 つだけ出力することです。ID または short_name ごとに 1 つずつ、複数のものが必要ではないですか。もちろん、XML 入力サンプルによって異なりますが、次のような XML があるとします。
<people>
<person><id><value>3</value></id><short_name><value>C</value></short_name></person>
<person><id><value>1</value></id><short_name><value>A</value></short_name></person>
<person><id><value>2</value></id><short_name><value>B</value></short_name></person>
</people>
次に、次の XSLT を使用すると、
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="people">
<xsl:apply-templates select="person">
<xsl:sort select="short_name/value"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="person">
<option value="{id/value}">
<xsl:value-of select="short_name/value"/>
</option>
</xsl:template>
</xsl:stylesheet>
次に、以下が出力されます
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>