XQuery, the Server Language
by Kurt Cagle
|
Pages: 1, 2, 3
The eXist database defines a number of these namespaces out of the box. From the standpoint of servlet development, perhaps the most important namespaces are as follows:
-
request: provides access to information sent from the client. Functions include get-cookie-names, get-cookie-value, get-data, get-header, get-header-names, get-method, get-parameter, get-parameter-names, get-server-name, get-uploaded-file, get-uploaded-file-name, and get-url.
-
response: lets the developer control the stream of data being sent back to the client. Functions include redirect-to, set-cookie, set-header, and stream-binary.
-
session: provides control over the user's HTTP sesssion. Functions include create, encode-url, get-attribute, get-attribute-names, get-id, invalidate, set-attribute, and set-current-user.
-
transform: lets the developer transform an XML node using XSLT from within the xquery. Functions include transform and stream-transform.
-
update: The update commands (distinct from a namespace) let you perform live updates of the data in the eXist XML database, either at the granular level of changing a value in the database or at the level of inserting or removing whole documents. This addresses one of the big shortcomings of XQuery, in that it provides for an effective read-write solution that can be invoked from within an XQuery.
Other extensions can be compiled in by rebuilding the Java JAR (a shell or batch script automates this process) for doing such things as writing SQL queries and updates designed to work with any JDBC compliant SQL database, such as Oracle, mySQL, Postgres, or SQL Server. This capability is especially important because it provides a bridge between the SQL and XML worlds, letting you perform complex queries (or updates) on your SQL database then passing this information to the XQuery to be additionally processed, filtered, sorted, or transformed.
Additionally, other extensions give access to a full range of math functions (including the oh-so-useful math:random function), let you send mail through an SMTP server, retrieve (and to a certain extent modify) images (which can also be stored in the database, by the way), and other functions that provide functionality more associated with a full bore server-side scripting language than an XML query language.
This article serves as a very basic introduction to XQuery as a server language. I will be addressing this topic in more detail in subsequent articles in this series, examining some of the more sophisticated capabilities and the gotchas inherent in working with XQuery and eXist, and showing what explosive power you can release when you combine eXist or other rest based XQuery engines with XForms and Ajax.
My prediction is that REST based XML databases like eXist will seriously challenge the existing raft of server languages, from ASP to Ruby, within the next couple of years. Right now, it's something of a closed secret among a few developers, but the power, sophistication and ease of use inherent in working with the XML as if it were a natural part of the server landscape can only be understood by trying it.
- Why not an XML notation ?
2007-06-09 01:39:23 Alain_COUTHURES - Why not an XML notation ?
2007-06-13 23:49:34 JorisGraaumans - Why not an XML notation ?
2007-06-16 01:14:16 Alain_COUTHURES - Thanks
2007-06-07 23:44:56 Lars Huttar - Thanks
2007-06-08 01:14:09 Kurt Cagle - thanks Kurt...
2007-06-07 20:44:25 itod47 - Security concerns
2007-06-07 08:02:16 john_judy - Security concerns
2007-06-08 01:11:52 Kurt Cagle - XQuery
2007-06-06 14:48:09 jkreisa - MarkLogic
2007-06-08 01:17:42 Kurt Cagle - I predicted that too ... 8 years ago
2007-06-06 14:43:26 mchampion - I predicted that too ... 8 years ago
2007-06-08 01:28:17 Kurt Cagle - I predicted that too ... 8 years ago
2007-06-07 01:42:39 BryanRasmussen