This page was generated
Jan. 25, 2010
11:01 PM
XQuery Function Reference

Module: PresentationML Support

The PresentationML function module is installed as the following file:

  • install_dir/Modules/MarkLogic/openxml/presentation-ml-support.xqy

where install_dir is the directory in which MarkLogic Server is installed.

To use the presentation-ml-support.xqy module in your own XQuery modules, include the following line in your XQuery prolog:

import module namespace ppt="http://marklogic.com/openxml/powerpoint" at "/MarkLogic/MarkLogic/openxml/presentation-ml-support.xqy"

The PresentationML functions are used to manipulate Microsoft Office Open XML documents.

Function Summary
ppt:directory-uris This function returns URIs for the presentation documents within the specified directory.
ppt:insert-slide This function returns updated map for the presentation, with slides inserted from presentations specified in parameters.
ppt:package-make This function returns a presentation in the OPC (Open Packaging Convention) format XML.
ppt:package-map This function returns a map for the specified presentation.
ppt:package-map-zip This function returns the zip archive for the documents specified in the map.
Function Detail
ppt:directory-uris(
$directory as xs:string
[$depth as xs:string]
) as xs:string*
Summary:

This function returns URIs for the presentation documents within the specified directory.

Parameters:
$directory: The directory in MarkLogic that includes the document parts for an extracted presentation.
$depth (optional): The depth of the directory query. Default is "infinity".

Example:
xquery version "1.0-ml";
import module namespace ppt=  "http://marklogic.com/openxml/powerpoint" at "/MarkLogic/openxml/presentation-ml-support.xqy";

let $presentation-dir:="/foo_pptx_parts/"   
return ppt:directory-uris($presentation-dir)

=>
/foo_pptx_parts/[Content_Types].xml
/foo_pptx_parts/_rels/.rels
/foo_pptx_parts/docProps/app.xml
/foo_pptx_parts/docProps/core.xml
/foo_pptx_parts/docProps/thumbnail.jpeg
/foo_pptx_parts/ppt/_rels/presentation.xml.rels
/foo_pptx_parts/ppt/media/image1.png
/foo_pptx_parts/ppt/presProps.xml
/foo_pptx_parts/ppt/presentation.xml
/foo_pptx_parts/ppt/slideLayouts/_rels/slideLayout1.xml.rels
/foo_pptx_parts/ppt/slideLayouts/_rels/slideLayout10.xml.rels
/foo_pptx_parts/ppt/slideLayouts/_rels/slideLayout11.xml.rels
/foo_pptx_parts/ppt/slideLayouts/_rels/slideLayout2.xml.rels
/foo_pptx_parts/ppt/slideLayouts/_rels/slideLayout3.xml.rels
/foo_pptx_parts/ppt/slideLayouts/_rels/slideLayout4.xml.rels
/foo_pptx_parts/ppt/slideLayouts/_rels/slideLayout5.xml.rels
/foo_pptx_parts/ppt/slideLayouts/_rels/slideLayout6.xml.rels
/foo_pptx_parts/ppt/slideLayouts/_rels/slideLayout7.xml.rels
/foo_pptx_parts/ppt/slideLayouts/_rels/slideLayout8.xml.rels
/foo_pptx_parts/ppt/slideLayouts/_rels/slideLayout9.xml.rels
/foo_pptx_parts/ppt/slideLayouts/slideLayout1.xml
/foo_pptx_parts/ppt/slideLayouts/slideLayout10.xml
/foo_pptx_parts/ppt/slideLayouts/slideLayout11.xml
/foo_pptx_parts/ppt/slideLayouts/slideLayout2.xml
/foo_pptx_parts/ppt/slideLayouts/slideLayout3.xml
/foo_pptx_parts/ppt/slideLayouts/slideLayout4.xml
/foo_pptx_parts/ppt/slideLayouts/slideLayout5.xml
/foo_pptx_parts/ppt/slideLayouts/slideLayout6.xml
/foo_pptx_parts/ppt/slideLayouts/slideLayout7.xml
/foo_pptx_parts/ppt/slideLayouts/slideLayout8.xml
/foo_pptx_parts/ppt/slideLayouts/slideLayout9.xml
/foo_pptx_parts/ppt/slideMasters/_rels/slideMaster1.xml.rels
/foo_pptx_parts/ppt/slideMasters/slideMaster1.xml
/foo_pptx_parts/ppt/slides/_rels/slide1.xml.rels
/foo_pptx_parts/ppt/slides/slide1.xml
/foo_pptx_parts/ppt/tableStyles.xml
/foo_pptx_parts/ppt/theme/theme1.xml
/foo_pptx_parts/ppt/viewProps.xml
                                      

ppt:insert-slide(
$map as map:map
$from-pres as xs:string+
$from-idx as xs:integer+
$insert-idx as xs:integer
) as map:map
Summary:

This function returns updated map for the presentation, with slides inserted from presentations specified in parameters.

The keys for the map are the names for the files within a presentation .pptx package. The value for the key is either
A) a URI for a presentation part in MarkLogic, or B) the actual XML element for the respective presentation package part.

Note: the lengths of the sequences of $from-pres and $from-idx must be equal, otherwise an Error is thrown.

Note: a slide may be inserted into the presentation contained within $map at any slide index that is
within the count of slides contained within the presentation +1. Trying to insert a slide into an index that is not allowed results in Error.

Parameters:
$map: The map for a .pptx presentation.
$from-pres: The directory in MarkLogic for a presentation from which slides will be inserted into the presentation within $map.
$from-idx: The index of the slide within the $from-pres that is to be inserted into $map.
$insert-idx: The insertion point for the presentation within $map, where the slide inserted from $from-pres will be inserted at.

Example:

In the following example, we have 2 presentations we've saved: demo_one.pptx and demo_two.pptx. These have both been unzipped and
their respectve parts saved to MarkLogic using the Office OpenXML Extract pipeline. Opening the presentations (.pptx) in PowerPoint, the
slides appear as follows:


demo_one.pptx    demo_two.pptx
    
            
    


demo_one.pptx has 2 slides, and demo_two.pptx has 1. We can insert slide 1 of demo_two.pptx to position 2 of presentation demo_one.pptx from
the extracted parts to create demo_three.pptx as follows:
xquery version "1.0-ml";

import module namespace ppt=  "http://marklogic.com/openxml/powerpoint" at "/MarkLogic/openxml/presentation-ml-support.xqy";

let $target-pres:="/demo_one_pptx_parts/"       (:target presentation:)
let $source-pres:="/demo_two_pptx_parts/"       (:source presentation:)

let $source-idx := 1    (:index of slide in source to copy to target :)
let $start-idx :=  2    (:insertion index of target presentation     :)

let $pptx-map := ppt:package-map($target-pres)

let $new-map  := ppt:insert-slide($pptx-map,$source-pres, $source-idx, $start-idx)
let $pptx-pkg := ppt:package-map-zip($new-map)  

return xdmp:save("C:\demo_three.pptx",$pptx-pkg)

The resulting presentation, when opened in PowerPoint will be:

demo_three.pptx
    
    


Example:

We can insert slides from multiple source presentations into a single destination presentation as well.
xquery version "1.0-ml";
import module namespace ppt=  "http://marklogic.com/openxml/powerpoint" at "/MarkLogic/openxml/presentation-ml-support.xqy";

let $targ-pres:="/one_pptx_parts/"          (:target presentation:)
let $source-pres-one:= "/two_pptx_parts/"   (:source presentation:)
let $source-pres-two:= "/three_pptx_parts/" (:another source presentation:) 
let $s-idx-1 := 1                           (: index of slide in source-pres-one to copy to target   :)
let $s-idx-2 := 15                          (: index of slide in source-pres-two to copy to target   :)
let $start-idx := 2                         (: insertion index starting point of target presentation :)

let $pptx-map := ppt:package-map($targ-pres)

return ppt:insert-slide($pptx-map, ($source-pres-one,$source-pres-two), ($s-idx-1,$s-idx-2), $start-idx)

=>

Returns a map containing the presentation contained within /one_pptx_parts/,
updated to include slide 1 from /two_pptx_parts/ and slide 15 from /three_pptx_parts/ as slides 2 and 3 respectively.

Assuming the presentation within /one_pptx_parts/ started with 3 slides, it now has 5 total, 
and its original slides 2 and 3 have been shifted to 4 and 5 respectively.
For each slide mapped within the map, images will be retained and references throughout the package will be updated.
Slides will use the master and layout of the presentation within the map. Slides inserted will retain the target presentation look and feel.

Note: While this function works great for a certain class of Slides, and retains images, animations, and much more for a Slide when inserting
from the original source into the target presentation, this function currently does not support Smart Art, Diagrams, Embeddings (.xlsx), or
the ability to insert a Slide into a target presentation while maintaining the slideMaster and slideLayout from the original source presentation.
Also, while Notes are available in the target presentation, notes will not be retained for slides inserted from the source presentations.



ppt:package-make(
$directory as xs:string
$uris as xs:string*
) as element(pkg:package)
Summary:

This function returns a presentation in the OPC (Open Packaging Convention) format XML.

Parameters:
$directory: The directory in MarkLogic that includes the files for an extracted presentation.
$uris: The uris for the files within the $directory to use to as the pkg:parts of the OPC package.

Example:
xquery version "1.0-ml";
import module namespace ppt=  "http://marklogic.com/openxml/powerpoint" at "/MarkLogic/openxml/presentation-ml-support.xqy";

let $presentation-dir:="/foo_pptx_parts/" 
let $uris := ppt:directory-uris($presentation-dir) 
return ppt:package-make($presentation-dir, $uris)
=>
<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
  <pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512">
    <pkg:xmlData>
      <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
        <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
        <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail" Target="docProps/thumbnail.jpeg"/>
        <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml"/>
        <Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
      </Relationships>
    </pkg:xmlData>
  </pkg:part>
  <pkg:part pkg:name="/docProps/app.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.extended-properties+xml">
    <pkg:xmlData>
      <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" 
                     xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
        <TotalTime>0</TotalTime>
        <Words>4</Words>
        <Application>Microsoft Office PowerPoint</Application>
        <PresentationFormat>On-screen Show (4:3)</PresentationFormat>
        <Paragraphs>1</Paragraphs>
        <Slides>1</Slides>
        <Notes>0</Notes>
        <HiddenSlides>0</HiddenSlides>
        <MMClips>0</MMClips>
        <ScaleCrop>false</ScaleCrop>
        <HeadingPairs>
          <vt:vector size="4" baseType="variant">
            <vt:variant>
              <vt:lpstr>Theme</vt:lpstr>
            </vt:variant>
            <vt:variant>
              <vt:i4>1</vt:i4>
            </vt:variant>
            <vt:variant>
              <vt:lpstr>Slide Titles</vt:lpstr>
            </vt:variant>
            <vt:variant>
              <vt:i4>1</vt:i4>
            </vt:variant>
          </vt:vector>
        </HeadingPairs>
        <TitlesOfParts>
          <vt:vector size="2" baseType="lpstr">
            <vt:lpstr>Office Theme</vt:lpstr>
            <vt:lpstr>Slide 1</vt:lpstr>
          </vt:vector>
        </TitlesOfParts>
        <Company>Mark Logic Corporation</Company>
        <LinksUpToDate>false</LinksUpToDate>
        <SharedDoc>false</SharedDoc>
        <HyperlinksChanged>false</HyperlinksChanged>
        <AppVersion>12.0000</AppVersion>
      </Properties>
    </pkg:xmlData>
  </pkg:part>
  <pkg:part pkg:name="/docProps/core.xml" pkg:contentType="application/vnd.openxmlformats-package.core-properties+xml">
    <pkg:xmlData>
      <cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" 
			    xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/"             
                            xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <dc:title>Slide 1</dc:title>
        <dc:creator>paven</dc:creator>
        <cp:lastModifiedBy>paven</cp:lastModifiedBy>
        <cp:revision>1</cp:revision>
        <dcterms:created xsi:type="dcterms:W3CDTF">2009-09-01T19:36:41Z</dcterms:created>
        <dcterms:modified xsi:type="dcterms:W3CDTF">2009-09-01T19:37:25Z</dcterms:modified>
      </cp:coreProperties>
    </pkg:xmlData>
  </pkg:part>
  <pkg:part pkg:name="/docProps/thumbnail.jpeg" pkg:contentType="image/jpeg" pkg:compression="store">
    <pkg:binaryData>
      /9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
      AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEB
      ...
      ... 
      ...
  </pkg:part>
</pkg:package>
				      
Note: example above truncated for brevity. All pieces of .pptx package are present and serialized within <pkg:package>, captured as <pkg:part> elements.
Images in this model are captured as base64 encoded strings, following the Open XML format. This file may be opened as
a .XML file within PowerPoint. Saving as XML in PowerPoint will generate this format for a .pptx package as well.

ppt:package-map(
$directory as xs:string
) as map:map
Summary:

This function returns a map for the specified presentation. Map keys are equivalent to the manifest for the .pptx zip package. Map values are URIs for the package parts located in MarkLogic.

Parameters:
$directory: The directory in MarkLogic that contains the files of extracted presentation to be used for map.

Example:
xquery version "1.0-ml";
import module namespace ppt=  "http://marklogic.com/openxml/powerpoint" at "/MarkLogic/openxml/presentation-ml-support.xqy";

let $presentation-dir:="/foo_pptx_parts/" 
let $map := ppt:package-map($presentation-dir)
return map:keys($map)
=>
ppt/slideLayouts/slideLayout10.xml
ppt/slideLayouts/slideLayout11.xml
ppt/slideLayouts/slideLayout3.xml
ppt/slideLayouts/slideLayout4.xml
ppt/slideLayouts/slideLayout8.xml
ppt/slideLayouts/_rels/slideLayout4.xml.rels
ppt/media/image1.png
ppt/slideLayouts/_rels/slideLayout1.xml.rels
ppt/presProps.xml
ppt/slideMasters/slideMaster1.xml
docProps/thumbnail.jpeg
ppt/slides/slide1.xml
ppt/slideLayouts/_rels/slideLayout8.xml.rels
ppt/slideLayouts/_rels/slideLayout5.xml.rels
ppt/slideLayouts/_rels/slideLayout11.xml.rels
ppt/slides/_rels/slide1.xml.rels
ppt/presentation.xml
ppt/tableStyles.xml
ppt/viewProps.xml
ppt/slideLayouts/slideLayout1.xml
docProps/app.xml
ppt/slideLayouts/slideLayout5.xml
ppt/slideLayouts/slideLayout9.xml
[Content_Types].xml
docProps/core.xml
ppt/slideLayouts/_rels/slideLayout2.xml.rels
ppt/slideLayouts/_rels/slideLayout9.xml.rels
ppt/slideLayouts/_rels/slideLayout6.xml.rels
ppt/slideLayouts/_rels/slideLayout3.xml.rels
ppt/slideLayouts/slideLayout2.xml
ppt/_rels/presentation.xml.rels
ppt/slideLayouts/slideLayout6.xml
ppt/theme/theme1.xml
ppt/slideLayouts/slideLayout7.xml
_rels/.rels
ppt/slideLayouts/_rels/slideLayout7.xml.rels
ppt/slideLayouts/_rels/slideLayout10.xml.rels
ppt/slideMasters/_rels/slideMaster1.xml.rels
                                      

ppt:package-map-zip(
$map as map:map
) as binary()
Summary:

This function returns the zip archive for the documents specified in the map.

Parameters:
$map: The map to create a zip archive from. The map keys will be used for as the manifest values.
The map values are either URIs for documents on the server, or the XML that should be used for the file specified by key.

Example:
xquery version "1.0-ml";
import module namespace ppt=  "http://marklogic.com/openxml/powerpoint" at "/MarkLogic/openxml/presentation-ml-support.xqy";


let $presentation-dir:="/foo_pptx_parts/" 
let $map := ppt:package-map($presentation-dir)
let $zip := ppt:package-map-zip($map)
return xdmp:save("C:\foo2.pptx",$zip)
=>
foo2.pptx is saved on the filesystem.  this can be opened in PowerPoint.