4.2.2 Metadata Functions

The below functions provide meta-data information about the XML database stored in MonetDB/XQuery. We have tried to maintain ACID properties with respect to the document management functions described above. This is achieved currently using a simple locking approach, which means that it will block on conflicting document management functions (the shredding function pf:add-doc(), may take considerable time on large XML instances).

If you rather trade consistency for not locking, you may use the collections-unsafe() and documents-unsafe() functions. If a concurrent document management query adds two collections to the database, the latter functions may list documents added by the first pf:add-doc() yet omit documents still being added by the second pf:add-doc().

pf:collection ($name as xs:string) as xs:node
pf:collections () as node()*
pf:collections-unsafe () as node()*
pf:documents () as node()*
pf:documents-unsafe () as node()*
pf:documents ($name as xs:string) as xs:node
pf:documents-unsafe ($name as xs:string) as xs:node
pf:docname ($n as node() as xs:string

The pf:collections() function returns an XML node for each existing collection in the format:

<collection updatable="true" size="64 KiB" numDocs="1">hello.xml</collection>

and pf:documents() does likewise for all documents in all collections in the database:

<document updatable="true" url="c:\HelloWorld.xml" collection="hello.xml">hello</document>

The second variant of pf:documents() restricts the list to only documents from a certain collection.

The pf:docname() function is a convenience function that given a node, returns the name of the document it stems from.