Difference between revisions of "RESTXQ Module"

From BaseX Documentation
Jump to navigation Jump to search
 
(20 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
=Conventions=
 
=Conventions=
  
* This module is included in the complete distributions (zip, exe, war) of BaseX.
+
* The module will be available if the {{Code|basex-api}} library is found in the classpath. This is the case if you use one of the complete distributions of BaseX (zip, exe, war).
* All functions are assigned to the {{Code|http://exquery.org/ns/restxq}} namespace, which must be dynamically imported:
+
* All functions are assigned to the <code><nowiki>http://exquery.org/ns/restxq</nowiki></code> namespace, which is statically bound to the {{Code|rest}} prefix.
<pre class="brush:xquery">
+
* The <code><nowiki>http://wadl.dev.java.net/2009/02</nowiki></code> namespace is bound to the {{Code|wadl}} prefix.
import module namespace rest = "http://exquery.org/ns/restxq";
+
* If any of the functions is called outside the servlet context, <code>[[XQuery Errors#BaseX Errors|basex:http]]</code> is raised.
...
 
</pre>
 
* In this documentation, the namespace is bound to the {{Code|rest}} prefix, and the {{Code|http://wadl.dev.java.net/2009/02}} namespace is bound to the {{Code|wadl}} prefix.
 
* If any of the functions is called outside the servlet context, the error {{Error|BXSE0003|#Errors}} is raised.
 
  
 
=General Functions=
 
=General Functions=
  
 
==rest:base-uri==
 
==rest:base-uri==
 +
 
{| width='100%'
 
{| width='100%'
 
|-
 
|-
| width='90' | '''Signatures'''
+
| width='120' | '''Signatures'''
 
|{{Func|rest:base-uri||xs:anyURI}}
 
|{{Func|rest:base-uri||xs:anyURI}}
 
|-
 
|-
 
| '''Summary'''
 
| '''Summary'''
|This function returns the implementation defined base URI of the resource function.
+
|Returns the implementation-defined base URI of the resource function.
 
|}
 
|}
  
 
==rest:uri==
 
==rest:uri==
 +
 
{| width='100%'
 
{| width='100%'
 
|-
 
|-
| width='90' | '''Signatures'''
+
| width='120' | '''Signatures'''
 
|{{Func|rest:uri||xs:anyURI}}
 
|{{Func|rest:uri||xs:anyURI}}
 
|-
 
|-
 
| '''Summary'''
 
| '''Summary'''
|This function returns the complete URI that addresses the Resource Function. This is the result of [[#rest:base-uri|rest:base-uri]] appended with the path from the path annotation of the resource function.
+
|Returns the complete URI that addresses the Resource Function. This is the result of [[#rest:base-uri|rest:base-uri]] appended with the path from the path annotation of the resource function.
 
|}
 
|}
  
 
==rest:wadl==
 
==rest:wadl==
 +
 
{| width='100%'
 
{| width='100%'
 
|-
 
|-
| width='90' | '''Signatures'''
+
| width='120' | '''Signatures'''
 
|{{Func|rest:wadl||element(wadl:application)}}
 
|{{Func|rest:wadl||element(wadl:application)}}
 
|-
 
|-
 
| '''Summary'''
 
| '''Summary'''
|This (unofficial) function returns a [http://www.w3.org/Submission/wadl WADL description] of all available REST services.
+
|Returns a [https://www.w3.org/Submission/wadl WADL description] of all available REST services.
 +
|}
 +
 
 +
==rest:init==
 +
 
 +
{| width='100%'
 +
|-
 +
| width='120' | '''Signatures'''
 +
|{{Func|rest:init||empty-sequence()}}<br/>{{Func|rest:init|$update as xs:boolean|empty-sequence()}}
 +
|-
 +
| '''Summary'''
 +
|Initializes the RESTXQ module cache:
 +
* By default, the cache will be discarded, and all modules will be parsed and cached again.
 +
* If {{Code|$update}} is enabled, the background caching behavior is simulated (see {{Option|PARSERESTXQ}}): Only updated modules will be parsed.
 +
* This function should be called if new RESTXQ code is deployed at runtime.
 
|}
 
|}
  
 
=Changelog=
 
=Changelog=
 +
 +
; Version 9.4
 +
* Updated: [[#rest:init|rest:init]] argument added
 +
 +
;Version 8.6
 +
* Added: [[#rest:init|rest:init]]
  
 
This module was introduced with Version 7.7.
 
This module was introduced with Version 7.7.
 
[[Category:XQuery]]
 

Latest revision as of 18:50, 18 November 2020

This XQuery Module contains helper functions for the RESTXQ API, some of which are defined in the RESTXQ Draft.

Conventions[edit]

  • The module will be available if the basex-api library is found in the classpath. This is the case if you use one of the complete distributions of BaseX (zip, exe, war).
  • All functions are assigned to the http://exquery.org/ns/restxq namespace, which is statically bound to the rest prefix.
  • The http://wadl.dev.java.net/2009/02 namespace is bound to the wadl prefix.
  • If any of the functions is called outside the servlet context, basex:http is raised.

General Functions[edit]

rest:base-uri[edit]

Signatures rest:base-uri() as xs:anyURI
Summary Returns the implementation-defined base URI of the resource function.

rest:uri[edit]

Signatures rest:uri() as xs:anyURI
Summary Returns the complete URI that addresses the Resource Function. This is the result of rest:base-uri appended with the path from the path annotation of the resource function.

rest:wadl[edit]

Signatures rest:wadl() as element(wadl:application)
Summary Returns a WADL description of all available REST services.

rest:init[edit]

Signatures rest:init() as empty-sequence()
rest:init($update as xs:boolean) as empty-sequence()
Summary Initializes the RESTXQ module cache:
  • By default, the cache will be discarded, and all modules will be parsed and cached again.
  • If $update is enabled, the background caching behavior is simulated (see PARSERESTXQ): Only updated modules will be parsed.
  • This function should be called if new RESTXQ code is deployed at runtime.

Changelog[edit]

Version 9.4
Version 8.6

This module was introduced with Version 7.7.