This article summarizes the codes of errors that are raised by the standard features and functions of XQuery. As the original specifications are fairly comprehensive, we tried our best to make this overview comprehensible to a wider range of readers.
The following tables list the error codes that are known to BaseX, a short description, and examples of queries raising that errors. Errors that are specific to a single module can be found in the descriptions of the respective function modules.
| Code |
Description |
Examples |
XPST0003 |
The query could not be parsed. This is the most common error; the accompanying message indicates what was expected, and where. |
1 + for $i in 1 return $i |
XPST0005 |
A type from an XML schema is referenced (schemas are not supported by BaseX). |
1 instance of element(*, xs:integer) |
XPST0008 |
A variable or type is referenced that has not been declared, or that is not visible at this place. |
$undefined |
XPST0017 |
A function call matches no known function: the name is unknown, the number of arguments is wrong, or a keyword does not match any parameter name. |
unknown-function() |
XPST0021 |
Two fields of a record type have the same name. |
declare record local:r(a, a); 1 |
XPST0051 |
A type in a sequence type (for example, in the target type of a cast expression) is unknown. |
1 instance of xs:itr |
XPST0080 |
xs:NOTATION or xs:anyAtomicType is used as target type of cast or castable. |
1 castable as xs:NOTATION |
XPST0081 |
- A name uses a prefix that has not been bound to a namespace, or
- a pragma or option declaration has no prefix.
|
unknown:x() |
XPST0152 |
The key type of a map type must be an atomic type. |
declare type local:u as map(local:t, item()); declare type local:t as element(); 1 |
XPST0154 |
A name in Q{uri}name notation has a prefix, but no namespace URI. |
Q{}a:b |
|
XQST0009 |
The query imports a schema (schema import is not supported by BaseX). |
import schema "x"; () |
XQST0022 |
The namespace URI in an element constructor must be a fixed string. |
<elem xmlns="{ 'dynamic' }"/> |
XQST0031 |
The specified XQuery version is not supported. |
xquery version "9.9"; () |
XQST0032 |
The base URI was declared more than once. |
declare base-uri "a"; declare base-uri "b"; () |
XQST0033 |
A namespace prefix was declared more than once. |
declare namespace a = "a"; declare namespace a = "b"; () |
XQST0034 |
A function was declared more than once. |
declare function local:f() { 1 }; declare function local:f() { 2 }; () |
XQST0038 |
The default collation was declared more than once, or it is unknown. |
declare default collation "a"; declare default collation "b"; () |
XQST0039 |
Two parameters of a function declaration have the same name. |
declare function local:f($a, $a) { $a }; () |
XQST0040 |
Two attributes of a constructed element have the same name. |
<elem a="1" a="2"/> |
XQST0045 |
A declared function, annotation, or type uses a reserved namespace. |
declare function fn:f() { 1 }; () |
XQST0046 |
A URI in the query text is invalid. |
declare namespace a = "%"; () |
XQST0047 |
Two module imports specify the same namespace. |
import module namespace a = "u"; import module namespace b = "u"; () |
XQST0048 |
The namespace declared in a module differs from the one specified in the import. |
import module namespace a = "uri" at "module.xqm"; ... |
XQST0049 |
A global variable was declared more than once. |
declare variable $a := 1; declare variable $a := 2; () |
XQST0052 |
The target type of cast or castable is not a known simple type. |
1 cast as unknown-type |
XQST0055 |
The mode for copying namespaces was declared more than once. |
declare copy-namespaces no-preserve, no-inherit; declare copy-namespaces preserve, inherit; () |
XQST0057 |
The namespace of a schema import must not be empty. |
import schema namespace p = ""; () |
XQST0059 |
The imported module or schema cannot be found or processed. |
import module namespace a = "unknown"; () |
XQST0065 |
The ordering mode was declared more than once. |
declare ordering ordered; declare ordering unordered; () |
XQST0066 |
The default namespace for elements or functions was declared more than once. |
declare default element namespace "a"; declare default element namespace "b"; () |
XQST0067 |
The construction mode was declared more than once. |
declare construction strip; declare construction preserve; () |
XQST0068 |
The mode for handling boundary spaces was declared more than once. |
declare boundary-space strip; declare boundary-space preserve; () |
XQST0069 |
The default order for empty sequences was declared more than once. |
declare default order empty least; declare default order empty greatest; () |
XQST0070 |
A namespace declaration overwrites a reserved namespace. |
declare namespace xml = "x"; () |
XQST0071 |
A namespace prefix is declared more than once in an element constructor. |
<a xmlns:p="uri1" xmlns:p="uri2"/> |
XQST0075 |
The query contains a validate expression (validation is not supported by BaseX). |
validate strict { <a/> } |
XQST0076 |
An order by or group by clause specifies an unknown collation. |
for $i in 1 to 2 order by $i collation "unknown" return $i |
XQST0079 |
A pragma was specified without the expression that is to be evaluated. |
(# xml:a #) {} |
XQST0085 |
An empty namespace URI was assigned to a prefix. |
<pref:elem xmlns:pref=""/> |
XQST0087 |
An unknown encoding was specified. Note that the encoding declaration is ignored in BaseX. |
xquery version "1.0" encoding "a b"; () |
XQST0088 |
An empty module namespace was specified. |
import module namespace a = ""; () |
XQST0089 |
Two variables in a for clause have the same name. |
for $a at $a in 1 return $a |
XQST0090 |
A character reference specifies an invalid character. |
"�" |
XQST0093 |
A module imports itself, directly or via other modules. |
import module ... |
XQST0094 |
group by references a variable that has not been declared before. |
for $a in 1 group by $b return $a |
XQST0097 |
A decimal-format property has an invalid value. |
declare default decimal-format digit = "xxx"; 1 |
XQST0098 |
A single decimal-format character was assigned to multiple properties. |
declare default decimal-format digit = "%"; 1 |
XQST0099 |
The context value was declared more than once. |
declare context item := 1; declare context item := 2; () |
XQST0103 |
Two variables in a window clause have the same name. |
for tumbling window $w in 1 start $w when true() return $w |
XQST0106 |
Conflicting or repeated annotations were assigned to a function. |
declare %updating %updating function local:f() { () }; () |
XQST0108 |
Output declarations may only be specified in the main module. |
Module: declare option output:method "text"; ... |
XQST0109 |
The specified serialization parameter is unknown. |
declare option output:unknown "x"; 1 |
XQST0110 |
A serialization parameter was specified more than once. |
declare option output:indent "no"; declare option output:indent "no"; 1 |
XQST0111 |
A decimal format was declared more than once. |
declare decimal-format a NaN = "!"; declare decimal-format a NaN = "?"; () |
XQST0113 |
A value for the context value may only be assigned in the main module. |
Module: declare context item := 1; ... |
XQST0114 |
A decimal-format property was specified more than once. |
declare decimal-format a NaN = "!" NaN = "?"; () |
XQST0116 |
Conflicting or repeated visibility annotations were assigned to a variable. |
declare %public %private variable $v := 1; () |
XQST0118 |
The start and end tag of an element constructor differ. |
<a></b> |
XQST0119 |
The document with the serialization parameters cannot be processed. |
declare option output:parameter-document "unknown.xml"; 1 |
XQST0125 |
An inline function must not be annotated as %public or %private. |
%public fn($x) { $x } |
XQST0134 |
The namespace axis is not supported. |
<a/>/namespace-node() |
XQST0140 |
A type declaration refers to itself, directly or via other types. |
declare type local:a as local:a; 1 |
XQST0146 |
A type was declared more than once. |
declare type local:a as xs:int; declare type local:a as xs:int; 1 |
XQST0148 |
A parameter without default value follows an optional parameter. |
declare function local:f($a := 1, $b) { 1 }; () |
| Code |
Description |
Examples |
XPDY0002 |
- No value has been assigned to an external variable, or
- no context value has been set before the query was evaluated.
|
descendant::* |
XPDY0050 |
- The value of a
treat expression does not have the required type, or - the root of the context node is no document node.
|
"string" treat as xs:int |
XPDY0130 |
A limit of the implementation was exceeded (for example, the maximum length of a string). |
|
|
XQDY0025 |
Two attributes of a constructed element have the same name. |
element x { attribute a { "" }, attribute a { "" } } |
XQDY0026 |
The content of a constructed processing instruction contains "?>". |
processing-instruction pi { "?>" } |
XQDY0041 |
The name of a processing instruction is invalid. |
processing-instruction { "1" } { "" } |
XQDY0044 |
The name of an attribute uses a reserved prefix or namespace. |
attribute xmlns { "uri" } |
XQDY0054 |
A global variable or the context value depends on itself. |
declare variable $a := local:a(); declare function local:a() { $a }; $a |
XQDY0064 |
The name of a processing instruction equals XML (case insensitive). |
processing-instruction xml { "x" } |
XQDY0072 |
The content of a constructed comment contains "--" or ends with "-". |
comment { "one -- two" } |
XQDY0074 |
The name of a constructed attribute or element is invalid, or it uses an unbound prefix. |
element { "x y" } { } |
XQDY0096 |
The name of an element uses a reserved prefix or namespace. |
element { QName("uri", "xml:n") } { } |
XQDY0101 |
A constructed namespace has an invalid prefix or URI. |
namespace xmlns { 'uri' } |
XQDY0102 |
A namespace prefix is bound twice in the same element. |
element x { namespace a { 'b' }, namespace a { 'c' } } |
XQDY0137 |
A map contains the same key twice. |
{ 1: 2, 1: 3 } |
| Code |
Description |
Examples |
FOAP0001 |
The array supplied to fn:apply has fewer members than the function has parameters. |
apply(fn($a, $b) { $a }, [ 1 ]) |
|
FOAR0001 |
A value was divided by zero. |
1 div 0 |
FOAR0002 |
A numeric value or operation causes an over- or underflow. |
12345678901234567890 |
|
FOAY0001 |
An array is addressed with a position that does not exist. |
[ 1, 2 ](3) |
FOAY0002 |
A negative array length was specified. |
array:subarray([ 1 ], 1, -1) |
|
FOCA0002 |
- A floating-point number cannot be converted to a decimal or integer value, or
- a function argument is no valid QName.
|
QName("", "el em") |
FOCA0003 |
A value is too large to be represented as integer. |
xs:integer(99e100) |
FOCA0005 |
NaN was supplied to a duration operation. |
xs:yearMonthDuration("P1Y") * xs:double("NaN") |
|
FOCH0001 |
A codepoint was specified that is no valid XML character. |
codepoints-to-string(0) |
FOCH0002 |
An unsupported collation was specified. |
compare('a', 'a', 'unknown') |
FOCH0003 |
An unsupported normalization form was specified. |
normalize-unicode('a', 'unknown') |
FOCH0004 |
The specified collation does not compare strings character by character. |
|
FOCH0005 |
An unknown character name, glyph, or codepoint was specified. |
char("unknown-name") |
|
FOCV0001 |
The CSV input is not correctly quoted. |
parse-csv('a"b') |
FOCV0002 |
A CSV option has an invalid value, or two options use the same character. |
parse-csv('a', { 'separator': 'xx' }) |
FOCV0004 |
The CSV input has no column with the specified name. |
`parse-csv('a,b
1,2', { 'header': true() })?get(1, 'unknown')` |
|
FODC0001 |
The node supplied to fn:id or fn:idref must have a document node as root. |
id("id0", <xml/>) |
FODC0002 |
The addressed resource cannot be retrieved. |
doc("unknown.xml") |
FODC0004 |
The specified collection URI is invalid. |
collection(":") |
FODC0005 |
The specified document URI is invalid. The specification leaves this error optional, and BaseX usually reports FODC0002 instead. |
|
FODC0006 |
The string supplied to fn:parse-xml is not well-formed XML. |
parse-xml("<x/") |
FODC0007 |
The parsed document is not valid according to its DTD. |
parse-xml("<x/>", { 'dtd-validation': true() }) |
FODC0008 |
The xsd-validation option has an invalid value. |
parse-xml("<x/>", { 'xsd-validation': 'bogus' }) |
FODC0009 |
The requested feature requires a schema-aware processor (which BaseX is not). |
xsd-validator({ 'validation-mode': 'lax' }) |
FODC0011 |
The string supplied to fn:parse-html cannot be parsed. |
|
FODC0013 |
No suitable XML parser is available. The internal parser of BaseX supports no DTD validation. |
parse-xml("<x/>", { 'dtd-validation': true(), 'intparse': true() }) |
FODC0014 |
The parsed document is not valid according to its XML schema. |
parse-xml("<x/>", { 'xsd-validation': 'strict' }) |
FODC0015 |
The referenced XML schema cannot be compiled. |
|
FODC0016 |
Access to an external resource was denied, because the call is not trusted. |
parse-xml('<!DOCTYPE x SYSTEM "x.dtd"><x/>', { 'dtd': true() }) |
|
FODF1280 |
The decimal format supplied to fn:format-number is unknown. |
format-number(1, "0", "invalid") |
FODF1290 |
A property of the supplied decimal format is invalid. |
format-number(1, "0", { 'decimal-separator': 'xx' }) |
FODF1310 |
The picture string supplied to fn:format-number is invalid. |
format-number(1, "invalid") |
|
FODT0001 |
A date or time calculation causes an over- or underflow. Years are limited to the range
-999999999 to 999999999. |
xs:date('2000-01-01') + xs:yearMonthDuration('P99999999999999999Y') |
FODT0002 |
A duration value or calculation causes an over- or underflow. |
implicit-timezone() div 0 |
FODT0003 |
An invalid timezone was specified. |
adjust-time-to-timezone(xs:time("01:01:01"), xs:dayTimeDuration("PT20H")) |
FODT0004 |
No timezone information is available for the specified place. |
civil-timezone(current-dateTime(), 'unknown-place') |
FODT0005 |
The supplied date or time components cannot be combined. |
|
|
FOER0000 |
Error triggered by the fn:error function. |
error() |
|
FOFD1340 |
The picture string supplied to fn:format-date, fn:format-time, or fn:format-dateTime is invalid. |
format-date(current-date(), "[]") |
FOFD1350 |
The picture string requests a component that the supplied value does not have. |
format-time(current-time(), "[Y0001]") |
|
FOHA0001 |
The specified hash algorithm is not supported. |
hash("x", "unknown") |
|
FOIX0001 |
The supplied Invisible XML grammar is invalid. |
invisible-xml("bogus") |
FOIX0002 |
The input does not conform to the Invisible XML grammar. |
|
|
FOJS0001 |
The input is no valid JSON. |
parse-json("{") |
FOJS0003 |
The JSON input contains duplicate keys, and duplicates are rejected. |
parse-json('{ "a": 1, "a": 2 }', { 'duplicates': 'reject' }) |
FOJS0005 |
The supplied JSON options are invalid. |
parse-json('""', { 'escape': true(), 'fallback': fn($s) { $s } }) |
FOJS0006 |
The supplied XML is no valid representation of JSON. |
xml-to-json(<x/>) |
FOJS0007 |
A string contains an invalid escape sequence. |
xml-to-json(<fn:string xmlns:fn="http://www.w3.org/2005/xpath-functions" escaped="true">\x</fn:string>) |
FOJS0008 |
An element cannot be converted to a map with the requested layout. |
|
|
FONS0004 |
A supplied QName uses a prefix that is bound to no namespace. |
resolve-QName("x:e", <e/>) |
|
FOPA0001 |
The origin node supplied to fn:path is no ancestor of the addressed node. |
path(<a/>, { 'origin': <b/> }) |
|
FOQM0001 |
The module URI is an empty string. |
load-xquery-module("") |
FOQM0002 |
The requested module cannot be found. |
load-xquery-module("unknown") |
FOQM0003 |
The dynamically loaded module contains a static error. |
|
FOQM0006 |
The requested XQuery version is not supported. |
|
|
FORG0001 |
A value cannot be converted to the required target type. |
xs:integer("A") |
FORG0002 |
An invalid URI was supplied to fn:resolve-uri. |
resolve-uri("x", ":") |
FORG0003 |
fn:zero-or-one was called with more than one item. |
zero-or-one((1, 2)) |
FORG0004 |
fn:one-or-more was called with an empty sequence. |
one-or-more(()) |
FORG0005 |
fn:exactly-one was called with zero or more than one item. |
exactly-one((1, 2)) |
FORG0006 |
An argument of a function call has the wrong type. |
sum((1, "string")) |
FORG0008 |
The arguments supplied to fn:dateTime have different timezones. |
dateTime(xs:date("2001-01-01+01:01"), current-time()) |
FORG0010 |
The input is no valid IETF date. |
parse-ietf-date("x") |
FORG0011 |
The specified radix is out of range (2-36). |
parse-integer("1", 1) |
FORG0012 |
The input cannot be parsed with the specified radix. |
parse-integer("z", 2) |
|
FORX0001 |
An invalid flag was specified for a regular expression. |
matches('a', 'a', 'invalid') |
FORX0002 |
The regular expression is invalid. |
matches('a', '[') |
FORX0004 |
The replacement string of a regular expression is invalid. |
replace("a", "a", "\") |
|
FOTY0013 |
Functions have no atomic value. |
data(true#0) |
FOTY0014 |
Functions have no string representation. |
string(true#0) |
|
FOUR0001 |
The IPv6 address in a URI is invalid. |
parse-uri('http://[abc/') |
|
FOUT1170 |
The specified text resource cannot be retrieved. |
unparsed-text(':') |
FOUT1190 |
The specified encoding is invalid, or the resource cannot be decoded with it. |
unparsed-text('existing-file.txt', 'InvalidEncoding') |
FOUT1200 |
The encoding of the text resource cannot be detected. |
|
|
FOXT0001 |
The available XSLT processor does not support the requested feature. |
transform({ 'delivery-format': 'raw' }) |
FOXT0002 |
The supplied transformation options are invalid. |
transform({}) |
FOXT0003 |
The XSLT transformation failed. |
transform({ 'stylesheet-text': '<x/>', 'source-node': <a/> }) |
| Code |
Description |
Examples |
SENR0001 |
Attributes, namespaces, and functions cannot be serialized on their own. |
serialize(attribute a { }) |
SEPM0004 |
If standalone or doctype-system is specified, the result must be a single element. |
|
SEPM0009 |
omit-xml-declaration is enabled, but standalone was assigned a value. |
serialize(<a/>, { 'omit-xml-declaration': true(), 'standalone': true() }) |
SEPM0010 |
undeclare-prefixes is enabled, but the XML version is 1.0. |
serialize(<a/>, { 'undeclare-prefixes': true(), 'version': '1.0' }) |
SEPM0016 |
A serialization parameter has an invalid value. |
serialize(1, { 'use-character-maps': { 'ab': 'x' } }) |
SEPM0017 |
The document with the serialization parameters raises an error. |
|
SEPM0018 |
In a parameter document, use-character-maps yields more than one item. |
|
SEPM0019 |
A parameter document specifies the same parameter more than once. |
|
|
SERE0008 |
A character cannot be represented in the chosen encoding. |
serialize('€', { 'method': 'text', 'encoding': 'US-ASCII' }) |
SERE0014 |
method is set to html, and an invalid HTML character was found. |
serialize(<a>{ char(0x80) }</a>, { 'method': 'html', 'html-version': 4.0 }) |
SERE0015 |
method is set to html, and a closing bracket (>) appears in a processing instruction. |
serialize(<a>{ processing-instruction p { 'a>b' } }</a>, { 'method': 'html', 'html-version': 4.0 }) |
SERE0020 |
A number cannot be represented in JSON (such as NaN or INF). |
serialize(xs:double('NaN'), { 'method': 'json', 'canonical': true() }) |
SERE0021 |
An item cannot be serialized as JSON. |
serialize(true#0, { 'method': 'json' }) |
SERE0022 |
The JSON output would contain the same name twice. |
|
SERE0023 |
More than one item was supplied to the JSON serializer. |
serialize((1, 2), { 'method': 'json' }) |
SERE0024 |
The result cannot be serialized as Canonical XML. |
serialize(<a xmlns:p="x"/>, { 'canonical': true() }) |
|
SESU0007 |
The specified encoding is not supported. |
serialize(1, { 'encoding': 'xyz' }) |
SESU0011 |
The specified normalization form is not supported. |
serialize(1, { 'normalization-form': 'x' }) |
SESU0013 |
The specified XML or HTML version is not supported. |
serialize(1, { 'version': '9.9' }) |
| Code |
Description |
Examples |
FOUP0001 |
The first argument of fn:put must be a document or element node. |
put(text { 1 }, 'file.txt') |
FOUP0002 |
The second argument of fn:put is no valid URI, or the target cannot be written. |
put(<a/>, '//') |
|
XUDY0009 |
The target node of a replace expression needs a parent in order to be replaced. |
replace node <target/> with <new/> |
XUDY0014 |
The node updated by the modify clause was not created by the copy clause. |
let $a := <a><b/></a> return copy $b := $a modify delete node $a/* return $b |
XUDY0015 |
A node is renamed more than once. |
let $a := <xml/> return (rename node $a as 'a', rename node $a as 'b') |
XUDY0016 |
A node is replaced more than once. |
let $a := <x>x</x>/node() return (replace node $a with <a/>, replace node $a with <b/>) |
XUDY0017 |
The value of a node is replaced more than once. |
let $a := <x/> return (replace value of node $a with 'a', replace value of node $a with 'b') |
XUDY0021 |
The update would result in an element with duplicate attribute names. |
copy $c := <x a='a'/> modify insert node attribute a { "" } into $c return $c |
XUDY0023 |
The update conflicts with existing namespaces. |
rename node <a:ns xmlns:a='uri'/> as QName('URI', 'a:ns') |
XUDY0024 |
New namespaces conflict with each other. |
copy $n := <x/> modify (insert node attribute { QName('uri1', 'a') } { "" } into $n, insert node attribute { QName('uri2', 'a') } { "" } into $n) return $n |
XUDY0029 |
The target of the update has no parent node. |
insert node <new/> before <target/> |
XUDY0030 |
Attributes cannot be inserted before or after the child of a document node. |
insert node <e a='a'/>/@a after document { <e/> }/* |
XUDY0031 |
Multiple calls of fn:put address the same URI. |
for $i in 1 to 3 return put(<a/>, 'file.txt') |
|
XUST0001 |
No updating expression is allowed at this place. |
delete node <a/>, "finished." |
XUST0002 |
An updating expression is expected in the modify clause or in an updating function. |
copy $a := <x/> modify 1 return $a |
XUST0003 |
The revalidation mode was declared more than once. |
declare revalidation ... |
XUST0026 |
The query declares a revalidation mode (revalidation is not supported by BaseX). |
declare revalidation strict; () |
XUST0028 |
No return type may be specified for an updating function. |
declare updating function local:x() as item() { () }; () |
|
XUTY0004 |
Inserted attributes must be listed before all other nodes. |
insert node (<a/>, attribute a { "" }) into <a/> |
XUTY0005 |
A single element or document node is expected as target of an insert expression. |
insert node <new/> into attribute a { "" } |
XUTY0006 |
A single element, text, comment, or processing instruction is expected as target of an insert before/after expression. |
insert node <new/> after attribute a { "" } |
XUTY0007 |
Only nodes can be deleted. |
delete node "string" |
XUTY0008 |
A single element, text, attribute, comment, or processing instruction is expected as target of a replace expression. |
replace node document { <a/> } with <b/> |
XUTY0010 |
If the target of replace is no attribute, the new nodes must not be attributes either. |
replace node <a><b/></a>/b with attribute size { 1 } |
XUTY0011 |
If the target of replace is an attribute, the new nodes must be attributes as well. |
replace node <e a=""/>/@a with <a/> |
XUTY0012 |
Only elements, attributes, and processing instructions can be renamed. |
rename node text { 1 } as <x/> |
XUTY0013 |
The expression of a copy clause must return a single node. |
copy $c := (<a/>, <b/>) modify () return $c |
XUTY0022 |
An attribute must not be inserted into a document node. |
insert node <e a=""/>/@a into document { 'a' } |
Additional, module-specific error codes are listed in the descriptions of the query modules.