Xslt allowed arguments in concat and normalize-space

I was looking at the code and I saw this:

<xsl:variable name="newlist" select="concat(normalize-space($list), ' ')" />

I'm just curious with this information, can I confidently say that $ list is stringand normalize-space($list)will certainly return to me string, and the string concat(normalize-space($list), ' ')will definitely return to me string(and the last character of this string is a space?)

+3
source share
2 answers

$listcould be a string, a number, a set of node, whatever. The result will be a string. And yes, the last character will be a space.

For instance:

<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>

returns

18stringotherstring
+1
source

, , , , $list - , normalize-space . .

 <xsl:value-of select="concat(normalize-space(13), ' ')"/>

.

concat normalize-space.

, , $list ,

<xsl:variable name="list" select="12 34" />

, , , .

0

All Articles