for-eachによって生成されたテーブルを並べ替えたいと思っています。ソートを決定するデータは、for-eachノードセットには含まれていませんが、代わりに。に含まれています。ノードセットとノードセットの間にcommon_idがあります。for-each内のローカル変数にcommon_idを割り当てようとしましたが、ソートでそれを確認できません。これを達成する方法はありますか?以下のいくつかの例。
XMLの例
<root>
<seq>
<common_id>B1U3</common_id>
<seq_data>1</seq_data>
</seq>
<seq>
<common_id>R3D</common_id>
<seq_data>3</seq_data>
</seq>
<seq>
<common_id>Y3110W</common_id>
<seq_data>2</seq_data>
</seq>
<detail>
<common_id>Y3110W</common_id>
<other_data>spame</other_data>
</detail>
<detail>
<common_id>B1U3</common_id>
<other_data>spamo</other_data>
</detail>
<detail>
<common_id>R3D</common_id>
<other_data>spama</other_data>
</detail>
</root>
必要な出力
____________________________
¦Common Id ¦Other Data¦
¦---------------¦----------¦
¦B1U3 ¦spama ¦
¦Y3110W ¦spame ¦
¦R3d ¦spamo ¦
¦_______________¦__________¦
現在のXSLT
<xsl:template match="/">
<table>
<tr>
<td>Common ID</td>
<td>Other Data</td>
</tr>
<xsl:for-each select="detail">
<xsl:variable name="local_id" select="common_id"/>
<xsl:sort select="../seq[common_id = $local_id]/seq_data"/>
<tr>
<td><xsl:value-of select="common_id"/></td>
<td><xsl:value-of select="other_data"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>