| XQUERY/XSLT API DOCUMENTATION 4.2 |
All XQuery & XSLT Functions MarkLogic Built-In Functions Admin (xdmp:) AppServer (xdmp:) Classifier (cts:) Debug (dbg:) Document Conversion (xdmp:) Extension (xdmp:) Documents, Directories, Properties, and Locks Functions Extension Functions Function Values Functions HTTP Functions JSON Functions MarkLogic Server Functions Search Functions XML Functions XQuery Context Functions XSLT Functions map (map:) Math (math:) Profile (prof:) Search (cts:) cts:query Constructors Functions Geospatial Functions Geospatial Lexicon Functions Lexicon Functions Search Functions Search Clustering Functions Security (xdmp:) Server Monitoring (xdmp:) Spell (spell:) Update (xdmp:) XQuery Library Modules Admin Library (admin:) Actions Functions Appserver Functions Database Functions Forest Functions Group Functions Host Functions Mimetypes Functions Scheduler Functions Alerting (alert:) Elastic Compute Cloud (ec2:) Entity Enrichment (entity:) Flexible Replication (flexrep:) Geospatial Supporting Functions GEO Functions GeoRSS Functions GML Functions KML Functions MCGM Functions Information Studio (info:) Information Studio Developer (infodev:) Library Services (dls:) cts:query Constructor Functions Document Management Functions Document Update Functions Retention Policy Functions XInclude Functions Modular Documents XInclude Functions XPointer Functions PKI (pki:) Plugin (plugin:) Search (search:) Security-sec (sec:) Spelling Dictionary Management (spell:) Thesaurus (thsr:) Triggers (trgr:) Triggers Library (trgr:) WordProcessingML (ooxml:) ZIP Package (ooxml:) CPF Functions Content Processing Framework (cpf:) CSS Conversion (css:) DocBook Conversion (dbk:) Domains (dom:) Excel Conversion (excel:) Generic Conversion (cvt:) Links (lnk:) MSWord Conversion (msword:) PDF Conversion (pdf:) Pipelines (p:) Powerpoint Conversion (ppt:) XHTML Conversion (xhtml:) W3C-Standard Functions Accessor (fn:) AnyURI (fn:) Boolean (fn:) Context (fn:) DurationDateTime (fn:) Error and Trace (fn:) Node (fn:) Numeric (fn:) QName (fn:) Sequence (fn:) String (fn:) XSLT (fn:) W3C XQuery/XSLT Reference W3C XQuery Functions W3C XQuery Language W3C XSLT Language
This page was generated September 12, 2012 6:02 AM | XQuery & XSLT Built-In & Modules Function Reference
Module: ZIP Package
The ZIP Package function module is installed as the following file: `install_dir/Modules/MarkLogic/openxml/package.xqy` where `install_dir` is the directory in which MarkLogic Server is installed. To use the `package.xqy` module in your own XQuery modules, include the following line in your XQuery prolog:
    import module namespace ooxml="http://marklogic.com/openxml"
    	    at "/MarkLogic/openxml/package.xqy";
The ZIP Package functions are used to unpack Microsoft Office Open XML documents from their compressed ZIP format into an expanded package with a directory structure, and then to insert each of those documents in a database. You can use these functions with any document that is a ZIP package, including Office 2007 documents.
Function Summary
ooxml:package-parts | This function returns the documents within the zip package.
ooxml:package-parts-insert | This function inserts one document in the database for each part at the specified URI.
ooxml:package-uris | This function returns the list of files in the zip package.
Function Detail
ooxml:package-parts(
| $package as node()
) as xs:string*
Summary: This function returns the documents within the zip package. Typically, the parts are returned as document nodes. They are returned in the order the package uris are returned, which is the manifest order.
Parameters:
$package : The zip package.
Example:
    xquery version "1.0-ml";
    import module namespace ooxml= "http://marklogic.com/openxml"
              at "/MarkLogic/openxml/package.xqy";

    let $pkg := xdmp:document-get("c:/tmp/test.docx")
    return
    ooxml:package-parts($pkg)[4]
    => The fourth document in the archive, which is the
    word/document.xml part in this example.
ooxml:package-parts-insert(
| $directory as xs:string?,
| $package-uris as xs:string*,
| $package-parts as node()*,
| [$permissions as element(sec:permission)*],
| [$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 (optional): Security permission elements corresponding to the permissions for the document. 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 (optional): 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 (optional): 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 (optional): 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 specifed 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.
ooxml:package-uris(
| $package as node()
) as xs:string*
Summary: This function returns the list of files in the zip package.
Parameters:
$package : The zip package.
Example:
    xquery version "1.0-ml";
    import module namespace ooxml= "http://marklogic.com/openxml"
                at "/MarkLogic/openxml/package.xqy";

    let $pkg := xdmp:document-get("c:/tmp/test.docx")
    return
    ooxml:package-uris($pkg)
    => The sequence comprising th list of documents in the archive,
    for example:
    ("[Content_Types].xml", "_rels/.rels", "word/_rels/document.xml.rels",
    "word/document.xml", "word/footer3.xml", "word/footer2.xml",
    "word/footer1.xml", "word/endnotes.xml", "word/footnotes.xml",
    "word/_rels/header1.xml.rels", "word/header1.xml",
    "word/media/image1.wmf", "word/theme/theme1.xml",
    "word/_rels/settings.xml.rels", "word/settings.xml",
    "word/styles.xml", "customXml/itemProps1.xml", "word/numbering.xml",
    "customXml/_rels/item1.xml.rels", "word/fontTable.xml",
    "docProps/app.xml", "docProps/core.xml", "customXml/item1.xml",
    "word/webSettings.xml", "docProps/custom.xml")

© Copyright 2002-2012 MarkLogic Corporation. All rights reserved.