
Module: CPF Functions
|
|
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.
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 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 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 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 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 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.
|
|
|
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: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, () )
|
|
|
|
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()] )
|
|
|
|
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: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"),
"/" ),
(), () )
|
|
|
|
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" )
|
|
|
|
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: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"), (), (),
(), () )
|
|
|
|
|