0
我遇到XSL以下問題,當每個換的xsl:</p> <p>我有以下現有所使用的其他XSL文件模板:期待只有一個節點
<xsl:template name="strength">
<xsl:call-template name="show-strength">
<xsl:with-param name="medStrengthUnit1"
select="epsos:numerator/@unit"/>
<xsl:with-param name="medStrengthUnit2"
select="epsos:denominator/@unit"/>
<xsl:with-param name="medStrengthValue1"
select="translate(epsos:numerator/@value, '.', ',')"/>
<xsl:with-param name="medStrengthValue2"
select="translate(epsos:denominator/@value, '.', ',')"/>
<xsl:with-param name="medStrength1"
select="epsos:numerator"/>
<xsl:with-param name="medStrength2"
select="epsos:denominator"/>
</xsl:call-template>
</xsl:template>
現在我希望讓此模板,但我沒有一個參數添加到方法(因爲它被其它樣式表)
對於現在的可能性,我用下面的電話:
<xsl:for-each select="$strength">
<xsl:call-template name="strength"/>
</xsl:for-each>
與實力是一個PARAM從其他方法傳遞:
<xsl:with-param name="strength"
select="epsos:quantity"/>
這是工作,但我知道只有一種力量,我不喜歡它使用的xsl:for-如果每我知道已經有一定的力量。
有沒有辦法只是呼籲路徑模板,如:
//for ($strength)
<xsl:call-template name="strength"/>
聽起來像你需要並且想要將上下文節點改變爲你的'$ strength'變量,因爲你需要'for-each'或'apply-templates'。 –
你確定你不能改變「強度」模板嗎?一種可能性是給它一個默認參數,比如' ' –
另一種可能性是用' ... xsl:template>添加一個匹配屬性到模板,然後你可以使用' '而不是'for-each/call-template'。您需要根據您要使用該模板的元素類型來調整「匹配」。 –