MarkLogic 9 Product Documentation
ooxml:package-parts-insertooxml:package-parts-insert(
$directory as xs:string?,
$package-uris as xs:string*,
$package-parts as node()*,
[$permissions as item()*],
[$collections as xs:string*],
[$quality as xs:int?],
[$forest-ids as xs:unsignedLong*]
) as empty-sequence()
Summary
This function inserts one document in the database
for each part at the specified URI. If a directory
is given, then all parts are inserted into documents in
that directory, with the rest of the URI determined by
the $uris specified (typically from the manifest of a
zip file or Office document).
Parameters |
directory |
The name
of the base directory to concatenate with each of the
$package-uris. If this is the empty string, then the
URIs for each document are the $package-uris. If the
string does not end in a forward slash ( / ),
one is added (because directory URIs should end in a
forward slash).
|
package-uris |
The list
of URIs for the parts to insert, typically from the zip
package manifest (or from ooxml:package-uris .)
The order must correspond to the order of $package-parts.
|
package-parts |
The uncompressed
parts to insert, typically from the zip package
(or from ooxml:package-parts .) The order must
correspond to the order of $package-uris.
|
permissions |
Security permission elements corresponding to the permissions for the document.
When run in an XQuery context, the permissions are a sequence of
XML elements (sec:permission). When importing this module into
a Server-Side JavaScript context, the permissions are an array of Objects.
If not supplied, the current user's default
permissions are applied. The default value used for $permissions
can be obtained by calling xdmp:default-permissions(). A document that is
created by a non-admin user (that is, by any user who does not have the
admin role) must have at least one update permission,
otherwise the creation will throw an XDMP-MUSTHAVEUPDATE
exception.
|
collections |
The collection URIs for collections to which this document
belongs. If not supplied, the document is added to the current
user's default collections. For each collection that is protected, the
user must have permissions to update that collection or have the
any-collection privilege. For each unprotected collection,
the user must have the unprotected-collections privilege.
The default value used for $collections can be obtained by calling
xdmp:default-collections() .
|
quality |
The quality of this document. A positive value increases
the relevance score of the document in text search functions.
The converse is true for a negative value. The default value is 0.
|
forest-ids |
Specifies the ID of the forest in which this document is inserted.
If the document already exists in the database and if $forest-ids is
not specified, it will remain in its existing forest. If no such
forest exists or if no such forest is attached to the context database,
an error is raised. If multiple forests are specified, the document
is inserted into one of the specified forests.
|
Usage Notes
This function has similar semantics to
xdmp:document-insert
. If a document already exists
at one of the specified URIs, the function replaces the contents
of the existing documents with the specified content. In addition
to replacing the content,
ooxml:package-parts-insert
replaces any permissions, collections, and quality with the ones
specified (or with the default
values for these parameters, if not explicitly specified). Also, if a
properties document exists at the same URI, that properties document
(including any content it contains) is preserved.
Example
xquery version "1.0-ml";
import module namespace ooxml= "http://marklogic.com/openxml"
at "/MarkLogic/openxml/package.xqy";
let $dir := "/my/office/docs/"
let $pkg := xdmp:document-get("c:/tmp/test.docx")
let $uris := ooxml:package-uris($pkg)
let $parts := ooxml:package-parts($pkg)
return ooxml:package-parts-insert($dir, $uris, $parts)
=> The empty sequence. The documents are inserted
into the database under the /my/office/docs/ directory.
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.