Re: [xsl] overriding xpath functions

Subject: Re: [xsl] overriding xpath functions
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Fri, 09 Mar 2012 09:16:28 +0000
On 09/03/2012 08:26, Jakub MalC= wrote:
maybe dumb question - what happens when a processor encounters an
expression using the eq operator (and the other related operators)? Since
eq is sort of overloaded and calls different functions according to the
type of the operands (op:numeric-equal, fn:compare etc).
And especially when the operands are empty sequences - like in () eq ()?
The result is an empty sequence*, but what steps lead to it?
The description of the semantics starts in the XPath "language book", here:

After various processes such as atomization, handling of empty operands, and conversion of untypedAtomic to string, this takes you to appendix B.2, the operator mapping table, which tells you for example that if both operands are of type xs:time, the function op:time-equal(A, B) is called. This "function" is then specified in the Functions and Operators book.
Follow-up question - is it possible to override the built-in xpath
functions in XSLT or XQuery?
No, it's not. The namespace URI associated with the "op" prefix is unspecified, so there's no way of writing a function in this namespace, and the "fn" namespace is reserved in both XQuery and XSLT, so there is a specific ban on writing functions in this namespace.

* is it written somewhere in the specs, that eq returns empty sequence when some of the operands is an empty sequence? I looked, but did not find it..

Section 3.5.2 of the XPath language book, rule 2.

Michael Kay

Current Thread