MarkLogic Server
XQUERY API DOCUMENTATION
3.2
This page was generated
January 5, 2009
5:42 PM
XQuery Built-In and Modules Function Reference

Module: Generic Conversion

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.

Function Summary
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.
Function Detail
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:
  import module namespace cvt = "http://marklogic.com/cpf/convert" 
		  at "/MarkLogic/conversion/convert.xqy"

  cvt:basename( "http://example.com/a.path/myfile.doc" ) 
     Returns "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:
  import module namespace cvt = "http://marklogic.com/cpf/convert" 
		  at "/MarkLogic/conversion/convert.xqy"

  cvt:basepath( "http://example.com/a.path/myfile.doc" ) 
     Returns "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:
  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")
     Returns "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:
  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()*
)  as   empty()
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.

Example:
  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()] )