EXSLT - func:result - Version 2

Version: 2
Previous Version: func.result.1.html
Status: new
Element Package: func.result.zip

Element Syntax

<func:result
   select = expression>
   <-- Content: template -->
</func:result>

When an exsl:result element is instantiated, it sets the result of the function to its value. The value of the exsl:result element is determined in a similar way to variable-binding elements as described in [11.2 Values of Variables and Parameters] of [XSLT].

Issue: exsl:result name - should exsl:result be called exsl:return instead?

Issue: exsl:reference-of - should it be possible to generate node set results by building them up gradually through an extension element such as exsl:reference-of (or exsl:append or multiple exsl:result elements)? It would help give results consisting of multiple nodes from a function. This is achievable by building an RTF with IDs pointing to the relevant nodes instead.

Issue: exsl:result parent - should the use of exsl:result be restricted to within exsl:function?

It is an error if an exsl:result element is instantiated if result nodes have been generated prior to its instantiation. Thus, the following is an unrecoverable error:

<exsl:function name="my:func">
   <foo />
   <exsl:result select="'foo'" />
</exsl:function>

It is an error if result nodes are generated following the instantiation of an exsl:result element. An XSLT processor may signal the error; if it does not signal the error, then it must recover by ignoring the result nodes. Thus, the following is an error:

<exsl:function name="my:func">
   <exsl:result select="'foo'" />
   <foo />
</exsl:function>

If an XSLT processor recovers from the error, the function is equivalent to:

<exsl:function name="my:func">
   <exsl:result select="'foo'" />
</exsl:function>

Issue: RTF after exsl:result error - should generating result nodes after instantiating an exsl:result be an unrecoverable error, or a recoverable one?

It is an error if instantiating the content of the exsl:function element results in the instantion of more than one exsl:result elements. An XSLT processor may signal the error; if it does not signal the error, it must recover by ignoring all exsl:result elements after the first.

Issue: Multiple exsl:result error - should instantiating exsl:result more than once be an unrecoverable error, or a recoverable one?

The following is an error if the value of the context node when the function is called is equal to the string 'yes', as two exsl:result elements are instantiated: one within the xsl:if and one directly within the exsl:function:

<exsl:function name="my:func1">
   <xsl:if test=". = 'yes'">
      <exsl:result select="true()" />
   </xsl:if>
   <exsl:result select="false()" />
</exsl:function>

If an XSLT processor recovers from this error, the above function is equivalent to:

<exsl:function name="my:func1">
   <xsl:choose>
      <xsl:when test=". = 'yes'">
         <exsl:result select="true()" />
      </xsl:when>
      <xsl:otherwise>
         <exsl:result select="false()" />
      </xsl:otherwise>
   </xsl:choose>
</exsl:function>

It is an error if an exsl:result element occurs within an exsl:result element. Thus the following is an error:

<exsl:function name="my:func2">
   <exsl:result>
      <exsl:result select="." />
   </exsl:result>
</exsl:function>

It is an error if instantiating the content of a variable-binding element (i.e. xsl:variable, xsl:param) results in the instantiation of an exsl:result element. Thus the following is an error:

<exsl:function name="my:func3">
   <xsl:variable name="foo">
      <exsl:result select="." />
   </xsl:variable>
</exsl:function>

If no result nodes are generated during the instantiation of the function content, and no exsl:result element is instantiated, then the result of the function is an empty result tree fragment.

3.2.1 Result Values

The exsl:result element can specify the value of the variable in three alternative ways.

  • If the exsl:result element has a select attribute, then the value of the attribute must be an expression and the returned value is the object that results from evaluating the expression. In this case, the content must be empty.

  • If the exsl:result element does not have a select attribute and has non-empty content (i.e. the exsl:result element has one or more child nodes), then the content of the exsl:result element specifies the value. The content of the exsl:result element is a template, which is instantiated to give the returned value. The value is a result tree fragment equivalent to a node-set containing just a single root node having as children the sequence of nodes produced by instantiating the template. The base URI of the nodes in the result tree fragment is the base URI of the exsl:result element.

    It is an error if a member of the sequence of nodes created by instantiating the template is an attribute node or a namespace node, since a root node cannot have an attribute node or a namespace node as a child. An XSLT processor may signal the error; if it does not signal the error, it must recover by not adding the attribute node or namespace node.

  • If the exsl:result element has empty content and does not have a select attribute, then the returned value is an empty string. Thus

    <exsl:result />

    is equivalent to

    <exsl:result select="''"/>

An implementation of this extension element in the EXSLT func namespace must conform to the behaviour described in this document.

Change History

Submitted: 2001-03-02
Creator: Jeni Tennison(http://www.jenitennison.com)

Changed the name of exsl:return to exsl:result.

VersionModifiedByDetails
2.12001-03-06Jeni Tennison

exsl:result moved into a separate module, EXSLT - Functions.

2.22001-03-10Jeni Tennison

Examples changed to reflect changes in other modules.

Copyright

http://www.exslt.org/func.result.2.html last modified 2001-03-10