Database Reference
In-Depth Information
declare function local:traverse-collection ( $ collection as xs:anyURI ,
$ indent as xs:integer ) as element ( p ) *
{
for $ sub-collection in xmldb:get-child-collections ( $ collection )
return
(
<p style = " margin-left: { $ indent } pt " ><b> { $ sub-collection } </b></p> ,
local:traverse-collection ( xs:anyURI ( concat ( $ collection , '/' ,
$ sub-collection )), $ indent + 10 ),
for $ document in xmldb:get-child-resources ( $ collection )
return
<p style = " margin-left: { $ indent + 5 } pt " > { $ document } </p>
)
};
<body>
{
local:traverse-collection ( xs:anyURI ( '/db/apps/exist-book' ), 0 )
}
</body>
Creating Resources and Collections
For creating resources and collections, the following functions are available:
xmldb:create-collection
As its title implies, it creates a new collection in the database. It will return the
path to the new collection when successful, or the empty sequence otherwise.
xmldb:store
Creates a new resource, storing some data passed as a parameter. It will return
the path to the new resource when successful, or throw an error when
unsuccessful.
Specifying what to store is quite flexible: you can pass data directly (for instance,
as an XML fragment or a string), and it will be stored as the new resource. How‐
ever, when the data is passed as type xs:anyURI , this is taken as the URI to the
data and eXist will try to read it from there.
There are two variants for this function: one where eXist will try to guess the
Internet media type of the data to store, and one where you can explicitly specify
this.
xmldb:store-files-from-pattern
Bulk-loads files from the filesystem. There are several variants of this function
that allow you more or less control over what is stored.
Search WWH ::




Custom Search