【发布时间】:2016-11-02 01:42:51
【问题描述】:
为什么replace()函数会删除我变量的html标签?
我有两个变量:
<xsl:variable name="content1">
<xsl:apply-templates select="." mode="my-mode">
</xsl:apply-templates>
</xsl:variable>
<xsl:variable name="content2">
<xsl:copy-of select="$content1, 'a', 'b')" />
</xsl:variable>
$content1 有 html 标签,$content2 没有,为什么?
【问题讨论】:
-
replace是一个字符串函数,它需要一个字符串作为第一个参数。如果您将节点作为第一个参数传入,它将获取该节点的字符串值并使用它。因此,例如,<content><a>hello</a> <b>world</b></content>的字符串值就是“hello world”,这就是replace的作用。