This page was generated
July 7, 2010
4:02 PM
XQuery Built-In and Modules Function Reference

Module: Admin Library - Mimetypes Functions

The Admin module is an XQuery library module that allows you to script administrative tasks that you otherwise would need the Admin Interface to perform. Most functions in this library perform adminstrative tasks and therefore require the user who runs the XQuery program to have the Admin role.

Many of these functions provide new configuration information. In most cases, you must save the configuration (with admin:save-configuration, for example) in the same statement that you use the functions in order for them to take effect.

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

import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"

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

Function Summary
admin:mimetype This function constructs a mimetype specification.
admin:mimetypes-add This function adds mimetypes to the configuration.
admin:mimetypes-delete This function deletes mimetypes from the configuration.
admin:mimetypes-get This function returns all the mimetypes from the configuration.
Function Detail
admin:mimetype(
$name as xs:string,
$extensions as xs:string,
$format as xs:string
)  as  element(mt:mimetype)
Summary:

This function constructs a mimetype specification.

Parameters:
$name : The name of the mimetype.
$extensions : The extension(s) for the mimetype.
$format : A valid format for the mimetype. Must be on of: binary,xml, or text.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";
    
  admin:mimetype("application/foo","foo,bar","binary")
  (: returns the mimetype specification :)  

  

admin:mimetypes-add(
$config as element(configuration),
$mimetypes as element(mt:mimetype)*
)  as  element(configuration)
Summary:

This function adds mimetypes to the configuration. This function always requires a server restart to take effect.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$mimetypes : A mimetype specification, typically the result of an admin:mimetype call.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";
    
  let $config := admin:get-configuration()
  let $mimetype := admin:mimetype("application/foo","foo,bar","binary")
  return
  admin:mimetypes-add($config, $mimetype)
  (: returns the new configuration element -- use admin:save-configuration
     to save the changes to the configuration or pass the configuration
     to other Admin API functions to make other changes.  :)  

  

admin:mimetypes-delete(
$config as element(configuration),
$mimetypes as element(mt:mimetype)*
)  as  element(configuration)
Summary:

This function deletes mimetypes from the configuration. This function always requires a server restart to take effect.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$mimetypes : A mimetype specification, typically the result of an admin:mimetype call.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";
    
  let $config := admin:get-configuration()
  let $mimetype := admin:mimetype("application/foo","foo,bar","binary")
  return
  admin:mimetypes-delete($config, $mimetype)
  (: returns the new configuration element -- use admin:save-configuration
     to save the changes to the configuration or pass the configuration
     to other Admin API functions to make other changes.  :)  

  

admin:mimetypes-get(
$config as element(configuration)
)  as  element(mt:mimetype)*
Summary:

This function returns all the mimetypes from the configuration.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";
    
  let $config := admin:get-configuration()
  return
  admin:mimetypes-get($config)
  (: returns the mimetypes specifications for the cluster :)