Database Reference
In-Depth Information
Where to Store Your Application?
A real-world application consists of data, which for eXist is always stored in the data‐
base, and the application itself, which consists of many files—not only (XQuery)
scripts but also images, stylesheets, static HTML pages, and more. In times past (v1.4
and before), eXist gave you a choice of where to store these files: either in the filesys‐
tem (underneath a subdirectory of $EXIST_HOME/webapp/myapp ) or in the
database.
Although the option to use the filesystem for your application is still supported, it has
been deprecated for some time and should not be used. Security and deployment are
the major drivers for this, and additionally, applications stored in the database are
part of standard database backups. The database's security system lets you tag certain
resources for general usage and others for use by specific users and/or groups. This
provides an extra layer of security on top of what is built into the application logic.
Deployment on a live database is a breeze; a simple backup/restore does the trick. If
you need more functionality, packaging mechanisms are available (see “Packaging”
on page 227 ). There are several tools that make working with resources in the database
feel almost exactly like working with files on the filesystem (as you'll read about in
Chapter 14 ). RESTXQ (see “Building Applications with RESTXQ” on page 215 ) only
works from within the database. The only remaining issue is version control, but with
a bit of scripting that can be solved too (for instance, using eXist Ant scripting, as
described in “Ant and eXist” on page 379 ).
So, develop your application in the database and reap the benefits of the security and
deployment mechanisms offered. Do not use the filesystem (any longer).
URL Mapping Using URL Rewriting
URL mapping is all about providing meaningful URLs to your users and keeping
them consistent. For instance, in a wiki, you might want the user to visit a subject
with a URL like http://…/wiki/subjectname . But, of course, there will not be an
XQuery script for every subject. Likely, there will be a single script handling all sub‐
jects based on some parameter, like in http://…/wiki/handlepage?subject=subject‐
name .
eXist's oldest and most mature mechanism for mapping URLs to functionality is
called URL rewriting . URL rewriting works by intercepting the HTTP request and
passing control to a single entry point. This entry point is an XQuery script, always
called controller.xql . Because it is XQuery, you can do whatever you want in it. It
must return an XML fragment that describes what eXist should do next.
Search WWH ::




Custom Search