1. Главная
  2. Функции XPath
  3. exsl:node-set()

exsl:node-set XPath

The exsl:node-set function returns a node-set from a result tree fragment (which is what you get when you use the content of xsl:variable rather than its select attribute to give a variable value). This enables you to process the XML that you create within a variable, and therefore do multi-step processing.

You can also use this function to turn a string into a text node, which is helpful if you want to pass a string to a function that only accepts a node-set.

Синтаксис

EXSLT

node-set exsl:node-set(object)

Описание и примеры

Implementations

The following XSLT processors support exsl:node-set:

  • 4XSLT, from 4Suite. (version 0.12.0a3)
  • Xalan-J from Apache (version 2.4.D1)

The following processors support earlier versions of exsl:node-set:

  • SAXON from Michael Kay (version 6.3)
  • jd.xslt from Johannes D?bler (version 1.0.8)
  • libxslt from Daniel Veillard; implementation by Thomas Broyer (version 1.0.19)

There are currently no third-party implementations of exsl:node-set.

Examples

This use case shows the result of using exsl:node-set() to convert a result tree fragment to a node-set.

Source

<doc>
    <one />
    <two />
    <three />
    <four />
</doc>

Stylesheet

<!--  Test exslt:node-set applied to a result tree fragment  -->
<xsl:variable name="tree">
    <a>
        <b>
            <c>
                <d />
            </c>
        </b>
    </a>
</xsl:variable>
<xsl:template match="/">
    <out>
        <xsl:value-of select="count(exslt:node-set(//*))" />
    </out>
</xsl:template>

Result

<out xmlns:exslt="http://exslt.org/common">5</out>