This appendix lists all of the errors that may be raised during evaluation of a query, in alphabetical order by name. The XQuery spec does not define any programming API defining how queries are executed from, for example, C# or Java; but there is an expectation that in any such API, you will be able to test these error codes to find out what went wrong. In most cases, you can also expect that the error code will be accompanied with an error message that gives much more detailed information.
Error names, which are in the namespace http://www.w3.org/2005/xqt-errors
, are broken down into three parts:
A two-character prefix indicating the specification that defines the error, listed in Table C-1.
A two-character category that groups the error messages into their functional meaning. In the case of XP
and XQ
errors, the categories are ST
for static errors, DY
for dynamic errors, and TY
for type errors.
A four-digit number.
Error prefix | Meaning |
---|---|
FO | Functions and operators |
SE | Serialization |
XP | XPath |
XQ | XQuery |
Division by zero, which may be raised by the div
or mod
operator (if the operands are xs:integer
or xs:decimal
values) or by the idiv
operator (regardless of the types of the operands). Using the div
operator on values of type xs:float
or xs:double
will not raise this error; it will return INF
or -INF
.
Overflow or underflow occurred during a numeric operation. This occurs when the result of an arithmetic operation or cast is a value that is either larger or smaller (that is, closer to zero) than the values supported by the implementation.
An attempt was made to retrieve a member from a position that does not exist in an array. For example: [1, 2, 3](4)
will return this error because it is attempting to retrieve the fourth member in a three-member array. Likewise, array:get([1, 2, 3], 4)
will return the same error. This error may also be raised by array:subarray
, array:remove
, array:insert-before
, array:put
, array:head
, or array:tail
.
The function array:subarray
was called with a negative $length
argument.
A value that is not lexically valid for a particular type has been encountered. This can be raised in two situations:
When passing an invalid name to the QName
or resolve-QName
function; see the descriptions of these functions in Appendix A for details
When attempting to cast one of the special values NaN
, INF
, or -INF
to xs:decimal
or xs:integer
An attempt was made to cast to xs:integer
a value that is too large to be supported by the implementation.
When multiplying or dividing a duration value by a number, the number supplied was NaN
.
An unsupported collation was passed as an argument to a function. Functions that accept collations as arguments (named $collation
) are compare
, collation-key
, contains
, contains-token
, starts-with
, ends-with
, substring-before
, substring-after
, index-of
, distinct-values
, deep-equal
, sort
, array:sort
, max
, and min
.
This error might also be raised if no collation was passed to these functions, but the default collation is unsupported.
An unsupported normalization form was passed as the $normalizationForm
argument to the normalize-unicode
function.
When calling the doc
, collection
, or uri-collection
function, the processor could not retrieve a resource from the specified URI. This can happen in several cases:
The argument specifies a URI for which there is no available document or collection.
The argument is a relative URI and the static base URI is absent.
The argument is not provided or is the empty sequence and there is no default collection (in the case of collection
or uri-collection
).
The resource cannot be parsed successfully as XML (in the case of doc
or collection
).
When calling the doc
, collection
, or uri-collection
function multiple times with the same argument, stability of the results returned cannot be guaranteed.
A lexically invalid URI was passed to the collection
or uri-collection
function. A URI can be relative or absolute, but it must conform to the syntax required by xs:anyURI
.
An invalid URI was passed to the doc
or doc-available
function. A URI can be relative or absolute, but it must conform to the syntax required by xs:anyURI
.
The $arg
string passed as an argument to the parse-xml
function is not well-formed XML. This error could also be raised if DTD validation was attempted but $arg
was not valid according to the DTD. Calling parse-xml-fragment
can also raise this error if it is not a well-formed XML fragment. In this case, it is not required to have a single root element, but it must otherwise follow the rules for XML syntax.
The format-number
or format-integer
function has been called with an invalid picture string (the second argument).
Overflow or underflow has occurred during an operation involving a duration value. This occurs when the result of an arithmetic operation or cast is a value that is either larger or smaller than the values supported by the implementation.
An invalid time zone value was passed to one of the three adjust-xxx-to-timezone
functions. This may occur if the value of $timezone
is not between -PT14H
and PT14H
, inclusive, or if it does not have an even number of minutes (e.g., -PT2H30M30S
).
The format-date
or format-time
function has been called with a component in the picture string that is not relevant to that type. For example, the format-date
function was called and the minute component was referenced in the picture string.
parse-json
, json-doc
, json-to-xml
, or json-to-xml
was called with an argument that contains a JSON object with duplicate keys, when the chosen policy is to reject duplicates. Duplicates can be allowed by using a duplicates
entry in the $options
map passed to the function. This error is also raised when calling the map:merge
function with duplicates
set to reject
, and the merged map would have duplicate keys.
json-to-xml
was called with an $options
argument that contains an entry "validate": true()
, but the processor does not support schema validation or typed nodes. Consider using "validate": false()
instead.
parse-json
, json-doc
, json-to-xml
, map:merge
, or xml-to-json
was called with an $options
argument that contains an invalid value.
xml-to-json
was called with XML input that does not conform to the rules for the XML representation of JSON. See “Converting Between JSON and XML” for more information on the required XML structure.
xml-to-json
was called with XML input that contained an element with the attribute escaped="true"
or
escaped-key="true"
, but the content of that element is not a valid JSON escape sequence. In JSON, a backslash () must be followed by one of the characters "
, ,
/
, b
, f
, n
, r
, t
, or u
. If u
appears, it must be followed by four hexadecimal digits to indicate a Unicode codepoint.
When calling the resolve-uri
function, the $base
argument is not provided and the static base URI is absent. Either add a $base
argument or use a base URI declaration in the query prolog.
load-xquery-module
was called with a $module-uri
argument for which no module can be found.
load-xquery-module
encountered a static error when trying to load a library module. Ensure that the library module is syntactically correct and has no static type errors.
load-xquery-module
tried to dynamically load a module, but provided an invalid or missing value for the initial context item or for an external variable.
This error might occur for the initial context item if the library module uses a context item declaration to specify the type of the context item, that type does not allow the empty sequence, and the context-item
entry in $options
passed to the load-xquery-module
was omitted or equal to the empty sequence.
This error might also occur for the initial context item if the library module uses a context item declaration to specify the type of the context item, and the context-item
entry in $options
passed to the load-xquery-module
function is not of that type. No type conversion is applied automatically on the context item.
It might occur for a variable if the library module specifies the type by using the as
keyword in the variable declaration, that type does not allow the empty sequence, and the value specified in the variables
entry in $options
passed to the load-xquery-module
was omitted or equal to the empty sequence.
Similarly, it will occur if the library module specifies the type by using the as
keyword in the variable declaration, and the value specified in the variables
entry in $options
passed to the load-xquery-module
function is not of that type. No type conversion is applied automatically on the variable values.
An invalid value was passed to a type constructor or a cast expression. It might be invalid because it is too large or too small, or because it does not have the correct lexical form or it does not follow the validity rules for the target datatype. This can happen in several situations:
When passing an invalid value to a type constructor, for example, xs:integer("abc")
When passing an invalid value to a cast expression, for example "2015-13-32" cast as xs:date
When passing an untyped value to one of the sum
, min
, max
, or avg
functions and that value cannot be cast to xs:double
When calling the resolve-uri
function, either the $relative
or $base
argument is not a syntactically valid URI.
A sequence of more than one item was passed to the zero-or-one
function; the argument must be either the empty sequence or a single item.
An empty sequence was passed to the one-or-more
function; the argument must be a sequence of one or more items.
An empty sequence or a sequence of more than one item was passed to the exactly-one
function; the argument must be a single item.
An invalid argument was used in a function or operation. This can happen in three situations:
You passed an argument sequence to one of the sum
or avg
functions that contains values that are not numbers or durations, or that are a mixture of numbers and durations.
You passed an argument sequence to one of the min
or max
functions that contains values that do not support the <
and >
operators, or that have a mixture of different types.
You attempted to find the effective boolean value of a sequence for which it cannot be determined. Effective boolean value cannot be determined for a multi-item sequence whose first item is an atomic value, an individual atomic value whose type is not numeric, untyped, xs:boolean
, or xs:string
, or a function item (including a map or array).
Effective boolean value is calculated when calling the boolean
and not
functions, but also in many different operations that do not involve functions, such as conditional (if
-then
-else
) expressions, where
clauses of FLWORs, and predicates of path expressions. Effective boolean value is discussed in more detail in “Effective Boolean Value”.
One common cause of this is using an expression like:
doc("catalog.xml")//product[1 to 3]
Although this expression is allowed by some XQuery processors, it is technically not valid because it attempts to find the effective boolean value of a sequence of integers. Instead, you should use:
doc("catalog.xml")//product[position() = 1 to 3]
The two arguments passed to the dateTime
function have different time zones. They should have the same time zone or none at all.
When calling the resolve-uri
function, the $relative
argument cannot be resolved relative to the $base
argument.
The $pattern
argument passed to the matches
, replace
, tokenize
, or analyze-string
function is not a valid regular expression. This might occur if, for example, there are mismatched parentheses or unescaped special characters. Note that the regular expression language supported omits many constructs that may be familiar, for example, to Perl programmers.
The $pattern
argument passed to the replace
, tokenize
, or analyze-string
function matches a zero-length string—for example, q?
.
The $replacement
argument passed to the replace
function is invalid. This can happen in two cases:
An attempt was made to find the typed value of a node that has no typed value. This occurs, for example, when you pass to the data
function an element node whose type (after schema validation) has element-only content. It may also be raised during atomization, which extracts the typed value of a node, sorting, or finding distinct values.
An attempt was made to find the typed value of a function item. This occurs when you pass a function item (other than an array) to the data
function. It may also be raised during atomization, which extracts the typed value of a node.
The string
function was called with a function item as the argument.
The deep-equal
function was called with a function item (other than a map or array) as the argument.
The unparsed-text
or unparsed-text-lines
function was called with an invalid $href
(first argument). This can occur in several cases:
The processor cannot find a resource at that URI.
The URI contains a fragment identifier (#
).
The processor cannot resolve the URI (to make it absolute) because it is relative and no static base URI is available.
The resource retrieved by the unparsed-text
or unparsed-text-lines
function could not be decoded. This can occur in several cases:
$encoding
does not represent a valid encoding name.
The processor does not support the encoding specified in $encoding
.
The resource retrieved cannot be decoded using the specified encoding (because it is not validly encoded).
The resource contains characters that are not allowed by XML.
The unparsed-text
or unparsed-text-lines
function was called with no $encoding
argument, the retrieved resource was not encoded in UTF-8, and the processor cannot otherwise infer the encoding.
The transform
function was called with invalid parameters, for example two mutually-exclusive parameters were supplied. This error is returned when a more specific XSLT error code is not available.
The transform
function attempted to transform using an XSLT that failed with a static or dynamic error. This error is returned when a more specific XSLT error code is not available.
The transform
function was called, but XSLT transformation (or a specific transformation option) has been disabled for security or other reasons.
The output method is not json
or adaptive
, and the results of a query contain either function items (including maps or arrays), or attribute or namespace nodes that are not associated with any elements. This result cannot be serialized. To serialize maps or arrays, use the json
output method.
The result has no single element node and consists of multiple text nodes or element nodes. In this case, it is considered to be an XML entity that may be included in another XML document but cannot stand on its own. Therefore, it is an error to specify the doctype-system
parameter, or to specify the standalone
parameter with a value other than omit
.
If the omit-xml-declaration
parameter has the value yes
, it is an error if either:
The standalone
attribute has a value other than omit
.
The version
parameter has a value other than 1.0
and the doctype-system
parameter is specified.
Undeclaring namespaces is not allowed in Namespaces 1.0. Therefore, if the output method is xml
or xhtml
, it is an error if the value of the undeclare-prefixes
parameter is yes
and the value of the version
parameter is 1.0
.
A serialization parameter has an incorrect value. Generally, a more specific error message will be provided.
When the serialization parameters were supplied as an XML instance, evaluating an expression to extract a serialization parameter value encountered an error.
When the serialization parameters were supplied as an XML instance, there was a duplicate output:character-map
element with the same value for the character
attribute. The characters supplied in a character map must be unique.
The result includes an NCName that contains a character not permitted by the version specified by the version
parameter. The characters allowed in names in XML 1.1 (and Namespaces 1.1) are different from those allowed in XML 1.0 (and Namespaces 1.0).
The result contains a character not permitted by the version specified by the version
parameter. The characters allowed in XML 1.1 (and Namespaces 1.1) are different from those allowed in XML 1.0 (and Namespaces 1.0).
The result contains a character that cannot be represented in the encoding being used by the serializer, and it cannot be replaced by a character reference (because, for example, it appears in a name, where character references are not allowed by XML syntax).
The value of the normalization-form
parameter is set to fully-normalized
, but some text in the result (for example, names or element content) begins with a combining character.
The output method is set to HTML, but the result contains one of the control characters #x7F
-#x9F
. These characters are allowed in XML, but not HTML. The most likely cause of this error is that the encoding of your input document is incorrectly declared. Microsoft Windows uses codes in this range to represent special characters such as an em dash or a euro currency symbol. If your source XML document uses these Microsoft codes, it must declare this by specifying encoding="cp1252"
in the XML declaration. Otherwise they will be taken to represent the Unicode control characters at these positions, which are not allowed in HTML.
The output method is set to HTML, but the result contains a processing instruction that has the character >
in its content. This is allowed in XML, but not HTML, because HTML terminates processing instructions with >
.
When serializing JSON, the output contained a numeric value such as INF
or NaN
that is not supported in the JSON syntax.
When serializing JSON, the output contained an item for which there are no rules for serialization, for example, a function item that is not a map or array.
When serializing JSON, a map contained two keys that are duplicates when converted to strings. This could arise if the keys have different typed values in the XQuery map, for example, the string 1
and the integer 1
. This error is not raised if allow-duplicate-names
is set to yes
.
The value of the normalization-form
parameter is not supported by the serializer. All serializers support, at a minimum, NFC
and none
.
One of the following is true:
The output method is set to html
, and the value of the version
or html-version
parameter is a version of HTML not supported by the serializer.
The output method is set to xml
, and the value of the version
parameter is a version of XML not supported by the serializer.
An expression relies on some part of the dynamic context that is absent. Most often, this is a path expression or function call that relies on the current context item, but the context item is absent. This may be because you used a relative path, when no outer expression set the context for the path. For example, if your entire query is:
//catalog/product
and the context is not set outside the query by the processor (or by a context item declaration), this error will be raised because the processor will not know what the path is relative to. Instead, start your path with a function call or variable that sets the context, as in:
doc("catalog.xml")//catalog/product
This error may occur when you use paths in a FLWOR expression and forget to start each path with a step that sets the context. For example:
for $prod in doc("catalog.xml")//product wherenumber
> 500 returnnumber
In this case, the processor does not automatically know to evaluate number
relative to the $prod
variable; it has to be explicitly specified, as in:
for $prod in doc("catalog.xml")//product where$prod/
number > 500 return$prod/
number
This error might also occur if you forget to put the dollar sign in front of the variable name, causing the processor to interpret it as a path. For example:
for $prod in doc("catalog.xml")//product
return prod
With the dollar sign omitted from the beginning of prod
in the return
clause, the processor will interpret it as a relative path to a child element named prod
.
A number of built-in function calls will raise this error as well if they require the current context item and it is absent. There are a number of built-in functions that operate on the current context item by default if no appropriate argument is passed. These functions are base-uri
, data
, element-with-id
, document-uri
, generate-id
, has-children
, id
, idref
, lang
, last
, local-name
, name
, namespace-uri
, nilled
, node-name
, normalize-space
, number
, path
, position
, root
, string
, and string-length
. For example, the function call name()
(with no arguments) uses the current context item.
Finally, this error can be raised in another situation: if a global variable is defined as external, but it was not bound to a value outside the scope of the query, any references to that variable will raise this error.
This error is raised in two separate cases:
When a path expression starts with /
or //
and the current context item is not part of a complete XML document (with a document node at its root)
When using a treat expression, if the operand of the expression does not match the sequence type specified
In the first case, you can fix the expression by starting with a call to the root
function, which does not require the root to be a document node. For example, you could use root(.)/descendant-or-self::product
instead of just //product
.
This is a general-purpose error that is raised if an expression relies on a component of the static context that has not been assigned a value. One example is attempting to resolve a relative URI when there is no static base URI available. In most cases, a more specific error code and message are provided.
A syntax or parsing error has occurred. This may happen, for example, if there are mismatched parentheses or invalid keywords.
If static typing is in effect, this error will be raised if any expression in your query (other than ()
and data( () )
) will always return the empty sequence. Often, this is the result of a misspelling or an invalid path. For more information, see Chapter 15.
An undefined name was encountered. This could be a variable name, an element name, an attribute name, or a type name. It may be that you misspelled the name or referred to it in the wrong namespace.
If it is a variable name, that variable may be referenced outside the scope for which it is bound. One reason for this error is misplaced or missing parentheses. A common case is when you attempt to return two items by using a FLWOR expression, as in:
for $prod in doc("catalog.xml")//product return $prod/number, $prod/name
In this case, the second reference to $prod
on the last line is out of scope, because only a single expression is included in the return
clause. The rest of the line (, $prod/name
) is considered to be a separate expression that appears after the FLWOR expression. This example can be remedied by placing parentheses around the return
clause, as in:
for $prod in doc("catalog.xml")//product return ($prod/number, $prod/name)
This error is also raised if the body of a user-defined function relies on the context item, which is absent inside a function. Instead, the relevant node must be passed to the function as an argument, as described in “Functions and Context”.
Finally, this error may be raised if an element, attribute, or type name appears in a sequence type but is not part of the in-scope schema definitions. For example, the sequence type:
element(prod, ProductType)
will raise an error if the in-scope schema definitions do not include a type definition for ProductType
.
You have attempted to call a function that is not declared. This may be because:
You are using the wrong function name.
You are using the wrong namespace prefix for the function name.
You didn’t import the module in which the function is declared.
You are passing an incorrect number of arguments to a function. When calling a function, there must be an argument for every parameter specified in the function signature.
You are using an implementation that doesn’t support the Higher Order Function Feature, but you are attempting to call a higher-order function such as for-each
or filter
.
A sequence type refers to a type (other than within the element()
or attribute()
constructs) that is not an atomic or union type in the in-scope schema definitions. Sequence types most commonly appear in function signatures, as in:
declare function local:xyz ($arg1 as xs:string*, $arg2 as prod:SizeType?) { };
where xs:string*
and prod:SizeType?
are sequence types that described the types of the arguments. This error might be raised if you:
Misspelled or incorrectly capitalized the name of a built-in type, e.g., xs:String
or xs:srting
.
Used a user-defined type name that is not declared in an in-scope schema—for example, if prod:SizeType
is not in an imported schema.
Used a user-defined type name that is a complex or list type, not an atomic type—for example, if prod:SizeType
allows children. Using the sequence type element(*, prod:SizeType)
would be allowed.
A cast or castable expression refers to one of the types xs:NOTATION
, xs:anySimpleType
, or xs:anyAtomicType
. It is not permitted to cast values to these types.
A qualified name (QName) in your query has a prefix that is not declared, or that is referenced outside the scope in which it is declared. Anything that appears before a colon in a name is considered to be a prefix, and it must be declared, either in the prolog or in an element constructor. This error is raised for path expressions, element and attribute constructors, element and attribute sequence types, pragma names, and option names. For example, the path expression:
doc("cat_ns.xml")//prod:
product
raises an error if the prod
prefix is not declared either in the query prolog or in a surrounding direct element constructor.
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 by 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 non-literal 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/*
.
Using an as
keyword and then supplying a value that does not conform to that type. For example, let $foo as xs:integer := "abc"
.
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 item being a node rather than an atomic value. A number of built-in functions will operate on the current context item by default if no appropriate argument is passed. These functions are base-uri
, document-uri
, element-with-id
, generate-id
, has-children
, id
, idref
, lang
, local-name
, node-name
, name
, namespace-uri
, nilled
, path
, and root
.
The last step in a path expression is returning both nodes and non-nodes, which is not permitted. It must return either all nodes or all non-nodes (i.e., atomic values or function items). The reason for this rule is that “/” causes sorting into document order if the step delivers nodes, but not if it delivers atomic values. Therefore, it doesn’t make sense to return a mixture. This can generally be remedied by changing the last slash to a simple map operator (!
).
A step in a path expression (that is not the last step) is returning non-nodes (i.e., atomic values or function items), which is not permitted. For example, the following expression:
doc("catalog.xml")//name/substring(., 1, 3)/replace(., 'A', 'a')
is not permitted because the second to last step, substring(., 1, 3)
, is returning atomic values. The offending slash can be replaced with the simple map operator (!
), which does allow non-nodes, for example:
doc("catalog.xml")//name/substring(., 1, 3) ! replace(., 'A', 'a')
You have specified a relative path expression, but the current context item is not a node. This might occur, for example, if you use a relative path in a predicate where the current context item is an atomic value, as in:
doc("catalog.xml")//product/substring(name, 1, 3)[@dept = 'ACC']
The path expression @dept
is being evaluated relative to the substring of the name (an atomic value) rather than the product
element. In this case, the predicate can be moved to the previous step, as in:
doc("catalog.xml")//product[@dept = 'ACC']/substring(name, 1, 3)
You are trying to construct a processing instruction that contains the string ?>
, which is not allowed.
An element was determined to be invalid when a validate
expression was applied to it.
When constructing a processing instruction, its target (name) is a value that cannot be cast to xs:NCName
. Processing instruction targets must be castable to xs:NCName
, whose valid values are included in “xs:NCName
”.
The name specified for an attribute constructor has one of the following problems that indicate you are trying to create a namespace declaration by using an attribute constructor, which is not allowed:
Its namespace prefix is xmlns
.
Its name is xmlns
(with no prefix).
Its namespace URI is http://www.w3.org/2000/xmlns/
.
Instead, you should declare the namespace in the query prolog or in an outer direct element constructor.
This error is also raised due to improper use of the xml
prefix or the XML namespace. This includes attempting to use a name where the prefix xml
is bound to a namespace other than http://www.w3.org/XML/1998/namespace
, or where some prefix other than xml
is bound to that namespace. The xml
prefix is predeclared, so it does not need an associated namespace declaration.
Function and variable declarations with circular definitions were encountered; these are not allowed. For example, an initializing expression in a variable declaration cannot call a function whose body itself references the variable being initialized. Likewise, two variable declarations cannot depend on each other (directly or indirectly).
If the expression that appears in curly braces after the validate
keyword is a document node, that document node must have exactly one child element node. It may also have as children zero, one, or many comment nodes and processing-instruction nodes, in any order.
When constructing a processing instruction, its target (name) cannot be the letters XML (in any combination of uppercase or lowercase letters). If you are attempting to add an XML declaration to your results, this is controlled by setting the omit-xml-declaration
serialization parameter to no
rather than being constructed in your query.
A computed comment constructor results in a comment that contains two consecutive hyphens (--
) or ends in a hyphen, which is not allowed.
The name expression in a computed constructor cannot be cast to xs:QName
, for example, because it is an invalid XML name or an undeclared prefix is used.
When evaluating a validate
expression whose validation mode is strict
, the processor could not find a global element declaration in the in-scope schema definitions or anywhere else. This may be because the schema was not imported or because the element was not globally declared.
You have attempted to construct an attribute named xml:id
with an invalid value. ID values must start with a letter or underscore and can only contain letters, digits, underscores, hyphens, and periods.
You have attempted to construct an attribute named xml:space
with a value other than preserve
or default
. Those are the only two values allowed.
The name specified for an element constructor has one of the following problems:
Its namespace prefix is xmlns
.
Its name is xmlns
(with no prefix).
Its namespace URI is http://www.w3.org/2000/xmlns/
.
This error is also raised due to improper use of the xml
prefix or the XML namespace. This includes attempting to use a name where the prefix xml
is bound to a namespace other than http://www.w3.org/XML/1998/namespace
, or where some prefix other than xml
is bound to that namespace. The xml
prefix is predeclared, so it does not need an associated namespace declaration.
This error is raised when a computed namespace constructor misuses the xmlns
prefix or the http://www.w3.org/2000/xmlns/
namespace. It is not valid to attempt to bind xmlns
to any namespace, or to bind any prefix to http://www.w3.org/2000/xmlns/
. For example:
namespace xmlns { "http://datypic.com/prod" }
Although this might look like it is declaring a default namespace, it is actually attempting to bind that namespace to the prefix xmlns
. To make that the default namespace, the correct syntax is:
namespace {""} { "http://datypic.com/prod" }
It is also invalid to use a computed namespace constructor to declare a zero-length namespace name, as in:
namespace prod { "" }
Another reason for this error is improper use of the xml
prefix or the XML namespace. This includes attempting to bind the prefix xml
to a namespace other than http://www.w3.org/XML/1998/namespace
, and attempting to bind some prefix other than xml
to that namespace. The xml
prefix is predeclared, so it does not need an associated namespace declaration.
In an element constructor, the same prefix cannot be bound to different namespaces in the same scope. This might arise when you’re using computed namespace constructors, for example:
element root { namespace prod {"http://datypic.com/prod1"}, namespace prod {"http://datypic.com/prod2"} }
This would create two conflicting namespace declarations for the prefix prod
, in the same scope (the root
element). This can be remedied by using different prefixes for different namespace names.
One or more of the imported schemas contain definitions that are incomplete or invalid, or contain duplicate declarations.
The processor has recognized a pragma but determined that it contains invalid content as defined by the implementation. Consult the documentation for your implementation to determine what values are allowed for the pragma.
The processor encountered a module declaration or module import, but it does not support the optional Module Feature.
The namespace name used in a namespace declaration attribute (in a direct element constructor) uses an enclosed expression. It must be a literal value; it cannot be dynamically evaluated.
The processor has encountered a version of XQuery that it does not support in the version declaration. If, for example, you have specified version 3.1 as shown below, you should ensure that your processor supports 3.1. Otherwise, you may need to use XQuery 1.0 or 3.0.
xquery version "3.1" encoding "UTF-8";
The prolog contains more than one base URI declaration, which is not allowed. Base URI declarations start with declare base-uri
.
The prolog contains more than one declaration for the same namespace prefix, which is not allowed. Namespaces can be declared using standard namespace declarations, module declarations, module imports, and schema imports. If a namespace is declared in a module import or declaration, it does not need to be separately declared in a namespace declaration.
You may have attempted to declare two functions with the same qualified name and the same number of parameters (arity). The conflicting function signature may appear in a separate module that has been imported.
This error is also raised if you declare a function with only one parameter, and it has the same qualified name as a type that is in scope. For example, if you import a schema that contains a type named order
in the namespace http://datypic.com/prod
, you cannot also declare a function, with one parameter, named order
in the same namespace. This is because each type has a constructor function that shares its name, and it would be impossible to distinguish between the type constructor and the user-defined function.
You have attempted to import two schema documents that have duplicate names for globally declared components such as elements, attributes, and types.
This error is raised in two situations:
The prolog contains more than one default collation declaration. Default collation declarations start with declare default collation
.
The prolog refers to a default collation that is not supported by the implementation.
A function signature (or an inline function expression) contains more than one parameter with the same name; the parameter names within a particular function signature must be unique.
A direct element constructor contains two attributes with the same qualified name. As with normal XML syntax, the attributes of an element must have unique names.
You have attempted to declare your own function, or use an annotation, in one of the following namespaces:
http://www.w3.org/XML/1998/namespace
(xml
)
http://www.w3.org/2001/XMLSchema
(xs
)
http://www.w3.org/2001/XMLSchema-instance
(xsi
)
http://www.w3.org/2005/xpath-functions
(fn
)
http://www.w3.org/2005/xpath-functions/math
(math
)
http://www.w3.org/2005/xpath-functions/array
(array
)
http://www.w3.org/2005/xpath-functions/map
(map
)
http://www.w3.org/2012/xquery
(used in annotations)
This is not permitted. Instead, use the prefix local
, or declare a new namespace and prefix your function name with the appropriate prefix for that namespace.
URI values (including namespace names) used in queries should be syntactically valid URIs, which can be URLs or URNs. A processor may optionally raise this error if a URI is not syntactically valid according to the rules, which are described in RFC 3986, Uniform Resource Identifiers (URI): Generic Syntax.
This error may be raised by any of the following URIs used in a query:
The namespace name in a namespace declaration (either in the prolog or in a direct element constructor)
The module location or namespace name in a module import
The target namespace in a module declaration
The schema location or namespace name in a schema import
The collation URI in a default collation declaration or in an order by
or group by
clause
The base URI in a base URI declaration
Two separate module imports specify the same target namespace, which is not permitted. Instead, specify multiple module locations for the same target namespace in a single import, using commas to separate them. For example, change this:
import module "http://datypic.com/strings" at "strings.xqm"; import module "http://datypic.com/strings" at "strings2.xqm";
to this:
import module "http://datypic.com/strings" at "strings.xqm", "strings2.xqm";
One of the functions and variables declared in a library module is not in the target namespace. Every function and global variable declared in a library module must be qualified with the target namespace of that module. Generally, this means that they use the prefix that is bound to the target namespace in the module declaration. For example, the following is not permitted because the variable maxStringLength
is not in the target namespace:
module namespace strings = "http://datypic.com/strings";
declare variable $maxStringLength
:= 32;
declare function strings:trim($arg as xs:string?) as xs:string? {
substring($arg, 1, 10)
};
Instead, it must be prefixed with strings
to put it in the target namespace http://datypic.com/strings
.
Duplicate prolog variable declarations were found. The qualified names of all variables declared in prologs must be unique across all modules that are used together. This includes the main module and any imported library modules.
A cast or castable expression refers to a type that is not defined in the in-scope schema types, or that is not a simple type. If you are using types from a schema definition, make sure that schema document is being imported, and that the type in question is a simple type.
The prolog contains more than one copy-namespaces declaration, which is not permitted. Copy-namespaces declarations start with declare copy-namespaces
.
A schema import that specifies a prefix has a zero-length namespace name, which is not allowed. For example, the following schema import is invalid:
import schema namespace prod = "" at "prod_nons.xsd";
You can, however, import a schema with no target namespace if you make “no namespace” the default, as in:
import schema default element namespace "" at "prod_nons.xsd";
Two separate schema imports specify the same target namespace, which is not permitted. For example:
import schema "http://datypic.com/prod" at "http://datypic.com/input/prod.xsd"; import schema "http://datypic.com/prod" at "http://datypic.com/input/prod2.xsd";
Instead, you can specify multiple schema locations for the same target namespace in a single import, using commas to separate them. For example:
import schema "http://datypic.com/prod" at "http://datypic.com/input/prod.xsd", "http://datypic.com/input/prod2.xsd";
However, the semantics of this are somewhat implementation-dependent because schema locations are just hints, and the processor could choose to ignore the second location. A safer option is to create a schema document that includes the two other schema documents, and import that.
The processor cannot find a valid library module for the target namespace specified in a module import, or a valid schema for the target namespace specified in a schema import. This might occur, for example, because it could not find a module or schema at all, or it found a module or schema with a different target namespace than the one specified in the import. Different processors have different strategies for locating modules—for example, some might allow independent compilation of library modules.
A function is declared with a name that is not in a namespace. All function names must be in a namespace. Note that default element namespace declarations do not apply to function names.
To remedy this, revise your function name to include a namespace prefix. In a main module, you can use any prefix that is declared in the prolog or the predeclared prefix local
. In a library module, you must use the prefix that is bound to the target namespace of the module.
The prolog cannot contain more than one ordering mode declaration. Ordering mode declarations start with declare ordering
.
The prolog contains more than one default element namespace declaration or more than one default function namespace declaration, which is not allowed. Default element namespace declarations start with declare default element namespace
, and default function namespace declarations start with declare default function namespace
.
The prolog contains more than one construction declaration, which is not allowed. Construction declarations start with declare construction
.
The prolog contains more than one boundary-space declaration, which is not allowed. Boundary-space declarations start with declare boundary-space
.
The prolog contains more than one empty order declaration, which is not allowed. Empty order declarations start with declare default order
.
This error is raised if a namespace declaration attempts to:
Bind a URI to the prefix xmlns
. This built-in prefix has special meaning in XML and cannot be used in a declaration.
Bind the http://www.w3.org/2000/xmlns/
namespace to any prefix.
Bind the xml
prefix to a namespace other than http://www.w3.org/XML/1998/namespace
.
Bind the http://www.w3.org/XML/1998/namespace
namespace to a prefix other than xml
.
This error could be raised by a standard namespace declaration (either in a prolog or direct constructor), or by the namespace binding that occurs as part of a module declaration, module import, or schema import.
More than one namespace declaration attribute on a single element constructor uses the same prefix, which is not allowed. For example, the following raises an error because the prod
prefix is bound twice on the same element:
<product xmlns:prod
="http://datypic.com/prod" xmlns:prod
="http://datypic.com/prd">...</product>
The processor encountered a validate
expression, but it does not support the Schema Aware Feature. Not all implementations support the validate
expression; it is an optional feature.
The collation specified in an order by
or group by
clause is not supported by the implementation.
An extension expression has no expression between its curly braces, and the processor does not recognize the pragma(s).
Namespace declaration attributes that map prefixes to namespace names that are zero-length strings, such as xmlns:cat=""
, are only allowed if the implementation supports Namespaces 1.1.
The version declaration contains an invalid encoding value. Example valid values for the encoding include UTF-8
, UTF-16
, ISO-8859-1
, and US-ASCII
. Encoding names always start with a letter and may contain letters, digits, periods, underscores, and hyphens.
The target namespace specified in a module import or a module declaration is a zero-length string, which is not allowed.
A variable bound in a for
or window
clause has the same name as the positional variable used in that same clause. This is not permitted. For example, change:
for $x at $x in (doc("catalog.xml")//product) return $x
to:
for $x at $y
in (doc("catalog.xml")//product)
return $x
A character reference (e.g.,  
) refers to a character that is not a valid character in the version of XML that is in use.
The name of a variable used in a group by
clause (directly after the keywords group by
) must be previously bound in a prior clause of the FLWOR expression.
A decimal format declaration supplies an invalid value for a particular property. For example, zero-digit
has a non-digit value, or pattern-separator
has more than one character.
A decimal format declaration attempts to use the same character for multiple properties representing characters used in a picture string. These properties are decimal-separator
, grouping-separator
, percent
, per-mille
, zero-digit
, digit
, exponent-separator
, and pattern-separator
. For example, if you attempted to specify the comma character for both the decimal-separator
and the grouping-separator
properties, this error is raised.
A module contains more than one context item declaration, which is not allowed. Context item declarations start with declare context item
.
A duplicate variable name was used in a window
clause. All the variables in a window
clause must have distinct names.
A validate
expression has a type
clause that uses a type name that is not among the in-scope schema definitions. This may be because the schema was not imported.
A function declaration contains both a %private
and a %public
annotation, more than one %private
annotation, or more than one %public
annotation. Only one %private
or one %public
annotation is allowed.
An output declaration appears in a library module, which is not allowed. Output declarations can only appear in main modules.
An output declaration that uses the namespace http://www.w3.org/2010/xslt-xquery-serialization
refers to an invalid name, i.e., one that is not described in “Serialization Parameters”. One exception is that the value use-character-maps
is not allowed in an output declaration; it can only be set in a separate document. The value parameter-document
is allowed in addition to the values in the table, to indicate the name of a document containing the serialization parameters.
The query contains output declarations that specify the same serialization parameter more than once. Only one value is allowed per parameter.
The query contains more than one decimal format declaration with the same name, or more than one default decimal format declaration. The decimal formats must have unique names within a module.
A context item declaration in a library module must be external, and it cannot contain a :=
operator to specify a default value.
A decimal format declaration is specifying the same property more than once, which is not allowed.
An output declaration is using parameter-document
to refer to an external document, but this document raises a serialization error.
A variable declaration contains both a %private
and a %public
annotation, more than one %private
annotation, or more than one %public
annotation. Only one %private
or one %public
annotation is allowed.
In a direct element constructor, the name used in the end tag must exactly match the name used in the corresponding start tag. This error will be raised even if the two tags represent the same qualified names but they have different prefixes (or one has no prefix).
An output declaration is using parameter-document
to refer to an external document, but the processor is unable to parse this document, possibly because it is not well-formed XML.
An inline function expression contains a %private
or a %public
annotation, which is not allowed. Inline function expressions can have other annotations, but not these two.
An implementation encountered an expression that it does not support because it does not implement the Higher-Order Function Feature, namely a function test, dynamic function call, named function reference, inline function expression, or partial function application.
In element constructor content, enclosed expressions that evaluate to attributes must appear first in the element constructor content, before any other kinds of nodes. For example, the following query is not valid because the second enclosed expression, {$prod/@dept}
, appears after an enclosed expression that returns element nodes.
for $prod in doc("catalog.xml")/catalog/product
return <li>{$prod/number}{$prod/@dept}
</li>
If the intent was to put the value of the dept
attribute inside the li
element, consider using the data
function to extract the value of the attribute.
The expression that appears in curly braces after the validate
keyword must be a single document or element node. If it evaluates to a sequence of multiple items, another kind of node, or an atomic value, this error is raised.
If you set the copy-namespaces mode to no-preserve
, and the construction mode to preserve
, there may be a conflict if your element content (or attribute values) contains namespace-sensitive values, such as qualified names. Namespaces used in content (as opposed to in element/attribute names) are not considered to be “used.”
For example, suppose your input document (qnames.xml) looks like this:
<listOfQualifiedNames xmlns:prod="http://datypic.com/prod"> <qName>prod:xyz</qName> <qName>prod:abc</qName> </listOfQualifiedNames>
Suppose also that this document has been validated with a schema, and the qName
elements are annotated with the type xs:QName
. You might query the document with:
<myNewList>{doc("qnames.xml")//qName}</myNewList>
intending to return a new element that contains the two qName
elements. If construction mode is preserve
, the qName
elements will still have the type xs:QName
. But if the copy-namespaces mode is no-preserve
, the http://datypic.com/prod
namespace will not be preserved, because it is used only in content, not in element or attribute names. Therefore, the qName
elements’ content will have undefined prefixes and this error will be raised.