Hello BaseX Team,
In reading the documentation and mail archives, it seems to me that BaseX
does not support documents in terms of having a single URI referring to a
single document node. For example, if I add a document using the db:add
function:
db:add("DB", document { <a/> }, "doc.xml")
And subsequently attempt to retrieve it using the doc function:
fn:doc("doc.xml")
I get a FODC0002 error. This is discussed in the mail archives, and so far
as I can tell this is because BaseX only works with collections. It does not
really address the concept of a documents (excuse me if I am over
simplifying the issue here). In other words, I am free to add more document
nodes under the name "doc.xml" therefore it is technically a collection as
opposed to a document. Is this correct?
A fairly early mailing list thread from 2010-07 addresses a similar and
suggests an alternative approach where one might retrieve a document in a
collection as follows:
for $doc in collection('DB')
where matches(document-uri($doc), 'doc.xml')
return $doc
But, doesn't this run afoul of the W3C recommendation which states for the
fn:docucument-uri function that:
"In the case of a document node $D returned by the fn:doc function, or a
document node at the root of a tree containing a node returned by the
fn:collection function, it will always be true that either
fn:document-uri($D) returns the empty sequence, or that the following
expression is true: fn:doc(fn:document-uri($D)) is $D. It is
implementation-defined whether this guarantee also holds for document nodes
obtained by other means, for example a document node passed as the initial
context node of a query or transformation."
In other words, if document-uri is returning 'doc.xml' for a node in
collection('DB') then I should be able to get that same document node using
the doc function.
I ask these questions because we are interested in being able to maintain
XML artifacts as singular documents, and using the collection hierarchy to
do things such as storing temporary and archived version of these artifacts.
The approach we are taking right now assumes that there is only one
document-node under each 'document'. I want to understand the limitations of
the collection and document implementation in BaseX so that I don't make any
wrong assumptions (as I think I already have).
Finally, assuming the interpretations are correct, are there plans to make
any changes in the implementation to support something more in line with the
hierarchy of db->collection->document? I have seen in previous threads that
you were seeking feedback on this, and I am curious to know if you still
are. Is there a major drawback you see to this model that perhaps I have not
considered? Any feedback is appreciated.
Thanks,
Jack Gager
Metadata Technology