Database Reference
In-Depth Information
else
<rest:response>
<http:response status = "{ $ ii:HTTP-NOT-FOUND }" >
<http:header name = " Content-Type "
value = " application/xml " />
</http:response>
</rest:response>
};
This is similar to our code for retrieving an image, except as well as the identifier
of the image we declare that we are only interested in URI paths that also have
a /thumbnail segment.
Instead of retrieving an image, we now create or retrieve a thumbnail. The details
of this are out of scope here, and the code is not too difficult to understand; the
main point of interest is the call to the extension image:scale , which will
actually generate the thumbnail image.
Hopefully, you will agree that the RESTXQ version is simpler and easier to under‐
stand than the REST Server API version. For example, in this specific example we
have not had to handle unwanted requests and return an HTTP 400 Bad Request or
HTTP 406 Method Not Allowed , as the RESTXQ API takes care of that for us.
XQJ
XQJ is a standardized Java API developed by the JCP (Java Community Process) as
JSR-225. A JSR (Java Specification Request) is centered solely on Java, and thus the
API is not really suitable for direct use in other programming languages. The imple‐
mentation of the XQJ server in eXist is really just a few extensions to eXist's REST
Server, with any XQJ client expected to communicate using HTTP via the REST
Server API. If you like the XQJ API but do not like Java, then theoretically there is
nothing to stop you from implementing an XQJ-like client in any language, and it
should not be too difficult providing you understand the REST Server API.
XQJ JSR-225 focuses solely on XQuery: it allows you to send an XQuery to the server,
have it executed, and receive the results. It also allows you to prepare XQuery expres‐
sions that can be parameterized and executed later (similar to prepared statements in
JDBC). While XQJ does not directly provide any facilities for managing documents
or the database, it is possible to achieve similar functionality by using eXist's XQuery
xmldb extension module (see the entry for xmldb in Appendix A ).
eXist has chosen only to implement a server API for use by XQJ; it does not provide
an XQJ client implementation. This is mainly because there is an excellent and freely
available XQJ client implementation from Charles Foster at http://www.xqj.net ,
which you may use in your own Java programs.
Search WWH ::




Custom Search