特定の属性(myId)を持つドキュメントがあり、その値がゼロになるたびに値を更新する必要があります。ドキュメントは次のようになります
<?xml version="1.0" encoding="UTF-8"?><Summary>
<Section myId="0">
<Section myId="0">
<Para>...</Para>
</Section>
<Section myId="5">
<Para>...</Para>
</Section>
</Section>
</Summary>
テンプレートを使用して属性myIdを照合し、呼び出し元のプログラムから渡された一意のIDに設定していますが、ドキュメント内の属性の1つのみを照合したいと考えています。値がゼロの追加の属性は、別のIDを渡すことで更新されます。私が使用しているテンプレートは次のようになります。
<xsl:template match = '@myId[.="0"]'>
<xsl:attribute name = "{name()}">
<xsl:value-of select = "$addValue"/>
</xsl:attribute>
</xsl:template>
値addValueは、呼び出し側プログラムから渡されるグローバルパラメーターです。1日のかなりの時間、答えを探しましたが、このテンプレートを1回だけ適用することはできません。出力は、両方のmyId値をaddValueのコンテンツに置き換えます。'@myId[。"0"][1]'と一致させようとし、position()関数を使用して一致させようとしましたが、テンプレートは常にゼロであるすべてのmyId属性に適用されます。
一致するテンプレートを1回だけ適用することは可能ですか?