XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (763 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
9.91Mb size Format: txt, pdf, ePub
16
/
,
//
17
[]

If two operators appear in the same row, then they are evaluated from left to right. So
A − B + C
means
(A − B) + C
.

Appendix B

Error Codes

The XSLT and XPath specifications associate error codes with each error condition. There is an implicit assumption here that although the W3C specification defines no API for invoking XPath expressions, there will be such APIs defined elsewhere, and they will need some way of notifying the application what kind of error has occurred. The error codes may also appear in error messages output by an XSLT processor, though there is no guarantee of this.

Technically, error codes are QNames whose namespace is
http://www.w3.org/2005/xqt-errors
. The 8-character code that you usually see, such as XPTY0004, is the local part of the QName. This mechanism allows additional error codes defined by a product vendor or application writer to be allocated in a different namespace. If you detect an error at application level, you can call the
error()
function (see Chapter 13) to force an error to be raised, specifying the error code to be allocated.

There is no normative error message text associated with each error code, either in the specification or in this appendix: hopefully, real products will give error messages that are much more helpful than those in the specification, including an indication of where the error occurred. For each error, this appendix gives first a short description, then an explanation of possible causes. For the errors defined in the XPath and
Functions and Operators
specifications the short description is usually taken straight from the spec; for XSLT errors, the description in the spec is often quite long and technical, so the description given here is a gloss.

Experience with the XSLT and XQuery test suites suggests that different products will often report the same error in different ways, and for many error conditions there's more than one code listed that could describe it. However, understanding error messages when things go wrong can be one of the most baffling experiences while learning a new language, so I thought that listing the codes and trying to explain them would be a worthwhile use of the space.

Each error code has a two-letter type, a two-letter subtype, and a four-digit number. The types and subtypes are listed in the table below.

Type
Subtype
Meaning
FO
AR
Functions and Operators: Arithmetic
FO
CA
Functions and Operators: Casting
FO
CH
Functions and Operators: Character handling
FO
DC
Functions and Operators: Documents
FO
DT
Functions and Operators: Dates and Times
FO
ER
Functions and Operators: Error Function
FO
NS
Functions and Operators: Namespaces
FO
RG
Functions and Operators: Arguments
FO
RX
Functions and Operators: Regular Expressions
FO
TY
Functions and Operators: Typed Value Determination
XP
DY
XPath: Dynamic Errors
XP
ST
XPath: Static Errors
XP
TY
XPath: Type Errors
XT
DE
XSLT: Dynamic Errors
XT
MM
XSLT:

XT
RE
XSLT: Recoverable Dynamic Errors
XT
SE
XSLT: Static Errors
XT
TE
XSLT: Type Errors

The error codes are listed in alphabetical order.

Functions and Operators (FO)

FOAR0001

Division by zero

This error can occur when using any of the operators
div
,
idiv
, or
mod
with integer or decimal arithmetic. With floating point arithmetic, division by zero results in positive or negative infinity.

FOAR0002

Numeric operation overflow/underflow

With floating point arithmetic, overflow and underflow conditions generally produce infinity or zero, but the implementation has the option of raising this error instead. With integer and decimal arithmetic, an implementation must produce this error if the result is outside the range of values that can be represented. The capacity of a decimal or integer value is implementation-defined, so an operation that succeeds with one implementation might raise this error with another.

FOCA0001

Input value too large for decimal

Used when casting to a decimal value from a float or double that is outside the implementation-defined limits supported by the
xs:decimal
data type.

FOCA0002

Invalid lexical value

Used when an invalid argument is passed to
resolve-QName()
or
QName()
, or when the float or double value NaN, INF, or -INF is cast to
xs:decimal
.

FOCA0003

Input value too large for integer

Raised when casting from an
xs:decimal
,
xs:float
, or
xs:double
to an
xs:integer
, if the value is outside the implementation-defined limits for the
xs:integer
data type.

FOCA0005

NaN
supplied as float/double value

Used when multiplying or dividing a duration by a number, if the number supplied is NaN.

FOCA0006

String to be cast to decimal has too many digits of precision

Raised when casting from string to decimal if there are more digits than the system can represent accurately. The implementation has the option of raising this error or rounding the value.

FOCH0001

Codepoint not valid

Raised by the
codepoints-to-string()
function if the sequence of integers supplied includes a value that does not represent a legal XML character.

FOCH0002

Unsupported collation

Raised if the value of a collation argument of any function is not defined in the static context or is not supported by the implementation.

FOCH0003

Unsupported normalization form

The normalization form requested in a call to the
normalize-unicode()
function is one that the implementation does not support.

FOCH0004

Collation does not support collation units

Some collations can be used for comparing strings, but not for extracting substrings. This error is reported if the collation supplied to one of the functions
contains()
,
starts-with()
,
ends-with()
,
substring-before()
, or
substring-after()
is not able to split a string into substrings.

FODC0001

No context document

The functions
id()
and
idref()
operate within the document containing the context node. If there is no context item, or if the context item is not a node, or if the tree containing the context node is not rooted at a document node, then this error is raised.

FODC0002

Error retrieving resource

Indicates that a document requested using
doc()
or
document()
cannot be found or cannot be parsed as XML, or that
collection()
was called with no arguments when there is no default collection.

FODC0003

Function stability not defined

Repeated calls on
doc()
,
document()
, or
collection()
are required to return the same result each time unless the user explicitly waives this requirement. This error is raised if the implementation cannot return stable results perhaps because documents have been updated on disk.

FODC0004

Invalid argument to
collection()

This error means that the URI passed to the
collection()
function is not a valid URI, or does not correspond to the URI of any known collection.

FODC0005

Other books

Haunted by Brother, Stephanie
Conceived in Liberty by Murray N. Rothbard
Scene of the Brine by Mary Ellen Hughes