EXSLT - set:leading

Implementer Page: set.leading.html
Function Package: set.leading.zip

Function Syntax

node-set set:leading(node-set, node-set)

Template Syntax

<xsl:call-template name="set:leading">
   <xsl:with-param name="nodes" select="node-set" />
   <xsl:with-param name="node" select="node-set" />
</xsl:call-template>

The set:leading function returns the nodes in the node set passed as the first argument that precede, in document order, the first node in the node set passed as the second argument. If the first node in the second node set is not contained in the first node set, then an empty node set is returned. If the second node set is empty, then the first node set is returned.

The set:leading template applies templates to these nodes in set:leading mode. By default, the nodes are copied by this template, so that a result tree fragment consisting of the nodes is returned.

Implementations

The following XSLT processors support set:leading:

Implementations of set:leading are available in the following languages:

Examples

Function

The following example shows how to use the set:leading function:

Source

<doc>
   <a />
   <b />
   <c />
   <d />
   <e />
   <f />
   <g />
   <h />
</doc>

Stylesheet

<xsl:template match="doc">
   <out>
;
            <xsl:value-of select="count(set:leading(*, g))" />
;
            <xsl:value-of select="count(set:leading(*, b))" />
;
            <xsl:value-of select="count(set:leading(*, d|f|h))" />
;
            <xsl:value-of select="count(set:leading(*, a|f|h))" />
;
            <xsl:value-of select="count(set:leading(*, x))" />
;
            <xsl:value-of select="count(set:leading(x, *))" />
;
            <xsl:value-of select="count(set:leading(a|b|c, h))" />
;
    
   </out>
</xsl:template>

Result

<out>;
      6;
      1;
      3;
      0;
      8;
      0;
      0;
    </out>

http://www.exslt.org/set/functions/leading/index.html last modified 2002-11-12