[XPath] Dynamic Errors and first-item semantics

Sections 2.5.2 and 2.5.3 of the XPath book talk about "dynamic errors",
but what they say is equally applicable to type errors raised during the
evaluation phase. The examples make this clear: consider "For example,
if a function parameter is never used in the body of the function, an
implementation may choose whether to evaluate the expression bound to
that parameter in a function call." For this example to be correct, the
section must apply to all run-time errors, not only to so-called
"dynamic errors".

(The problem arises because of poor choice of terminology. We tend to
imagine that all run-time errors are dynamic errors, but they are not.)

While we are on the subject, here is a request for clarification.

The expression concat("Title:", //title) raises a type error if the
document contains more than one <title> element. 

Section 2.5.3 says:

"an implementation is not required to search for data whose only
possible effect on the result would be to raise an error"

Assuming that section 2.5.3 applies to type errors as well as to dynamic
errors, does this mean that in the above expression, the implementation
can output the value of the first <title> element in the document, and
avoid searching for any others?

If so, we have reintroduced the first-item semantics of XPath 1.0 (and
the corresponding efficiency) by the back door, and we should make this
explicit, at least by including an example.

Michael Kay 

Received on Wednesday, 18 February 2004 05:25:23 UTC