metadata
Saturday, 13 February 2016 · 2 messages · last reply 15 Feb 2016
KS
Kendall Shaw13 Feb 2016 20:28 #
Unless there is now a standard way to associate metadata with documents and collections, is there a preferred method?
I could try to ensure that there is always a unique id that can be derived from combination of an id attribute or element in the document + the document’s document uri, then have separate metadata documents that are associated with the unique id. Is there an obviously better approach?
Kendall
CG
Christian Grün15 Feb 2016 10:30 #
Hi Kendall,
One popular approach is to maintain an additional metadata.xml document, which contains all metadata for the documents stored in a database. Here is a simple example for maintaining a timestamp: ____________________________
* Creation:
db:create('db', <meta/>, 'metadata.xml')* Insertion:
let $path := 'new-doc.xml'
let $doc := <xml/>
let $meta := element doc {
attribute path { $path },
element timestamp { current-dateTime() }
}
return (
db:add('db', $doc, $path),
insert node $meta into db:open('db', 'metadata.xml')/meta
)* Retrieval:
let $path := 'new-doc.xml'
return db:open('db', 'metadata.xml')/meta/doc[@path = $path]* Deletion:
let $path := 'new-doc.xml'
return (
db:delete('db', $path),
delete node db:open('db', 'metadata.xml')/meta/doc[@path = $path]
)
____________________________Cheers,
Christian
Quoted text · Kendall Shaw · 10 lines
On Sat, Feb 13, 2016 at 8:28 PM, Kendall Shaw <kendall.shaw at workday.com> wrote: > Unless there is now a standard way to associate metadata with documents and > collections, is there a preferred method? > > I could try to ensure that there is always a unique id that can be derived > from combination of an id attribute or element in the document + the > document’s document uri, then have separate metadata documents that are > associated with the unique id. Is there an obviously better approach? > > Kendall
Written for BaseX 8.4. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery