次のようなxmlの例があります。
<p class="exer_header" style="display: none;">
<image-input size="5" value="val1" />
</p>
<p class="exer_header" style="display: none;">
<image-input size="5" value="val2" />
</p>
<answers-img>
<answer-img class="imagednd_answer1" value="val1"/>
<answer-img class="imagednd_answer2" value="val2"/>
</answers-img>
および XSLT ex. ここ:
<xsl:template match="image-input">
<xsl:variable name="id" select="generate-id(.)"/>
<xsl:element name="input">
<xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
<xsl:attribute name="class">exer_input</xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="answers-img">
<xsl:for-each select="//image-input">
<xsl:element name="div">
<xsl:element name="input">
<xsl:attribute name="class">ans_img_input</xsl:attribute>
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="value">***{ID}***</xsl:attribute>
</xsl:element>
<xsl:apply-templates select="//answers-img/answer-img"/>
</xsl:element>
</xsl:for-each>
</xsl:template>
次に質問です。「input」テンプレートから別の「answers-img」テンプレートに変数idを送信して{ID}を変更するにはどうすればよいですか?
UPD:「answer-img」では、「input-img」で生成されるのと同じidが必要です。最初に xslt が "input-img" (2 回) を使用してコードを生成し、"input-img" ではなく別のテンプレートのどこかでテンプレート "answer-img" を呼び出します。グローバル配列変数を作成できますか?