2011-03-17 48 views
4

是否可以爲xslt模板標籤中匹配屬性值設置變量名稱。 有什麼幫助嗎?xslt模板標籤匹配屬性的變量

+0

沒有在XSLT 1.0。但是沒有任何東西阻止使用'document()'函數... – 2011-03-19 02:27:35

回答

1

我不能完全肯定要達到什麼樣的,但這裏有一個例子:

<!-- a variable --> 
    <xsl:variable name="x" select="//some/path"/> 

    <!-- a template to match all elements with the name of the variable --> 
    <xsl:template match="*[name(.)=$x]"> 
     Yes! <xsl:value-of select="."/> 
    </xsl:template> 
+8

匹配模式不能包含XSLT 1.0中的變量 – 2011-03-17 10:21:44

+0

這應該在單獨的答案中。我花了2天找到這個錯誤,因爲Xalan-J和PHP的XSLTProcessor類都檢測不到這是一個語法錯誤。 – quaylar 2014-07-15 14:28:27