This page was generated
June  25,  2015
8:18  AM
XQuery & XSLT Built-In & Modules Function Reference

Module: CPF Functions

The conversion module is part of the conversion processing pipeline. These functions provide some basic path manipulation functions.

To use the conversion module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace cvt = "http://marklogic.com/cpf/convert" at "/MarkLogic/conversion/convert.xqy";

You will need to ensure that the conversion module is loaded into the same modules database as the importing module.

The library namespace prefix cvt is not predefined in the server.

The Excel module is part of the conversion processing pipeline. These functions are used to manipulate XHTML derived by converting Microsoft Excel spreadsheets, as part of conversion processing.

To use the Excel module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace excel = "http://marklogic.com/cpf/excel" at "/MarkLogic/conversion/excel.xqy";

You will need to ensure that the Excel module is loaded into the same modules database as the importing module.

The library namespace prefix excel is not predefined in the server.

The MSWord module is part of the conversion processing pipeline. These functions are used to manipulate XHTML derived by converting Microsoft Msword spreadsheets, as part of conversion processing.

To use the MSWord module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace msword = "http://marklogic.com/cpf/msword" at "/MarkLogic/conversion/msword.xqy";

You will need to ensure that the MSWord module is loaded into the same modules database as the importing module.

The library namespace prefix msword is not predefined in the server.

The domains module is installed as part of the Content Processing Framework. These functions are used to manage domains, which define the association of content processing with particular collections, directories, or documents.

To use the domains module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace dom = "http://marklogic.com/cpf/domains" at "/MarkLogic/cpf/domains.xqy";

The library namespace prefix dom is not predefined in the server.

These functions should be executed in the context of the triggers database.

The CPF module is installed as part of the Content Processing Framework. These functions are used by content processing actions to manage the state of the document as it is being processed.

To use the CPF module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace cpf = "http://marklogic.com/cpf" at "/MarkLogic/cpf/cpf.xqy";

The library namespace prefix cpf is not predefined in the server.

The PDF module is part of the conversion processing pipeline. These functions are used to manipulate XHTML derived by converting PDF documents, as part of conversion processing.

To use the PDF module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace pdf = "http://marklogic.com/cpf/pdf" at "/MarkLogic/conversion/pdf.xqy";

You will need to ensure that the PDF module is loaded into the same modules database as the importing module.

The library namespace prefix pdf is not predefined in the server.

The DocBook conversion module is part of the conversion processing pipeline. These functions are used to manipulate DocBook as part of conversion processing.

To use the DocBook module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace dbk = "http://marklogic.com/cpf/docbook" at "/MarkLogic/conversion/docbook.xqy";

You will need to ensure that the DocBook module is loaded into the same modules database as the importing module.

The library namespace prefix dbk is not predefined in the server.

The links module is installed as part of the Content Processing Framework. These functions are used to manage the relationships among documents in the database, for example, as between a binary source document and an XML document generated by a conversion process from that source document. The Content Processing Framework will use links to determine if related documents should also be removed when a document is deleted from the database.

To use the links module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace lnk = "http://marklogic.com/cpf/links" at "/MarkLogic/cpf/links.xqy";

The library namespace prefix lnk is not predefined in the server.

The CSS module is part of the conversion processing pipeline. These functions are used to manipulate CSS (Cascading style sheets) as part of conversion processing.

To use the CSS module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace css = "http://marklogic.com/cpf/css" at "/MarkLogic/conversion/css.xqy";

You will need to ensure that the CSS module is loaded into the same modules database as the importing module.

The library namespace prefix css is not predefined in the server.

The XHTML module is part of the conversion processing pipeline. These functions are used to manipulate XHTML, as part of conversion processing.

To use the XHTML module as part of your own XQuery module, include the following line in your XQuery prolog:

import module namespace xhtml = "http://marklogic.com/cpf/xhtml" at "/MarkLogic/conversion/xhtml.xqy";

You will need to ensure that the XHTML module is loaded into the same modules database as the importing module.

The library namespace prefix xhtml is not predefined in the server.

Function Summary
cpf:check-transition Verify that the current transition is the correct one for the document.
cpf:document-get-error Fetch a trace of the error that caused the document's processing to fail, if any.
cpf:document-get-last-updated Determine the date and time of the last update to the document's content, if any.
cpf:document-get-processing-status Determine the document's current processing status, if any.
cpf:document-get-state Determine the document's current state, if any.
cpf:document-set-error Set the document's error trace to the given value.
cpf:document-set-last-updated Set the date and time of the document's last update.
cpf:document-set-processing-status Set the document's processing status to the given value.
cpf:document-set-state Set the document's state to the given state.
cpf:failure Concludes the state action in failure, advancing the state as defined by the state transition.
cpf:success Concludes the action successfully, advancing the state as defined by the transition.
css:convert Convert CSS text to an equivalent XML representation that is more suitable for analysis.
css:get Fetch the CSS for the given document, be it embedded or linked.
cvt:basename Return the filename part of the URI, cutting off any query strings or fragments.
cvt:basepath Return the base path of the URI, cutting off the filename.
cvt:destination-uri Construct the destination URI from the source URI using the following rules: The path prefix of the destination URI is the same as the source URI's.
cvt:part-uri Construct the URI for the part using the following rules: The path prefix of the part URI is the same source URI's, followed by a subdirectory name.
cvt:save-converted-documents Save a set of converted documents, with appropriate links.
dbk:convert Convert XHTML to DocBook lite vocabulary, if possible.
dom:add-permissions Add permissions to the domain.
dom:add-pipeline Add another pipeline to the set of pipelines bound to the domain.
dom:collection Return the name of the collection in which domains are stored.
dom:configuration-create Create a new CPF configuration.
dom:configuration-get Returns the CPF configuration.
dom:configuration-set-default-domain Set a new default domain for the CPF configuration.
dom:configuration-set-evaluation-context Set a new context for the CPF configuration.
dom:configuration-set-permissions Set new permissions for the CPF configuration.
dom:configuration-set-restart-user Set a new restart user for the CPF configuration.
dom:create Create a new content processing domain, along with the triggers that perform work in that domain.
dom:domain-scope Create a domain scope element.
dom:domains Return all the domains.
dom:evaluation-context Create an evaluation context element.
dom:get Find a particular domain.
dom:remove Remove the domain and any associated triggers.
dom:remove-permissions Remove permissions to the domain.
dom:remove-pipeline Remove the association between a pipeline and the domain.
dom:set-description Set the description of the domain.
dom:set-domain-scope Set the scope of the domain.
dom:set-evaluation-context Set the evaluation context of the domain.
dom:set-name Set the name of the domain to something else.
dom:set-permissions Set the permissions of the domain.
dom:set-pipelines Bind a new set of pipelines to the domain.
excel:clean Clean up any conversion artifacts or other infelicities, putting each sheet into its own div element.
lnk:create Create a link between the two given documents with the given role labels and strength.
lnk:from Find and return all the links from the given document to some other.
lnk:get Find and return the link between the two documents, if any.
lnk:insert Insert the given link.
lnk:remove Remove the link between the two given documents and return the removed link.
lnk:to Find and return all the links to the given document from some other.
msword:clean Clean up any conversion artifacts or other infelicities.
p:action Construct an action element.
p:collection Return the name of the collection in which pipelines are stored.
p:condition Construct a condition element.
p:create Create a new content processing pipeline.
p:execute Construct a execute element.
p:get Find a particular pipeline.
p:get-by-id Find a particular pipeline.
p:insert Insert a fully constructed content processing pipeline, returning its unique ID.
p:pipelines Return all the pipelines.
p:remove Remove the named pipeline.
p:state-transition Construct a new state transition element.
p:status-transition Construct a new status transition element.
pdf:clean Clean up any conversion artifacts or other infelicities.
pdf:get-toc Fetch the linked TOC, if any.
pdf:insert-toc-headers Locate TOC anchors and make them properly refer to headers at the appropriate level.
pdf:make-toc Clean and normalize the TOC produced by raw conversion.
ppt:clean Clean up any conversion artifacts or other infelicities, putting each slide into its own div element.
xhtml:add-lists Infer numbered or bulleted lists and insert appropriate markup.
xhtml:clean Clean up the XHTML: pruning empty spans, consolidating adjacent spans, etc.
xhtml:restructure Turn an XHTML with flat structure into one with div structure based on the header elements.
Function Detail
cpf:check-transition(
$docid as xs:string,
$transition as element(*, p:transition)?
)  as   xs:boolean
Summary:

Verify that the current transition is the correct one for the document. If a document is touched from multiple threads certain race conditions may apply that will cause the lookup of the transition to end up out of sync with the transition action when it is actually executed. In this case the action should do nothing; not even call cpf:success or cpf:failure. Some other CPF thread has already done the work on this document.


Parameters:
$docid : The URI of the document.
$transition : The pipeline transition being executed.

Example:
  xquery version "1.0-ml";
  import module namespace cpf = "http://marklogic.com/cpf" 
		  at "/MarkLogic/cpf/cpf.xqy";

  declare variable $cpf:document-uri as xs:string external;
  declare variable $cpf:transition as node() external;

  if (cpf:check-transition( $cpf:document-uri, $cpf:transition )) then
     try {
        do-my-work(),
        cpf:success( $cpf:document-uri, $cpf:transition, () )
     } catch ($e) {
        cpf:failure( $cpf:document-uri, $cpf:transition, $e, () )
     }
  else ()
  

cpf:document-get-error(
$doc as xs:string
)  as   node()?
Summary:

Fetch a trace of the error that caused the document's processing to fail, if any.

Parameters:
$doc : The URI of the document.

Example:
  xquery version "1.0-ml";
  import module namespace cpf = "http://marklogic.com/cpf" 
		  at "/MarkLogic/cpf/cpf.xqy";

  cpf:document-get-error( "/myDocs/example.xml" )
  

cpf:document-get-last-updated(
$doc as xs:string
)  as   xs:dateTime?
Summary:

Determine the date and time of the last update to the document's content, if any.

Parameters:
$doc : The URI of the document.

Example:
  xquery version "1.0-ml";
  import module namespace cpf = "http://marklogic.com/cpf" 
		  at "/MarkLogic/cpf/cpf.xqy";

  cpf:document-get-last-updated( "/myDocs/example.xml" )
  

cpf:document-get-processing-status(
$doc as xs:string
)  as   xs:string?
Summary:

Determine the document's current processing status, if any. The status will be one of "created", "updated", "deleted", "active", or "done".

Parameters:
$doc : The URI of the document.

Example:
  xquery version "1.0-ml";
  import module namespace cpf = "http://marklogic.com/cpf" 
		  at "/MarkLogic/cpf/cpf.xqy";

  cpf:document-get-processing-status( "/myDocs/example.xml" )
  

cpf:document-get-state(
$doc as xs:string
)  as   xs:anyURI?
Summary:

Determine the document's current state, if any.

Parameters:
$doc : The URI of the document.

Example:
  xquery version "1.0-ml";
  import module namespace cpf = "http://marklogic.com/cpf" 
		  at "/MarkLogic/cpf/cpf.xqy";

  cpf:document-get-state( "/myDocs/example.xml" )
  

cpf:document-set-error(
$doc as xs:string,
$error as node()?
)  as   empty-sequence()
Summary:

Set the document's error trace to the given value.

Parameters:
$doc : The URI of the document.
$error : The error causing processing failure, or empty to erase the existing trace.

Usage Notes:

In general, applications should not not need to set the error trace of a document. cpf:failure will automatically set this trace, and cpf:success will clear it.


cpf:document-set-last-updated(
$doc as xs:string,
$last-updated as xs:dateTime
)  as   empty-sequence()
Summary:

Set the date and time of the document's last update.

Parameters:
$doc : The URI of the document.
$last-updated : The date and time at which the document was last updated, typically fn:current-dateTime().

Usage Notes:

In general, applications should only set the update time of a document in the document update action and should set it to the current date and time to ensure consistency of processing.

Example:
  xquery version "1.0-ml";
  import module namespace cpf = "http://marklogic.com/cpf" 
		  at "/MarkLogic/cpf/cpf.xqy";

  cpf:document-set-last-updated( "/myDocs/example.xml", 
		               fn:current-dateTime() )
  

cpf:document-set-processing-status(
$doc as xs:string,
$processing-status as xs:string
)  as   empty-sequence()
Summary:

Set the document's processing status to the given value.

Parameters:
$doc : The URI of the document.
$processing-status : The new processing status, one of "created", "updated", "deleted", "active", or "done".

Usage Notes:

In general, applications should not not need to set the processing status of a document. If the document is currently being actively processed by the content processing framework, changing its processing status may have unexpected results. Manually setting the document's processing status should therefore be done only on documents whose processing status is "done". Setting the document's processing status to "updated" can be a means of triggering reprocessing; setting it to "deleted" can be a means of providing a soft-delete capability.

Example:
  xquery version "1.0-ml";
  import module namespace cpf = "http://marklogic.com/cpf" 
		  at "/MarkLogic/cpf/cpf.xqy";

  cpf:document-set-processing-status( "/myDocs/example.xml", 
 		                    "deleted" )
  

cpf:document-set-state(
$doc as xs:string,
$state as xs:anyURI
)  as   empty-sequence()
Summary:

Set the document's state to the given state.

Parameters:
$doc : The URI of the document.
$state : The new state of the document.

Usage Notes:

Setting a document's state may trigger content processing. If the document is currently being actively processed by the content processing framework, changing its state may have unexpected results. Manually setting the document's state should therefore be done only on documents whose processing status is "done".

Example:
  xquery version "1.0-ml";
  import module namespace cpf = "http://marklogic.com/cpf" 
		  at "/MarkLogic/cpf/cpf.xqy";

  cpf:document-set-state( "/myDocs/example.xml", 
                          "http://marklogic.com/states/reprocess" )
  

cpf:failure(
$docid as xs:string,
$transition as element(*, p:transition)?,
$exception as node()?,
$override-state as xs:anyURI?
)  as   empty-sequence()
Summary:

Concludes the state action in failure, advancing the state as defined by the state transition. The state action must call this method to indicate failure, passing the external variables $cpf:document-uri, $cpf:transition, and $cpf:exception as parameters. If the document does not exist, do nothing.

Side effects: Advances the document state to the transition's on-failure state, if any, and marks the document as processed in the current state.


Parameters:
$docid : The URI of the document.
$transition : The pipeline transition being executed.
$exception : The exception leading to the processing failure, if any.
$override-state : The next state of the document, overriding the transition state.

Example:
  xquery version "1.0-ml";
  import module namespace cpf = "http://marklogic.com/cpf" 
		  at "/MarkLogic/cpf/cpf.xqy";

  declare variable $cpf:document-uri as xs:string external;
  declare variable $cpf:transition as node() external;
  declare variable $cpf:exception as node() external;

  cpf:failure( $cpf:document-uri, $cpf:transition, $cpf:exception, () )
  

cpf:success(
$docid as xs:string,
$transition as element(*, p:transition)?,
$override-state as xs:anyURI?
)  as   empty-sequence()
Summary:

Concludes the action successfully, advancing the state as defined by the transition. The action must call this method to indicate completion of successful processing, passing the external variables $cpf:document-uri and $cpf:transition as parameters. If the document does not exist, do nothing.

Side effects: Advances the document state to the transition's on-success state, if any, and marks the document as processed in the current state.


Parameters:
$docid : The URI of the document.
$transition : The pipeline transition being executed.
$override-state : The next state of the document, overriding the transition state.

Example:
  xquery version "1.0-ml";
  import module namespace cpf = "http://marklogic.com/cpf" 
		  at "/MarkLogic/cpf/cpf.xqy";

  declare variable $cpf:document-uri as xs:string external;
  declare variable $cpf:transition as node() external;

  cpf:success( $cpf:document-uri, $cpf:transition, () )
  

css:convert(
$css as xs:string,
$options as element()?
)  as   element(css:styles)?
Summary:

Convert CSS text to an equivalent XML representation that is more suitable for analysis.

Parameters:
$css : The CSS text itself.
$options : Options for the conversion. The following options are defined: "html-style", the name of the CSS class on the "html" element; "body-style", the name of the CSS class on the "body" element. These style names are used to improve weighting heuristics. The options are in the "css:convert" namespace.

Example:
  xquery version "1.0-ml";
  import module namespace css = "http://marklogic.com/cpf/css" 
		  at "/MarkLogic/conversion/css.xqy";

  css:convert( css:get("http://example.com/mydoc.xhtml"), () )
  

css:get(
$doc as xs:string
)  as   xs:string
Summary:

Fetch the CSS for the given document, be it embedded or linked. Limitation: doesn't account for @import directives in the CSS; assumes the linked CSS is in the database.

Parameters:
$doc : The name of the parent document.

Example:
  xquery version "1.0-ml";
  import module namespace css = "http://marklogic.com/cpf/css" 
		  at "/MarkLogic/conversion/css.xqy";

  css:get("http://example.com/mydoc.xhtml") 
  

cvt:basename(
$uri as xs:string
)  as   xs:string
Summary:

Return the filename part of the URI, cutting off any query strings or fragments.

Parameters:
$uri : The URI to manipulate.

Example:
  xquery version "1.0-ml";
  import module namespace cvt = "http://marklogic.com/cpf/convert" 
		  at "/MarkLogic/conversion/convert.xqy";

  cvt:basename( "http://example.com/a.path/myfile.doc" ) 
     
  => "myfile.doc"
  

cvt:basepath(
$uri as xs:string
)  as   xs:string
Summary:

Return the base path of the URI, cutting off the filename.

Parameters:
$uri : The URI to manipulate.

Example:
  xquery version "1.0-ml";
  import module namespace cvt = "http://marklogic.com/cpf/convert" 
		  at "/MarkLogic/conversion/convert.xqy";

  cvt:basepath( "http://example.com/a.path/myfile.doc" ) 

  => "http://example.com/a.path"
  

cvt:destination-uri(
$uri as xs:string,
$extension as xs:string
)  as   xs:string
Summary:

Construct the destination URI from the source URI using the following rules: The path prefix of the destination URI is the same as the source URI's. The filename in the destination maps '.' to '_' and appends the given extension.

Parameters:
$uri : The URI to manipulate.
$extension : The extension to add, such as ".xml"

Example:
  xquery version "1.0-ml";
  import module namespace cvt = "http://marklogic.com/cpf/convert" 
		  at "/MarkLogic/conversion/convert.xqy";

  cvt:destination-uri("http://example.com/a.path/myfile.doc", ".xml")
     
  => "http://example.com/a.path/myfile_doc.xml"
  

cvt:part-uri(
$uri as xs:string,
$part as xs:string
)  as   xs:string
Summary:

Construct the URI for the part using the following rules: The path prefix of the part URI is the same source URI's, followed by a subdirectory name. The subdirectory name is formed by mapping '.' to '_' in the source filename and appending '_parts' to it. The part's filename is unchanged, but any part path is removed.

Parameters:
$uri : The URI to manipulate.
$part : The part to append to the URI. Only the filename is appended; any subdirectories preceding the filename are removed.

Example:
  xquery version "1.0-ml";
  import module namespace cvt = "http://marklogic.com/cpf/convert" 
		  at "/MarkLogic/conversion/convert.xqy";

  cvt:part-uri("http://example.com/a.path/myfile.doc", 
               "images/image1.jpg")
  
  => "http://example.com/a.path/myfile_doc_parts/image1.jpg"
  

cvt:save-converted-documents(
$source-uri as xs:string,
$destination-uri as xs:string,
$manifest as element(),
$docs as document-node()*,
[$destination-collections as xs:string*]
)  as   empty-sequence()
Summary:

Save a set of converted documents, with appropriate links. If there is a main document, it must be the first listed in the manifest. The order in the manifest (as in xdmp:xxx-convert) must match the order of document nodes. Any cleaning or other preprocessing of the documents must already have been done. If certain parts should have been created in a certain state or with other initial properties, that must be done after the call to this function.

Parameters:
$source-uri : The URI of the source document.
$destination-uri : The URI of the root destination (converted) document.
$manifest : The parts list of all the conversion products, as returned by xdmp:pdf-convert, xdmp:word-convert, etc. The main or root document should be the first on the list, if there is one.
$docs : The documents produced by conversion, in the same order as in the manifest.
$destination-collections (optional): The collections for the destination document. The default is the empty sequence.

Example:
  xquery version "1.0-ml";
  import module namespace cvt = "http://marklogic.com/cpf/convert" 
		  at "/MarkLogic/conversion/convert.xqy";

  let $results := xdmp:word-convert( doc("myfile.doc"), "myfile.doc" )
  return 
     cvt:save-converted-documents("myfile.doc", "myfile.doc",
        $results[1], $results[2 to last()] )
  

dbk:convert(
$doc as node()?,
$options as element()?
)  as   node()*
Summary:

Convert XHTML to DocBook lite vocabulary, if possible. The section structuring depends on the presence of div elements with mlsection markers, as produced by xhtml:restructure.

Parameters:
$doc : The contents of the XHTML document.
$options : Conversion options in the "dbk:docbook" namespace. There are two options are defined: "wrap-text", a boolean value which causes "phrase" elements to be inserted where XHTML "span" elements were found. The default is false. "preserve-styles", a boolean value which causes the XHTML "class" attributes to be mapped to "role" attributes in the output. The default is false.

Example:
  xquery version "1.0-ml";
  import module namespace dbk = "http://marklogic.com/cpf/docbook" 
		  at "/MarkLogic/conversion/docbook.xqy";

  let $options := 
     <options xmlns="dbk:convert">
       <wrap-text>false</wrap-text>
       <preserve-styles>true</preserve-styles>
     </options>
  return dbk:convert(fn:doc("http://example.com/mydoc.xhtml"), $options) 
  

dom:add-permissions(
$domain-name as xs:string,
$permissions as element(sec:permission)*
)  as   empty-sequence()
Summary:

Add permissions to the domain. An error is raised if the domain cannot be found. The triggers associated with the domain will be modified also.

Parameters:
$domain-name : The name of the domain to be changed.
$permissions : Additional permissions for the domain.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:add-permissions( "Incoming", 
		       xdmp:permission("development", "read") )
  

dom:add-pipeline(
$domain-name as xs:string,
$pipeline-id as xs:unsignedLong
)  as   empty-sequence()
Summary:

Add another pipeline to the set of pipelines bound to the domain. An error is raised if the domain cannot be found or the pipeline does not exist.

Parameters:
$domain-name : The name of the domain to be changed.
$pipeline-id : The unique id of the pipeline.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  dom:add-pipeline( "Incoming", 
		  p:get("Entity Extraction")/p:pipeline-id )
  

dom:collection(  ) as  xs:string
Summary:

Return the name of the collection in which domains are stored.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:collection()
      ==> returns "http://marklogic.com/cpf/domains"
  

dom:configuration-create(
$restart-user as xs:string,
$evaluation-context as element(dom:evaluation-context),
$default-domain as xs:unsignedLong,
$permissions as element(sec:permission)*
)  as   xs:unsignedLong
Summary:

Create a new CPF configuration.

Parameters:
$restart-user : The username for the user who runs the restart trigger.
$evaluation-context : The evaluation-context element (for example, from the output of dom:evaluation-context for the domain.
$default-domain : The ID of the default domain.
$permissions : Zero or more permissions elements.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-create( "admin", 
   dom:evaluation-context( xdmp:database("Modules"), "/" ),
   fn:data(dom:get("my-domain")/dom:domain-id), 
   (xdmp:permission('my-role', 'read'), 
   xdmp:permission('my-role', 'execute') )
)
  

dom:configuration-get(  ) as  element(dom:configuration)
Summary:

Returns the CPF configuration.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-get()
  

dom:configuration-set-default-domain(
$domain-id as xs:unsignedLong
)  as   empty-sequence()
Summary:

Set a new default domain for the CPF configuration.

Parameters:
$domain-id : The domain ID of the default domain.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-set-default-domain( 
   fn:data(dom:get("my-domain")/dom:domain-id) )
  

dom:configuration-set-evaluation-context(
$context as element(dom:evaluation-context)
)  as   empty-sequence()
Summary:

Set a new context for the CPF configuration. This will ripple down to the restart trigger as well.

Parameters:
$context : An evaluation-context element (for example, from the output of dom:evaluation-context.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-set-evaluation-context( 
     dom:evaluation-context( xdmp:database("Modules"), "/" ) )
  

dom:configuration-set-permissions(
$permissions as element(sec:permission)*
)  as   empty-sequence()
Summary:

Set new permissions for the CPF configuration. This will ripple down to the restart trigger as well.

Parameters:
$permissions : The permissions for the configuration.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-set-permissions( (xdmp:permission('my-role', 'read'), 
   xdmp:permission('my-role', 'execute') ) )
  

dom:configuration-set-restart-user(
$restart-user as xs:string
)  as   empty-sequence()
Summary:

Set a new restart user for the CPF configuration. This will ripple down to the restart trigger as well.

Parameters:
$restart-user : The username for the restart user.

Example:
xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

dom:configuration-set-restart-user( "admin" )
  

dom:create(
$name as xs:string,
$description as xs:string,
$scope as element(dom:domain-scope),
$context as element(dom:evaluation-context),
$pipelines as xs:unsignedLong*,
$permissions as element(sec:permission)*
)  as   xs:unsignedLong
Summary:

Create a new content processing domain, along with the triggers that perform work in that domain.

Parameters:
$name : The name of the domain. It must be unique.
$description : A description of the domain.
$scope : The scope of the domain. Create using dom:domain-scope.
$context : The evaluation context for processing actions. Create using dom:evaluation-context.
$pipelines : The unique identifiers of the pipelines to bind to this domain. The same pipeline can be bound to different domains. Until at least one pipeline is bound to the domain, no processing is defined for that domain.
$permissions : Permissions.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:create( "Incoming", "Handling incoming documents", 
              dom:domain-scope( "directory", 
                    "/incoming/", 
		    "infinity" ),
	      dom:evaluation-context( xdmp:database("Modules"), 
		                     "/" ),
              (), () )
  

dom:domain-scope(
$document-scope as xs:string,
$uri as xs:string,
$depth as xs:string?
)  as   element(dom:domain-scope)
Summary:

Create a domain scope element.

Parameters:
$document-scope : The way in which this domain scope is defined: "collection", "directory", or "document".
$uri : The URI defining the scoping. For a "collection" scope this will be the collection URI; for a "directory" scope this will be the URI of the directory (and must therefore end with a trailing slash); for a "document" scope this will be the URI of the document.
$depth : This parameter applies only to "directory" scopes and defines whether the scope is recursive ("infinity") or not ("0").

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:set-domain-scope( "Test", 
                       dom:domain-scope( "document", 
                          "http://example.com/test.xml", 
		          () )
  )
  

dom:domains(  ) as  element(dom:domain)*
Summary:

Return all the domains.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  for $domain in dom:domains()
  return $domain/dom:domain-name
  

dom:evaluation-context(
$database as xs:unsignedLong,
$root as xs:string
)  as   element(dom:evaluation-context)
Summary:

Create an evaluation context element.

Parameters:
$database : The unique identifier of the database in which the content processing actions will be executed. All the modules used in the content processing application must be in this database.
$root : A root path under which modules are located.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:set-evaluation-context( "Test", 
     dom:evaluation-context( xdmp:database("Modules"), "/" )
  )
  

dom:get(
$domain-name as xs:string
)  as   element(dom:domain)
Summary:

Find a particular domain.

Parameters:
$domain-name : The name of the domain to get. An error is raised if no such domain exists.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:get( "Incoming" )
  

dom:remove(
$domain-name as xs:string
)  as   empty-sequence()
Summary:

Remove the domain and any associated triggers. An error is raised if no such domain exists.

Parameters:
$domain-name : The name of the domain to remove.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:remove( "Incoming" )
  

dom:remove-permissions(
$domain-name as xs:string,
$permissions as element(sec:permission)*
)  as   empty-sequence()
Summary:

Remove permissions to the domain. An error is raised if the domain cannot be found. The triggers associated with the domain will be modified also.

Parameters:
$domain-name : The name of the domain to be changed.
$permissions : Permissions to remove.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:remove-permissions( "Incoming", 
		          xdmp:permission("development", "read") )
  

dom:remove-pipeline(
$domain-name as xs:string,
$pipeline-id as xs:unsignedLong
)  as   empty-sequence()
Summary:

Remove the association between a pipeline and the domain. An error is raised if the domain cannot be found. Only the association between the domain and the pipeline will be broken: the existing pipeline will not be deleted and may still be active in other domains.

Parameters:
$domain-name : The name of the domain to be changed.
$pipeline-id : The pipeline to be removed from the domain.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  dom:remove-pipeline("Incoming", p:get("My Pipeline")/p:pipeline-id)
  

dom:set-description(
$domain-name as xs:string,
$description as xs:string
)  as   empty-sequence()
Summary:

Set the description of the domain. An error is raised if the domain cannot be found.

Parameters:
$domain-name : The name of the domain to be changed.
$description : The new description of the domain.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:set-description( "Incoming", 
		       "Incoming document processing area" )
  

dom:set-domain-scope(
$domain-name as xs:string,
$scope as element(dom:domain-scope)
)  as   empty-sequence()
Summary:

Set the scope of the domain. An error is raised if the domain cannot be found. If the domain already has triggers associated with it, the triggers will be modified to act on the new scope as well.

Parameters:
$domain-name : The name of the domain to be changed.
$scope : The new scope of the domain. Create using dom:domain-scope.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:set-domain-scope( "Incoming", 
       dom:domain-scope( "directory", "/incoming/", "0" )
  )
  

dom:set-evaluation-context(
$domain-name as xs:string,
$context as element(dom:evaluation-context)
)  as   empty-sequence()
Summary:

Set the evaluation context of the domain. An error is raised if the domain cannot be found. If the domain already has triggers associated with it, the triggers will be modified to act in the new evaluation context.

Parameters:
$domain-name : The name of the domain to be changed.
$context : The new evaluation context of the domain. Create using dom:evaluation-context.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:set-evaluation-context( "Incoming", 
       dom:evaluation-context( xdmp:database("Modules"), "/apps/" )
  )
  

dom:set-name(
$domain-name as xs:string,
$new-name as xs:string
)  as   empty-sequence()
Summary:

Set the name of the domain to something else. An error is raised if a domain with the new name already exists or if the domain cannot be found.

Parameters:
$domain-name : The name of the domain whose name will be changed.
$new-name : The new name for this domain.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:set-name( "Test", "Incoming" )
  

dom:set-permissions(
$domain-name as xs:string,
$permissions as element(sec:permission)*
)  as   empty-sequence()
Summary:

Set the permissions of the domain. An error is raised if the domain cannot be found. If the triggers associated with the domain will be modified also.

Parameters:
$domain-name : The name of the domain to be changed.
$permissions : New permissions for the domain.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";

  dom:set-permissions( "Incoming", xdmp:default-permissions() )
  
  

dom:set-pipelines(
$domain-name as xs:string,
$pipelines as xs:unsignedLong*
)  as   empty-sequence()
Summary:

Bind a new set of pipelines to the domain. An error is raised if the domain cannot be found or any of the pipelines does not exist. If the domain already has pipelines associated with it, those existing pipelines will not be deleted; only the association will be broken.

Parameters:
$domain-name : The name of the domain to be changed.
$pipelines : The unique ids of the pipelines.

Example:
  xquery version "1.0-ml";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  dom:set-pipelines( "Incoming", (
     p:get("Status Change Handling")/p:pipeline-id,
     p:get("Basic Conversion")/p:pipeline-id ) )
  

excel:clean(
$uri as xs:string,
$doc as node()?
)  as   node()?
Summary:

Clean up any conversion artifacts or other infelicities, putting each sheet into its own div element.

Parameters:
$uri : The source URI of the converted spreadsheet.
$doc : The XHTML produced by conversion of a Microsoft Excel spreadsheet.

Example:
  xquery version "1.0-ml";
  import module namespace excel = "http://marklogic.com/cpf/excel" 
		  at "/MarkLogic/conversion/excel.xqy";

  excel:clean("my_xls.xhtml", fn:doc("my_xls.xhtml"))
  

lnk:create(
$from as xs:string,
$to as xs:string,
$role as xs:string,
$rev-role as xs:string,
$strength as xs:string
)  as   empty-sequence()
Summary:

Create a link between the two given documents with the given role labels and strength. An error is raised if either of the documents involved does not exist or if the link would be invalid for some reason. This function will replace any existing link between those two documents with the new link.

Parameters:
$from : The URI of the document at the tail of the link.
$to : The URI of the document at the head of the link.
$role : A label for the relationship of the head of the link to the tail of the link, one of "source", "consumer", "container", "variant", and "related".
$rev-role : A label for the reverse relationship of the tail of the link to the head of the link.
$strength : An indicator of the strength of the relationship between the two documents, either "strong" or "weak".

Example:
  xquery version "1.0-ml";
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy";

  lnk:create( "/myDocs/example.xhtml", "/myDocs/example.doc", 
              "source", "conversion", "strong" ) 
  

lnk:from(
$from as xs:string
)  as   element(lnk:link)*
Summary:

Find and return all the links from the given document to some other. This function will check the properties of the link and raise an error if they are inconsistent or incomplete in some way.

Parameters:
$from : The URI of the document at the tail of the link.

Example:
  xquery version "1.0-ml";
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy";

  for $link in lnk:from( "/myDocs/example.xhtml" )
  return $link/@to
  

lnk:get(
$from as xs:string,
$to as xs:string
)  as   element(lnk:link)?
Summary:

Find and return the link between the two documents, if any. This function will check the properties of link and raise an error if they are inconsistent or incomplete in some way.

Parameters:
$from : The URI of the document at the tail of the link.
$to : The URI of the document at the head of the link.

Example:
  xquery version "1.0-ml";
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy";

  lnk:get( "/myDocs/fr/example.xhtml", "/myDocs/example.xhtml" )
  

lnk:insert(
$link as element(lnk:link)
)  as   empty-sequence()
Summary:

Insert the given link. An error is raised if either of the documents involved does not exist or if the link is invalid in some way. This function will replace any existing link between those two documents.

Parameters:
$link : The link element.

Example:
  xquery version "1.0-ml";
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy";

  lnk:insert( lnk:get( "/myDocs/fr/example.xhtml", "/myDocs/example.xhtml" ) )
  

lnk:remove(
$from as xs:string,
$to as xs:string
)  as   element(lnk:link)
Summary:

Remove the link between the two given documents and return the removed link. An error is raised if no such link exists.

Parameters:
$from : The URI of the document at the tail of the link.
$to : The URI of the document at the head of the link.

Example:
  xquery version "1.0-ml";
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy";

  lnk:remove( "/myDocs/example.xhtml", "/myDocs/example.doc" )
  

lnk:to(
$to as xs:string
)  as   element(lnk:link)*
Summary:

Find and return all the links to the given document from some other. This function will check the properties of the link and raise an error if they are inconsistent or incomplete in some way.

Parameters:
$to : The URI of the document at the head of the link.

Example:
  xquery version "1.0-ml";
  import module namespace lnk = "http://marklogic.com/cpf/links" 
		  at "/MarkLogic/cpf/links.xqy";

  for $link in lnk:from( "/myDocs/example.xhtml" )
  return $link/@to
  

msword:clean(
$uri as xs:string,
$doc as node()?
)  as   node()
Summary:

Clean up any conversion artifacts or other infelicities.

Parameters:
$uri : The source URI of the converted document.
$doc : The XHTML produced by conversion of a Microsoft Word document.

Example:
  xquery version "1.0-ml";
  import module namespace msword = "http://marklogic.com/cpf/msword" 
		  at "/MarkLogic/conversion/msword.xqy";

  msword:clean("my_doc.xhtml",fn:doc("my_doc.xhtml"))
  

p:action(
$module as xs:string,
$description as xs:string?,
$options as element()?
)  as   element(p:action)
Summary:

Construct an action element.

Parameters:
$module : The path to the module to evaluate.
$description : A description of the action.
$options : The options element to pass to the module as the external variable $cpf:options. The options element will be in the namespace of the module.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  p:action("/app/process-workitem.xqy", (), () )
         ===> returns 
            <p:action xmlns:p="http:marklogic.com/cpf/pipelines">
               <p:module>/app/process-workitem.xqy</p:module>
            </p:action>
  

p:collection(  ) as  xs:string
Summary:

Return the name of the collection in which pipelines are stored.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  p:collection()
      ==> returns "http://marklogic.com/cpf/pipelines"
  

p:condition(
$module as xs:string,
$description as xs:string?,
$options as element()?
)  as   element(p:condition)
Summary:

Construct a condition element.

Parameters:
$module : The path to the module to evaluate.
$description : A description of the condition.
$options : The options element to pass to the module as the external variable $cpf:options. The options element will be in the namespace of the module.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  let $options := 
     <options xmlns="/app/test-root.xqy">
        <root>workitem</root>
     </options> 
  return p:condition("/app/test-root.xqy", (), $options )
         ===> returns 
            <p:condition xmlns:p="http:marklogic.com/cpf/pipelines">
               <p:module>/app/test-root.xqy</p:module>
               <options xmlns="/app/test-root.xqy">
                 <root>workitem</root>
               </options> 
            </p:condition>
  

p:create(
$name as xs:string,
$description as xs:string,
$success-action as element(p:action)?,
$failure-action as element(p:action)?,
$status-transitions as element(p:status-transition)*,
$state-transitions as element(p:state-transition)*
)  as   xs:unsignedLong
Summary:

Create a new content processing pipeline.

Parameters:
$name : The name of the pipeline. It must be unique.
$description : A description of the pipeline.
$success-action : The default action for successful transitions. If none is provided the system default success action will be used. Create using p:action.
$failure-action : The default action for failed transitions. If none is provided the system default failure action will be used. Create using p:action.
$status-transitions : Status transition definitions. There should be exactly one status transition for the statuses "created", "deleted", and "updated". Create using p:status-transition.
$state-transitions : State transition definitions. There should be at most one state transition for a given state. Create using p:state-transition.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  let $init-state := xs:anyURI("http://example.com/states/init")
  let $error-state := xs:anyURI("http://example.com/states/error")
  return
  p:create( "Empty", "No nothing much", (), (), 
            ( p:status-transition("created", "", 
                                  $init-state, 
				  $error-state, 
				  (), (), () ),
	      p:status-transition("deleted", "", 
	                          (), 
	                          $error-state, 
				  (), (), () ),
	      p:status-transition("updated", "", 
				  (), 
				  $error-state, 
				  (), (), () )
             ), ()
          )
  

p:execute(
$condition as element(p:condition)?,
$action as element(p:action)?,
$description as xs:string?
)  as   element(p:execute)
Summary:

Construct a execute element.

Parameters:
$condition : The condition to execute to test whether this rule applies. If no condition is specified, the action always executes.
$action : The action to execute should this rule apply. If no action is specified, the default success action will execute instead.
$description : A description of the rule.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  let $options := 
     <options xmlns="/app/test-root.xqy">
        <root>workitem</root>
     </options> 
  return 
  p:execute( p:condition("/app/test-root.xqy", (), $options ), (),
             "Execute default action on workitems."
           )
  

p:get(
$pipeline-name as xs:string
)  as   element(p:pipeline)
Summary:

Find a particular pipeline.

Parameters:
$pipeline-name : The name of the pipeline to get. An error is raised if no such pipeline exists.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  p:get( "Link Maintenance" )
  

p:get-by-id(
$pipeline-id as xs:unsignedLong
)  as   element(p:pipeline)
Summary:

Find a particular pipeline.

Parameters:
$pipeline-id : The ID of the pipeline to get. An error is raised if no such pipeline exists.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";
  import module namespace dom = "http://marklogic.com/cpf/domains" 
		  at "/MarkLogic/cpf/domains.xqy";
          
  p:get-by-id( dom:get("Default Domain")/dom:pipeline[1] )
  

p:insert(
$pipeline-node as node()
)  as   xs:unsignedLong
Summary:

Insert a fully constructed content processing pipeline, returning its unique ID. If a pipeline with the same name already exists in the database, it is replaced.

Parameters:
$pipeline-node : The pipeline definition. Any pipeline-id element will be ignored.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  p:insert( xdmp:get("/pipelines/myapp.xml")/* )
  

p:pipelines(  ) as  element(p:pipeline)*
Summary:

Return all the pipelines.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  for $pipeline in p:pipelines()
  return $pipeline/p:pipeline-name
  

p:remove(
$pipeline-name as xs:string
)  as   empty-sequence()
Summary:

Remove the named pipeline. An error is raised if no such pipeline exists.

Parameters:
$pipeline-name : The name of the pipeline to remove.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  p:remove( "Empty" )
  

p:state-transition(
$state as xs:anyURI,
$description as xs:string,
$on-success as xs:anyURI?,
$on-failure as xs:anyURI?,
$priority as xs:unsignedLong?,
$default-action as element(p:action)?,
$rules as element(p:execute)*
)  as   element(p:state-transition)
Summary:

Construct a new state transition element.

Parameters:
$state : The name of the state.
$description : A description of the transition.
$on-success : The successor state, should the transition succeed. If no successor state is defined, the document will remain in its current state.
$on-failure : The successor state, should the transition fail. If no successor state is defined, the document will remain in its current state.
$priority : The priority for this transition. Higher priority transitions will be examined before lower priority ones. If no priority is passed, then the transition gets the highest priority.
$default-action : The default action to execute on entry into this state, if none of the rules apply.
$rules : The execution rules to apply in this transition. The first rule whose condition is true will have its action executed.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  p:state-transition( xs:anyURI("http://example.com/states/review"),
                      "Document review state", 
                      (), xs:anyURI("http://example.com/states/error"), (),
                      p:action("/app/send-to-reviewer.xqy",(), ()),
                      () )
  

p:status-transition(
$status as xs:string,
$description as xs:string,
$on-success as xs:anyURI?,
$on-failure as xs:anyURI?,
$priority as xs:unsignedLong?,
$default-action as element(p:action)?,
$rules as element(p:execute)*
)  as   element(p:status-transition)
Summary:

Construct a new status transition element.

Parameters:
$status : The status: either "created", "updated", or "deleted".
$description : A description of the transition.
$on-success : The successor state, should the transition succeed. If no successor state is defined, the document will remain in its current state.
$on-failure : The successor state, should the transition fail. If no successor state is defined, the document will remain in its current state.
$priority : The priority for this transition. Higher priority transitions will be examined before lower priority ones. If no priority is passed, then the transition gets the highest priority.
$default-action : The default action to execute on entry into this status, if none of the rules apply.
$rules : The execution rules to apply in this transition. The first rule whose condition is true will have its action executed.

Example:
  xquery version "1.0-ml";
  import module namespace p = "http://marklogic.com/cpf/pipelines" 
		  at "/MarkLogic/cpf/pipelines.xqy";

  p:status-transition("created", 
                      "Document creation: Put in initial state.",
                      xs:anyURI("http://example.com/states/initial"), (), (),
                      (), () )
  

pdf:clean(
$doc as node()?,
$toc as element()?
)  as   node()?
Summary:

Clean up any conversion artifacts or other infelicities.

Parameters:
$doc : The XHTML produced by conversion of a PDF document.
$toc : The TOC produced by conversion of a PDF document.

Example:
  xquery version "1.0-ml";
  import module namespace pdf = "http://marklogic.com/cpf/pdf" 
		  at "/MarkLogic/conversion/pdf.xqy";

  pdf:clean(fn:doc("my_pdf.xhtml"), pdf:get-toc("my_pdf.xhtml"))
  

pdf:get-toc(
$uri as xs:string
)  as   element()?
Summary:

Fetch the linked TOC, if any.

Parameters:
$uri : The URI of the converted PDF document.

Example:
  xquery version "1.0-ml";
  import module namespace pdf = "http://marklogic.com/cpf/pdf" 
		  at "/MarkLogic/conversion/pdf.xqy";

  pdf:get-toc("my_pdf.xhtml")
  

pdf:insert-toc-headers(
$doc as node()?,
$toc as element()?
)  as   node()?
Summary:

Locate TOC anchors and make them properly refer to headers at the appropriate level. Returned the transformed document.

Parameters:
$doc : The cleaned XHTML produced by PDF conversion.
$toc : The normalized TOC.

Example:
  xquery version "1.0-ml";
  import module namespace pdf = "http://marklogic.com/cpf/pdf" 
		  at "/MarkLogic/conversion/pdf.xqy";

  xdmp:document-insert( "myfile.xhtml", 
         pdf:insert-toc-headers( doc("myfile.xhtml"), 
                                 pdf:get-toc("myfile.xhtml") )
  )
  

pdf:make-toc(
$toc as element()?
)  as   element()?
Summary:

Clean and normalize the TOC produced by raw conversion.

Parameters:
$toc : The raw TOC element.

Example:
  xquery version "1.0-ml";
  import module namespace pdf = "http://marklogic.com/cpf/pdf" 
		  at "/MarkLogic/conversion/pdf.xqy";

  let $results := 
     xdmp:pdf-convert( xdmp:get("/myfiles/myfile.pdf"), "myfile.pdf" )
  let $manifest := $results[1]
  let $toc := 
      for $doc at $index in $results[2 to last()]
      let $name := string($manifest/*[$index])
      where fn:matches( $name, "toc.xml" )
      return $doc
  return pdf:make-toc( $toc )
  

ppt:clean(
$uri as xs:string,
$doc as node()?
)  as   node()
Summary:

Clean up any conversion artifacts or other infelicities, putting each slide into its own div element.

Parameters:
$uri : The source URI of the converted presentation.
$doc : The XHTML produced by conversion of a Microsoft Powerpoint presentation.

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

  ppt:clean("my_ppt.xhtml",fn:doc("my_ppt.xhtml"))
  

xhtml:add-lists(
$doc as node()?
)  as   node()?
Summary:

Infer numbered or bulleted lists and insert appropriate markup. Restructuring first is highly recommended to improve both accuracy and performance. This function also assumes that indentation styling is already present on the paragraphs in the original input.

Parameters:
$doc : The source XHTML.

Example:
  xquery version "1.0-ml";
  declare default element namespace "http://www.w3.org/1999/xhtml";

  import module namespace xhtml = "http://marklogic.com/cpf/xhtml" 
		  at "/MarkLogic/conversion/xhtml.xqy";

  let $raw :=
     <html>
       <head><title>Example</title></head>
       <body>
          <div class="mlsection1">
            <h1>Section header</h1>
            <p>1. First paragraph.</p>
            <p>2. Second paragraph.</p>
            <p>a. Sub-topic 1.</p>
            <p>b. Sub-topic 1.</p>
            <p>3. Third paragraph</p>
            <div class="mlsection2">
              <h2>Subheader</h2>
              <p>1. Sub paragraph.</p>
            </div>
          </div>
       </body>
     </html>
  return xhtml:add-lists( $raw )

  Returns:
     <html>
       <head><title>Example</title></head>
       <body>
          <div class="mlsection1">
            <h1>Section header</h1>
            <ol style="list-style-type: none; margin-left: 0pt">
              <li>1. First paragraph.</li>
              <li>2. Second paragraph.</li>
              <ol style="list-style-type: none; margin-left: 0pt">
                <li>a. Sub-topic 1.</li>
                <li>b. Sub-topic 1.</li>
              </ol>
              <li>3. Third paragraph</li>
            </ol>
            <div class="mlsection2">
              <h2>Subheader</h2>
              <p>1. Sub paragraph.</p>
            </div>
          </div>
       </body>
     </html>
  

xhtml:clean(
$doc as node()?
)  as   node()?
Summary:

Clean up the XHTML: pruning empty spans, consolidating adjacent spans, etc.

Parameters:
$doc : The source XHTML.

Example:
  xquery version "1.0-ml";
  import module namespace xhtml = "http://marklogic.com/cpf/xhtml" 
		  at "/MarkLogic/conversion/xhtml.xqy";

  xhtml:clean(fn:doc("my.xhtml"))
  

xhtml:restructure(
$doc as node()?
)  as   node()?
Summary:

Turn an XHTML with flat structure into one with div structure based on the header elements.

Parameters:
$doc : The source XHTML.

Example:
  xquery version "1.0-ml";
  declare default element namespace "http://www.w3.org/1999/xhtml";

  import module namespace xhtml = "http://marklogic.com/cpf/xhtml" 
		  at "/MarkLogic/conversion/xhtml.xqy";

  let $unstructured :=
     <html>
       <head><title>Example</title></head>
       <body>
          <h1>First section</h1>
          <p>First paragraph.</p>
          <p>Second paragraph.</p>
          <h2>Subheader</h2>
          <p>Sub paragraph.</p>
          <h1>Second section</h1>
          <p>Last paragraph.</p>
       </body>
     </html>
  return xhtml:restructure( $unstructured )

  Returns:
    <html>
      <head><title>Example</title></head>
      <body>
         <div class="mlsection1">
           <h1>First section</h1>
           <p>First paragraph.</p>
           <p>Second paragraph.</p>
           <div class="mlsection2">
             <h2>Subheader</h2>
             <p>Sub paragraph.</p>
           </div>
         </div>
         <div class="mlsection1">
           <h1>Second section</h1>
           <p>Last paragraph.</p>
         </div>
      </body>
    </html>