Inserts a new instance into a database.
fn:put(node $node, string $uri)
The function does not return a result.
Updating functions, which include fn:put
, cannot
be called from an XQuery expression. This function can only be called within an
XQuery update
expression.
If the $node
argument holds an XML document node,
a corresponding document is stored in the Tamino database. If the
$node
argument holds an element, it is internally
wrapped by a document node.
The fn:put
function is restricted to store
documents in the database instance that is processing the update expression.
Because of this constraint, the argument must be a relative URI. The relative
URI is interpreted in the same way as the corresponding part in the URI of a
_process command; this
means that:
the collection is mandatory;
in the case of an XML document, the doctype part may be empty; otherwise, the document is stored with the specified doctype;
the docname part is optional.
The doctype part of the URI must be indicated by a slash. The docname
part of the URI, if present, must be indicated by a slash. The following
example URI stores into ino:etc with a docname of
"test":
ino:etc//test
.
A node that holds the instance to be inserted.
The URI of the location where the instance should be stored.
An update expression that directly calls the
fn:put
function. It inserts a document that holds an
author list into the bib collection.
update fn:put(document{<author-list>{collection("bib")/bib/book/author}</author-list>},"bib")
Using a FLWU expression improves the readability:
update let $node := document{<author-list>{collection("bib")/bib/book/author}</author-list>} do fn:put($node,"bib")
The following construct(s) refer to this construct: