XPTY0004

This error is a general type error that is raised when a value has a type that is incompatible with the type expected by a function or other expression. This could be because the type of the value is incorrect for the expression, which is the case when you try to multiply two strings. It could also arise if the value is a sequence of fewer or more items than are expected, for example when you pass the substring function a sequence of multiple strings instead of just a single string.

Common cases that raise this type error are:

  • Comparing values with incomparable types, for example, "abc" = 1.

  • Attempting to compare sequences of more than one value using the value comparison operators, for example, (1, 2) eq (1, 2).

  • Attempting arithmetic operations on values that are not numbers or dates, for example, "abc" + "def".

  • Calling a function with arguments that have incorrect types, for example, substring(1234, 3), whose first argument is an integer instead of a string.

  • Calling a function with too few or too many items in an argument, for example, substring( ("a", "b"), 3), which passes a sequence of two items as the first argument instead of just one.

  • Passing an invalid operand to a type constructor or cast as expression. This includes passing a nonliteral value when constructing a value of type xs:QName (or a type derived from xs:QName or xs:NOTATION). These types have a special constraint that they can only accept a literal xs:string value, not an evaluated expression.

  • Using an order by clause that returns more than one item to sort on, for example, order by $prod/*.

  • Specifying a value with an incompatible type in a type constructor or cast expression, as in 53 cast as xs:date.

  • Supplying an element node that has not been validated to a function that expects a validated element node.

  • Calling a function that relies on the current context node, when the current context item is an atomic value rather than a node. A number of built-in functions will operate on the current context node by default if no appropriate argument is passed. These functions are base-uri, id, idref, lang, local-name, name, namespace-uri, and root.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.19.174