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树碎片的东西以前不止一次地得到了我(具有不同的细节)...... –