| XQUERY/XSLT API DOCUMENTATION 4.2 |
All XQuery & XSLT Functions MarkLogic Built-In Functions Admin (xdmp:) AppServer (xdmp:) Classifier (cts:) Debug (dbg:) Document Conversion (xdmp:) Extension (xdmp:) Documents, Directories, Properties, and Locks Functions Extension Functions Function Values Functions HTTP Functions JSON Functions MarkLogic Server Functions Search Functions XML Functions XQuery Context Functions XSLT Functions map (map:) Math (math:) Profile (prof:) Search (cts:) cts:query Constructors Functions Geospatial Functions Geospatial Lexicon Functions Lexicon Functions Search Functions Search Clustering Functions Security (xdmp:) Server Monitoring (xdmp:) Spell (spell:) Update (xdmp:) XQuery Library Modules Admin Library (admin:) Actions Functions Appserver Functions Database Functions Forest Functions Group Functions Host Functions Mimetypes Functions Scheduler Functions Alerting (alert:) Elastic Compute Cloud (ec2:) Entity Enrichment (entity:) Flexible Replication (flexrep:) Geospatial Supporting Functions GEO Functions GeoRSS Functions GML Functions KML Functions MCGM Functions Information Studio (info:) Information Studio Developer (infodev:) Library Services (dls:) cts:query Constructor Functions Document Management Functions Document Update Functions Retention Policy Functions XInclude Functions Modular Documents XInclude Functions XPointer Functions PKI (pki:) Plugin (plugin:) Search (search:) Security-sec (sec:) Spelling Dictionary Management (spell:) Thesaurus (thsr:) Triggers (trgr:) Triggers Library (trgr:) WordProcessingML (ooxml:) ZIP Package (ooxml:) CPF Functions Content Processing Framework (cpf:) CSS Conversion (css:) DocBook Conversion (dbk:) Domains (dom:) Excel Conversion (excel:) Generic Conversion (cvt:) Links (lnk:) MSWord Conversion (msword:) PDF Conversion (pdf:) Pipelines (p:) Powerpoint Conversion (ppt:) XHTML Conversion (xhtml:) W3C-Standard Functions Accessor (fn:) AnyURI (fn:) Boolean (fn:) Context (fn:) DurationDateTime (fn:) Error and Trace (fn:) Node (fn:) Numeric (fn:) QName (fn:) Sequence (fn:) String (fn:) XSLT (fn:) W3C XQuery/XSLT Reference W3C XQuery Functions W3C XQuery Language W3C XSLT Language
This page was generated September 12, 2012 6:02 AM | XQuery & XSLT Built-In & Modules Function Reference
Built-In: XSLT
The XSLT functions. These functions are available in XSLT only. They are defined in XSL Transformations (XSLT) Version 2.0.
Function Summary
fn:current | Returns the item that was the context item at the point where the expression was invoked from the XSLT stylesheet.
fn:current-group | Returns the current regex group.
fn:current-grouping-key | Returns the current regex grouping key.
fn:document | Returns the document(s) stored in the database at the specified URI(s).
fn:element-available | Returns true if and only if the name of an XSLT instruction is passed in.
fn:format-number | Returns a formatted string representation of value argument based on the supplied picture.
fn:function-available | Returns true if and only if there is a function whose name and optionally arity matches the value of the $function-name and the optional $arity arguments.
fn:key | The key function does for keys what the id function does for IDs.
fn:regex-group | While the xsl:matching-substring instruction is active, a set of current captured substrings is available, corresponding to the parenthesized sub-expressions of the regular expression.
fn:system-property | Returns a string representing the value of the system property identified by the name.
fn:type-available | Returns true if and only if there is a type whose name matches the value of the $type-name argument is present in the static context.
fn:unparsed-entity-public-id | Returns the public identifier of the unparsed entity specified by the $entity-name parameter.
fn:unparsed-entity-uri | Always returns the zero length string.
fn:unparsed-text | Reads a file stored in the database as either text or binary file and returns its contents as a string.
fn:unparsed-text-available | Returns true if a call to unparsed-text would succeed with identical arguments.
Function Detail
fn:current( ) as item()
Summary: Returns the item that was the context item at the point where the expression was invoked from the XSLT stylesheet. This function is only available in XSLT; it is not available in XQuery.
Example:
    xquery version "1.0-ml";

    xdmp:xslt-eval(
    <xsl:stylesheet version="2.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="/">
       <xsl:value-of select="node-name(current()/element())"/>
     </xsl:template>
    </xsl:stylesheet>,
    document{<foo>hello there</foo>})

    => foo
fn:current-group( ) as item()*
Summary: Returns the current regex group. This function is only available in XSLT; it is not available in XQuery.
Example: See the examples in the Grouping section of the XSLT Specification.
fn:current-grouping-key( ) as xs:anyAtomicType?
Summary: Returns the current regex grouping key. This function is only available in XSLT; it is not available in XQuery.
Example: See the examples in the Grouping section of the XSLT Specification.
fn:document(
| $uris as item()*,
| [$base-node as node()]
) as document-node()*
Summary: Returns the document(s) stored in the database at the specified URI(s). The URI(s) are resolved according to the base-uri of the calling stylesheet or XQuery main module. This is an XSLT function, and it is available in both XSLT and in XQuery 1.0-ml.
Parameters:
$uris : The $uris is a sequence of the URI(s) of the document(s) to be retrieved. This parameter is mandatory. However you may pass a singleton sequence with an empty string in it. In that case it will return the stylesheet that contains this function call when called from XSLT stylesheet and all the documents in the database when called from XQuery- this is allowed only when you are not using version 1.0 strict. If any URI in this sequence is an absolute URI, then it is used as is. If it is a relative URI, it is resolved against a base URI specified in the second argument.
$base-node (optional): If $base-node is supplied, its base URI is used to resolve relative URIs in uri-sequence. If it is not supplied, the base URI of the node that contained the fn:document() call is used.
Usage Notes: If no second argument is specified, the URI resolves using the base-uri of the calling module. This can cause surprising results if the URI you are resolving is not rooted but the module from which you call it has a base-uri. When calling `fn:document` from an `xdmp:eval`, the calling module is defined to have no base-uri. When calling from an XQuery module or an XSLT stylesheet, the base-uri is the URI of the module or stylesheet. For an example to demonstrate this , see the second example below. For the URI to be exactly what you enter, use `fn:doc` instead.
Example:
    fn:document(("/product.xml", "/price.xml"),
                < a xml:base="http://www.marklogic.com" />)
Example:
    xquery version "1.0-ml";
    (:
      This module should be at the App Server root with a name test.xqy,
      so it resolves to /test.xqy from the App Server's root.
    :)
    xdmp:set-response-content-type("text/plain"),

    xdmp:document-insert("testing.xml", <foo/>);
    xdmp:document-insert("/testing.xml", <bar/>);

    declare option xdmp:output "indent-untyped=yes";

    <root>
      <document-from-module>
         <document>{fn:document("testing.xml")}</document>
      </document-from-module>
      <document-from-eval>
         <document>{xdmp:eval('fn:document("testing.xml")')}</document>
      </document-from-eval>
    </root>

    (:
      From the module, the document cannot find the URI "testing.xml"
      because the base-uri of the module is its URI relative to the
      App Server root.  It therefore finds /testing.xml because that is what
      the URI testing.xml resolves to (testing.xml resolves to /testing.xml when
      the base-uri is /test.xqy).  From an eval, there is no base-uri, so
      it can find an unrooted URI (testing.xml resolves to testing.xml when the
      base-uri is empty).
    :)

    =>
    <root>
      <document-from-module>
        <document>
          <bar/>
        </document>
      </document-from-module>
      <document-from-eval>
        <document>
          <foo/>
        </document>
      </document-from-eval>
    </root>
fn:element-available(
| $element-name as xs:string
) as xs:boolean
Summary: Returns true if and only if the name of an XSLT instruction is passed in. This function is only available in XSLT; it is not available in XQuery.
Parameters:
$element-name : The name of the element to test.
Example:
    xquery version "1.0-ml";

    xdmp:xslt-eval(
    <xsl:stylesheet version="2.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="foo">
       <xsl:value-of
            select="element-available('xsl:apply-templates')"/>
     </xsl:template>
    </xsl:stylesheet>,
    document{<foo>hello there</foo>})

    => true
fn:format-number(
| $value as numeric,
| $picture as xs:string,
| [$decimal-format-name as xs:string]
) as xs:string
Summary: Returns a formatted string representation of value argument based on the supplied picture. An optional decimal format name may also be supplied for interpretation of the picture string. This is an XSLT function, and it is available in both XSLT and in XQuery 1.0-ml.
Parameters:
$value : The given numeric `$value` that needs to be formatted. The type of this argument must be a numeric type (for example, xs:integer, xs:float, xs:double, or xs:decimal).
$picture : The desired string representation of the given number `$value`. The picture string is a sequence of characters, in which the characters represent variables such as, decimal-separator-sign, grouping-sign, zero-digit-sign, digit-sign, pattern-separator, percent sign and per-mille-sign. For details on the picture string, see http://www.w3.org/TR/xslt20/#date-picture-string.
$decimal-format-name (optional): Represents a named `<xsl:decimal-format>` instruction. It is used to assign values to the variables mentioned above based on the picture string.
Example:
    xquery version "1.0-ml";

    fn:format-number(xs:integer("1000000"),"#,##0.00")
    =>
    1,000,000.00
Example:
    xquery version "1.0-ml";

    let $stylesheet :=
    <xsl:stylesheet version="2.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xsl:decimal-format name="testformat" decimal-separator="."/>
        <xsl:template match="foo">
          <xsl:sequence select="format-number(xs:float('1234.5'), '#,##0.00',
                                'testformat')"/>
        </xsl:template>
    </xsl:stylesheet>
    return
    xdmp:xslt-eval($s, document{<foo/>})
    =>
    1,234.50
fn:function-available(
| $function-name as xs:string,
| [$arity as xs:integer]
) as xs:boolean
Summary: Returns true if and only if there is a function whose name and optionally arity matches the value of the $function-name and the optional $arity arguments. This is an XSLT function, and it is available in both XSLT and in XQuery 1.0-ml.
Parameters:
$function-name : The $function-name is a string containing a lexical QName. It may be a name of a builtin-type, type imported using xsl:import-schema, or an extension type. This parameter is mandatory. The lexical QName is expanded using the namespace declarations in scope for the expression. If the lexical QName is unprefixed, then the standard function namespace is used in the expanded QName.
$arity (optional): If $arity parameter is present, then the function returns true if and only if the function specified by the first argument has a signature that takes $arity number of arguments.
Example:
    fn:type-available(xs:integer)
fn:key(
| $key-name as xs:string,
| $key-value as xs:string,
| [$top as node()]
) as node()*
Summary: The key function does for keys what the id function does for IDs. This function is only available in XSLT; it is not available in XQuery.
Parameters:
$key-name : The name of the key.
$key-value : The value of the key.
$top (optional): The subtree to limit the results to.
Example: See the examples in the Keys section of the XSLT Specification.
fn:regex-group(
| $group-number as xs:integer
) as xs:string
Summary: While the `xsl:matching-substring` instruction is active, a set of current captured substrings is available, corresponding to the parenthesized sub-expressions of the regular expression. These captured substrings are accessible using the function regex-group. This function takes an integer argument to identify the group, and returns a string representing the captured substring. This function is only available in XSLT; it is not available in XQuery.
Parameters:
$group-number : The group number to return.
Usage Notes: The function returns the zero-length string if there is no captured substring with the relevant number. This can occur for a number of reasons: The number is negative. The regular expression does not contain a parenthesized sub-expression with the given number. The parenthesized sub-expression exists, and did not match any part of the input string. The parenthesized sub-expression exists, and matched a zero-length substring of the input string.
Example: See the examples in the `xsl:analyze-string` section of the XSLT Specification.
fn:system-property(
| $property-name as xs:string
) as xs:string
Summary: Returns a string representing the value of the system property identified by the name. If there is no such system property, the zero-length string is returned. This function is only available in XSLT; it is not available in XQuery.
Parameters:
$property-name : The name of the property whose value is to be returned. Valid names are: xsl:version xsl:vendor xsl:vendor-url xsl:product-name xsl:product-version xsl:is-schema-aware xsl:supports-serialization xsl:supports-backwards-compatibility xsl:supports-namespace-axis
Example:
    xquery version "1.0-ml";

    xdmp:xslt-eval(
    <xsl:stylesheet version="2.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="foo">
       <xsl:value-of select="system-property('xsl:is-schema-aware')"/>
     </xsl:template>
    </xsl:stylesheet>,
    document{<foo>hello there</foo>})

    => yes
fn:type-available(
| $type-name as xs:string
) as xs:boolean
Summary: Returns true if and only if there is a type whose name matches the value of the $type-name argument is present in the static context. This is an XSLT function, and it is available in both XSLT and in XQuery 1.0-ml.
Parameters:
$type-name : The $type-name is a string containing a lexical QName. It may be a name of a builtin-type, type imported using xsl:import-schema, or an extension type. This parameter is mandatory. The lexical QName is expanded using the namespace declarations in scope for the expression. If the lexical QName is unprefixed, then the default namespace is used in the expanded QName.
Example:
    fn:type-available(xs:integer)
fn:unparsed-entity-public-id(
| $entity-name as xs:string
) as xs:string
Summary: Returns the public identifier of the unparsed entity specified by the $entity-name parameter. If no such entity exists or if the entity has no public identifier, this function returns the empty string. This function is only available in XSLT; it is not available in XQuery.
Parameters:
$entity-name : The entity name.
Example: See the XSLT Specification.
fn:unparsed-entity-uri(
| $entity-name as xs:string
) as xs:anyURI
Summary: Always returns the zero length string. This function is only available in XSLT; it is not available in XQuery.
Parameters:
$entity-name : The entity name.
Example: See the XSLT Specification.
fn:unparsed-text(
| $href as xs:string,
| [$encoding as xs:string]
) as xs:string?
Summary: Reads a file stored in the database as either text or binary file and returns its contents as a string.
Parameters:
$href : The $href is a string containing a URI reference. It must identify a resource that can be read as text. If the URI is a relative URI then it is resolved relative to the base URI from the static context.
$encoding (optional): If $encoding parameter is present and the URI points to a "text" file, the encoding is ignored since all the files are in UTF-8 in the database. However, if the URI points to a binary file, then an attempt is made to convert it from the specified encoding and the string value of the results of the conversion is returned. If the conversion fails, an exception is returned. The $encoding parameter must be passed when the URI resolves to a binary resource. An automatic encoding detector will be used if the value `auto` is specified. If $encoding is not present, the encoding defaults to UTF-8.
Example:
    fn:unparsed-text("http://marklogic.com/test.xml","UTF-8")
fn:unparsed-text-available(
| $href as xs:string,
| [$encoding as xs:string]
) as xs:boolean
Summary: Returns true if a call to unparsed-text would succeed with identical arguments.
Parameters:
$href : The $href is a string containing a URI reference. It must identify a resource that can be read as text. If the URI is a relative URI then it is resolved relative to the base URI from the static context.
$encoding (optional): If $encoding parameter is present and the URI points to a "text" file, the encoding is ignored since all the files are in UTF-8 in the database. However, if the URI points to a binary file, then an attempt will be made to convert it to the specified encoding and if the conversion succeeds it returns true. If the conversion fails, an exception is returned. The $encoding parameter must be passed when the URI resolves to a binary resource.
Example:
    fn:unparsed-text-available("http://marklogic.com/test.xml","UTF-8")

© Copyright 2002-2012 MarkLogic Corporation. All rights reserved.