我正在查看一些代码,我看到了这个:
<xsl:variable name="newlist" select="concat(normalize-space($list), ' ')" />
我只是想知道这个信息,我可以肯定地说 $list 是一个 string
并且 normalize-space($list)
肯定会返回给我一个 string
和行 concat(normalize-space($list), ' ')
肯定会返回一个 string
(最后一个该字符串的字符是空格?)
最佳答案
$list
可以是字符串、数字、节点集,任何东西。结果将是一个字符串。是的,最后一个字符将是一个空格。
例如:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:variable name="node">
<node>
<subnode>string</subnode>
<subnode>otherstring</subnode>
</node>
</xsl:variable>
<xsl:variable name="string" select="concat($node,' ')"/>
<xsl:value-of select="string-length($string)"/>
<xsl:value-of select="substring-before($string,' ')"/>
</xsl:template>
</xsl:stylesheet>
返回
18stringotherstring
关于html - xslt 允许在 concat 和 normalize-space 中使用参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6276481/