Difference between revisions of "XQuery Errors"

From BaseX Documentation
Jump to navigation Jump to search
Line 16: Line 16:
 
|- valign="top" scope="row"
 
|- valign="top" scope="row"
 
|<code>XPST0003</code>
 
|<code>XPST0003</code>
|An error occurred while ''parsing'' the query string (i.e., before the query could be compiled and executed).
+
|An error occurred while ''parsing'' the query string (i.e., before the query could be compiled and executed). This error is the most common one, and may be accompanied by a variety of different error messages.  
|<code>1+</code>
+
|<code>1+<hr/>for i in //* return $i</code>
 
|- valign="top" scope="row"
 
|- valign="top" scope="row"
 
|<code>XPST0005</code>
 
|<code>XPST0005</code>
Line 27: Line 27:
 
|<code>$a---<hr/>element(*, x)</code>
 
|<code>$a---<hr/>element(*, x)</code>
 
|- valign="top" scope="row"
 
|- valign="top" scope="row"
|<code>XPST0017<br/>&nbsp;</code>
+
|<code>XPST0017</code>
 
| • The specified function is unknown, or<br />• it uses the wrong number of arguments.
 
| • The specified function is unknown, or<br />• it uses the wrong number of arguments.
 
|<code>fn:unknown()<hr/>fn:count(1,2,3)</code>
 
|<code>fn:unknown()<hr/>fn:count(1,2,3)</code>
 
|- valign="top" scope="row"
 
|- valign="top" scope="row"
|<code>XPST0051<br/>&nbsp;</code>
+
|<code>XPST0051</code>
| An unknown QName is used in a ''sequence type'' (e.g. target type of the <code>cast</code> expression).
+
| An unknown QName is used in a ''sequence type'' (e.g. in the target type of the <code>cast</code> expression).
 
|<code>1 instance of x<hr/>"test"&nbsp;cast&nbsp;as&nbsp;xs:itr</code>
 
|<code>1 instance of x<hr/>"test"&nbsp;cast&nbsp;as&nbsp;xs:itr</code>
 
|- valign="top" scope="row"
 
|- valign="top" scope="row"
|<code>XPST0080<br/>&nbsp;</code>
+
|<code>XPST0080</code>
 
| <code>xs:NOTATION</code> or <code>xs:anyAtomicType</code> is used as target type of <code>cast</code> or <code>castable</code>.
 
| <code>xs:NOTATION</code> or <code>xs:anyAtomicType</code> is used as target type of <code>cast</code> or <code>castable</code>.
 
|<code>1 castable as xs:NOTATION</code>
 
|<code>1 castable as xs:NOTATION</code>
 
|- valign="top" scope="row"
 
|- valign="top" scope="row"
|<code>XPST0081<br/>&nbsp;</code>
+
|<code>XPST0081</code>
 
| • A QName uses a prefix that has not been bound to any namespace, or<br />• A pragma or option declaration has not been prefixed.
 
| • A QName uses a prefix that has not been bound to any namespace, or<br />• A pragma or option declaration has not been prefixed.
 
|<code>unknown:x<hr/>(# pragma #) { 1 }</code>
 
|<code>unknown:x<hr/>(# pragma #) { 1 }</code>
 +
|}
 +
 +
==XPTY: Type Errors==
 +
 +
{| class="wikitable" width="100%"
 +
! width="5%"|Code
 +
! width="70%"|Description
 +
! width="25%"|Examples
 +
|- valign="top" scope="row"
 +
|<code>XPTY0004</code>
 +
| This error is raised if an expression has the wrong type, or cannot be cast into the specified type. It may be raised both statically (during query compilation) or dynamically (at runtime).
 +
|<code>1 + "A"<hr/>fn:abs("a")<hr/>1 cast as xs:gYear</code>
 +
|- valign="top" scope="row"
 +
|<code>XPTY0018</code>
 +
| The result of the last step in a path expression contains both nodes and atomic values.
 +
|<code>doc('input.xml')/(*, 1)</code>
 +
|- valign="top" scope="row"
 +
|<code>XPTY0019</code>
 +
| The result of a step (other than the last step) in a path expression contains an atomic values.
 +
|<code>(1 to 10)/*</code>
 
|}
 
|}
  
 
In progress...
 
In progress...
 +
 +
{| class="wikitable" width="100%"
 +
! width="5%"|Code
 +
! width="70%"|Description
 +
! width="25%"|Examples
 +
|- valign="top" scope="row"
 +
|<code></code>
 +
|
 +
|<code></code>
 +
|}

Revision as of 12:12, 29 January 2011

This article is part of the Query Portal. It summarizes all error codes that may be thrown by the BaseX XQuery processor.

As the official specifications are written too formal to be easily understood, we tried our best to make this article comprehensible to everyone. The following tables include the error code that is raised by BaseX, a description, and examples of queries raising that error.

XPST: Static Errors

Code Description Examples
XPST0003 An error occurred while parsing the query string (i.e., before the query could be compiled and executed). This error is the most common one, and may be accompanied by a variety of different error messages. 1+
for i in //* return $i
XPST0005 An expression will never results, no matter what input will be processed. doc('input')/..
XPST0008 A variable or type name is used that has not been defined in the current scope. $a---
element(*, x)
XPST0017 • The specified function is unknown, or
• it uses the wrong number of arguments.
fn:unknown()
fn:count(1,2,3)
XPST0051 An unknown QName is used in a sequence type (e.g. in the target type of the cast expression). 1 instance of x
"test" cast as xs:itr
XPST0080 xs:NOTATION or xs:anyAtomicType is used as target type of cast or castable. 1 castable as xs:NOTATION
XPST0081 • A QName uses a prefix that has not been bound to any namespace, or
• A pragma or option declaration has not been prefixed.
unknown:x
(# pragma #) { 1 }

XPTY: Type Errors

Code Description Examples
XPTY0004 This error is raised if an expression has the wrong type, or cannot be cast into the specified type. It may be raised both statically (during query compilation) or dynamically (at runtime). 1 + "A"
fn:abs("a")
1 cast as xs:gYear
XPTY0018 The result of the last step in a path expression contains both nodes and atomic values. doc('input.xml')/(*, 1)
XPTY0019 The result of a step (other than the last step) in a path expression contains an atomic values. (1 to 10)/*

In progress...

Code Description Examples