我想知道可以在模板中传输变量并获取值。例如在模板 A 中设置变量并在模板 B 中获取值?我尝试使用调用模板,但我没有得到价值。
<xsl:template name="Transf">
<xsl:param name="T1"/>
<xsl:value-of select="$T1"/>
</xsl:template>
<xsl:template match='director/filmDirectors'>
<xsl:if test="filmDirector='Allen Woody'">
<xsl:call-template name="Transf">
<xsl:value-of select="@id"/><xsl:with-param name="T1" select="@id"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match='movie/titles'>
<xsl:call-template name="Transf">
<xsl:with-param name="T1"><xsl:value-of select="tile[@id=$T1]"/></xsl:with-param>
</xsl:call-template>
</xsl:template>
XML 文件
<list>
<director>
<filmDirectors>
<filmDirector id="steve-s">
<lname>Spielberg</lname>
<lfirstname>Steven</lfirstname>
</filmDirector>
<filmDirector id="woody-a">
<lname>Allen<lname>
<lfirstname>Woody</lfirstname>
</filmDirector>
<filmDirectors>
</director>
<movie>
<titles>
<title id="steve-s">Jurassic Park</title>
</titles>
<titles>
<title id="woody-a">Small Time Crooks</title>
</titles>
</movie>
你能给我建议吗?
预先感谢您的回复。