一些简单的可被用任何版本的XSLT:
<xsl:variable name="vApos">'</xsl:variable>
我经常使用相同的技术用于指定报价:
concat('This movie is named ', $vQ, 'Father', $vApos, 's secrets', $vQ)
所以:
<xsl:variable name="vQ">"</xsl:variable>
然后你可以使用标准的XPath函数concat()
散布这些变量到任何文本 ,这种转化:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name="vApos">'</xsl:variable>
<xsl:variable name="vQ">"</xsl:variable>
<xsl:template match="/">
<xsl:value-of select=
"concat('This movie is named ', $vQ, 'Father', $vApos, 's secrets', $vQ)
"/>
</xsl:template>
</xsl:stylesheet>
产生:
This movie is named "Father's secrets"
问得好,+1。看到我的答案是一个有用的技术,可以很容易地将任何特殊字符混合成一个字符串。 – 2011-06-08 13:42:47