Database Reference
In-Depth Information
Addressing Collections, Resources, and Files
To work with documents and collections stored in the database, you need to be able
to address them, point to them, and know their names. There are several ways to do
this. Extra care should be taken when your resource and/or collection names contain
spaces or special (e.g., accented) characters.
Use URIs
There is one extremely important thing you should be aware of when addressing
resources and collections inside eXist's database: eXist uses URL-encoded URIs for
naming . This means that all reserved characters, according to the URL encoding rules
(for more information, see http://tools.ietf.org/html/rfc3986#page-12 ) , must be
percent-encoded!
For instance:
• A document that shows up as an example.xml in the WebDAV browser must be
addressed programmatically as an%20example.xml .
• A document in the collection /db/my app (test)/test.xml must be addressed
with /db/my%20app%20%28test%29/test.xml .
• When you request a list of documents inside a collection (with the function
xmldb:get-child-resources ), the names returned are URIs, and as such they
are URL-encoded.
If you are not extremely careful with this, your application will
quickly become a mess. Always distinguish internally between
names (useful for displaying document/collection names to the
user) and URIs (useful for addressing the documents/collections).
Conveniently, eXist contains standard functions to transform a name into a URI, and
vice versa:
xmldb:decode-uri
Decodes a URI into a name; that is, it changes all percent-encoded characters
into their UTF-8 equivalent characters.
xmldb:encode-uri
Encodes a name into a URI; that is, it checks for reserved characters and changes
them into the equivalent URL percent-encoding.
Search WWH ::




Custom Search