1
我願做一個字符串替換與變量的值,比如:是否可以在EXSLT str中使用變量:替換?
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:str="http://exslt.org/strings" extension-element-prefixes="str" >
<xsl:variable name="my-variable">bar</xsl:variable>
<xsl:template match="text()">
<xsl:value-of select="str:replace(. ,'foo', $my-variable)"/>
</xsl:template>
</xsl:stylesheet>
當我在文件上運行此,例如,
<?xml version="1.0" encoding="utf-8"?>
<root>foobar</root>
我這個錯誤在xsltproc/
的libxsltXPath error : Invalid type
xmlXPathCompiledEval: evaluation failed
runtime error: file C:/Users/Adam/Documents/WakhiLD/XSL/replace.xsl line 6 element value-of
XPath evaluation returned no result.
這似乎是合理的函數調用使用變量,所以我很茫然,什麼我應該做的。
感謝您的快速和明確的答案。那個XSLT 1.0樹碎片的東西以前不止一次地得到了我(具有不同的細節)...... –