【发布时间】:2016-06-02 09:03:08
【问题描述】:
我试图将 XML 文件的所有文本作为一个节点而不是一系列节点来获取,以便检查整个文本的大小。
XML
<root>
<a>a word</a>
<b>Some text <c>in</c> the file</b>
</root>
XSL
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="$text" select="/root/descendant-or-self::*/text()" />
<xsl:message select="string-length($text)"/>
</xsl:template>
</xsl:stylesheet>
这不起作用,因为我在$text 中得到一个序列而不是一个简单的字符串。
我该怎么做?
【问题讨论】: