func:result element is instantiated, during the instantiation of a
func:function element, the function returns with its value.
<func:result select = "expression"> <!-- Content: template --> </func:result>
Описание и примеры
It is an error for a
func:result element to not be a descendant of
func:function. It is an error for a
func:result element to have any following sibling elements aside from the
It is an error if instantiating the content of the func:function element results in the instantion of more than one
Thus 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
func:result elements are instantiated: one within the
xsl:if and one directly within the
<func:function name="my:func1"> <xsl:if test=". = 'yes'"> <func:result select="true()" /> </xsl:if> <func:result select="false()" /> </func:function>
It is an error if a
func:result element occurs within an
func:result element. Thus the following is an error:
<func:function name="my:func2"> <func:result> <func:result select="." /> </func:result> </func:function>
<func:function name="my:func3"> <xsl:variable name="foo"> <func:result select="." /> </xsl:variable> </func:function>
func:result element can specify the value of the variable in three alternative ways.
- If the
func:resultelement 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
func:resultelement does not have a select attribute and has non-empty content (i.e. the
func:resultelement has one or more child nodes), then the content of the
func:resultelement specifies the value. The content of the
func:resultelement 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
func:resultelement. 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.
func:resultelement has empty content and does not have a select attribute, then the returned value is an empty string. Thus
is equivalent to
The following XSLT processors support
- 4XSLT, from 4Suite. (version 0.12.0a3)
- SAXON 6.3 from Michael Kay (version 6.3)
- libxslt from Daniel Veillard; implementation by Thomas Broyer (version 1.0.19)
- Xalan-J from Apache (version 2.4.D1)