| 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:01 AM | XQuery & XSLT Built-In & Modules Function Reference
Built-In: QName
These built-in functions are XQuery functions defined to operate on qualified name (xs:QName) values. They are defined in XQuery 1.0 and XPath 2.0 Functions and Operators.
Function Summary
fn:expanded-QName | [0.9-ml only, use fn:QName instead] Returns an xs:QName with the namespace URI given in $paramURI and the local name in $paramLocal.
fn:in-scope-prefixes | Returns the prefixes of the in-scope namespaces for $element.
fn:local-name-from-QName | Returns an xs:NCName representing the local part of $arg.
fn:namespace-uri-for-prefix | Returns the namespace URI of one of the in-scope namespaces for $element, identified by its namespace prefix.
fn:namespace-uri-from-QName | Returns the namespace URI for $arg as an xs:string.
fn:prefix-from-QName | Returns an xs:NCName representing the prefix of $arg.
fn:QName | Returns an xs:QName with the namespace URI given in $paramURI.
fn:resolve-QName | Returns an xs:QName value (that is, an expanded QName) by taking an xs:string that has the lexical form of an xs:QName (a string in the form "prefix:local-name" or "local-name") and resolving it using the in-scope namespaces for a given element.
Function Detail
fn:expanded-QName(
| $paramURI as xs:string?,
| $paramLocal as xs:string
) as xs:QName
Summary: [0.9-ml only, use `fn:QName` instead] Returns an `xs:QName` with the namespace URI given in $paramURI and the local name in $paramLocal. If $paramURI is the zero-length string or the empty sequence, it represents "no namespace".
Parameters:
$paramURI : A namespace URI, as a string.
$paramLocal : A localname, as a string.
Example:
    (: this function only exists in 0.9-ml :)
    xquery version "0.9-ml"
    fn:expanded-QName("http://www.example.com/example", "person")

    => an xs:QName with namespace URI =
       "http://www.example.com/example",
       local name = "person".
fn:in-scope-prefixes(
| $element as element()
) as xs:string*
Summary: Returns the prefixes of the in-scope namespaces for $element. For namespaces that have a prefix, it returns the prefix as an xs:NCName. For the default namespace, which has no prefix, it returns the zero-length string.
Parameters:
$element : The element whose in-scope prefixes will be returned.
Example:
    xquery version "0.9-ml"
    declare namespace a="a"
    declare namespace b="b"

    let $x := <a:hello>hello
                <b:goodbye>goodbye</b:goodbye>
    	  </a:hello>
    return
    fn:in-scope-prefixes($x)

    => a

    xquery version "0.9-ml"
    declare namespace a="a"
    declare namespace b="b"

    let $x := <a:hello>hello
                <b:goodbye>goodbye</b:goodbye>
    	  </a:hello>
    return
    fn:in-scope-prefixes($x/b:goodbye)

    => b a
fn:local-name-from-QName(
| $arg as xs:QName?
) as xs:NCName?
Summary: Returns an `xs:NCName` representing the local part of $arg. If $arg is the empty sequence, returns the empty sequence.
Parameters:
$arg : A qualified name.
Example:
    fn:local-name-from-QName(
       fn:QName("http://www.example.com/example", "person") )

    => person
fn:namespace-uri-for-prefix(
| $prefix as xs:string?,
| $element as element()
) as xs:anyURI?
Summary: Returns the namespace URI of one of the in-scope namespaces for $element, identified by its namespace prefix. If $element has an in-scope namespace whose namespace prefix is equal to $prefix, it returns the namespace URI of that namespace. If $prefix is the zero-length string or the empty sequence, it returns the namespace URI of the default (unnamed) namespace. Otherwise, it returns the empty sequence. Prefixes are equal only if their Unicode code points match exactly.
Parameters:
$prefix : A namespace prefix to look up.
$element : An element node providing namespace context.
Example:
    xquery version "0.9-ml"
    declare namespace ex="http://www.example.com/example"

    let $x := <ex:hello>1</ex:hello>
    return
    fn:namespace-uri-for-prefix("ex", $x)

    => the namespace URI corresponding to
       "http://www.example.com/example".
fn:namespace-uri-from-QName(
| $arg as xs:QName?
) as xs:anyURI?
Summary: Returns the namespace URI for $arg as an `xs:string`. If $arg is the empty sequence, the empty sequence is returned. If $arg is in no namespace, the zero-length string is returned.
Parameters:
$arg : A qualified name.
Example:
    fn:namespace-uri-from-QName(
      fn:QName("http://www.example.com/example", "person") )

    => the namespace URI corresponding to
       "http://www.example.com/example".
fn:prefix-from-QName(
| $arg as xs:QName?
) as xs:NCName?
Summary: Returns an `xs:NCName` representing the prefix of $arg. The empty sequence is returned if $arg is the empty sequence or if the value of $arg contains no prefix.
Parameters:
$arg : A qualified name.
Example:
    xquery version "1.0-ml";
    declare namespace ex="http://www.example.com/example";

    fn:prefix-from-QName(
       fn:QName("http://www.example.com/example", "person") )

    => empty sequence, because the QName constructed
       by fn:QName does not have a prefix
Example:
    let $qn := fn:QName("http://www.w3.org/XML/1998/namespace", "lang")
    return
    fn:prefix-from-QName(fn:node-name( attribute {$qn} {"en"}))

    => xml
fn:QName(
| $paramURI as xs:string?,
| $paramQName as xs:string
) as xs:QName
Summary: Returns an `xs:QName` with the namespace URI given in $paramURI. If $paramURI is the zero-length string or the empty sequence, it represents "no namespace"; in this case, if the value of $paramQName contains a colon (:), an error is raised [err:FOCA0002]. The prefix (or absence of a prefix) in $paramQName is retained in the returned xs:QName value. The local name in the result is taken from the local part of $paramQName.
Parameters:
$paramURI : A namespace URI, as a string.
$paramQName : A lexical qualified name (xs:QName), a string of the form "prefix:localname" or "localname".
Usage Notes: If $paramQName does not have the correct lexical form for `xs:QName` an error is raised [err:FOCA0002]. Note that unlike xs:QName this function does not require an `xs:string` literal as the argument.
Example:
    fn:QName("http://www.example.com/example", "person")

    => an xs:QName with namespace URI =
       "http://www.example.com/example",
       local name = "person", and
       prefix = "".

    fn:QName("http://www.example.com/example", "ht:person")

    => an xs:QName with namespace URI =
       "http://www.example.com/example",
       local name = "person",
       and prefix = "ht".
fn:resolve-QName(
| $qname as xs:string?,
| $element as element()
) as xs:QName?
Summary: Returns an `xs:QName` value (that is, an expanded QName) by taking an `xs:string` that has the lexical form of an `xs:QName` (a string in the form "prefix:local-name" or "local-name") and resolving it using the in-scope namespaces for a given element.
Parameters:
$qname : A string of the form "prefix:local-name".
$element : An element providing the in-scope namespaces to use to resolve the qualified name.
Usage Notes: Sometimes the requirement is to construct an `xs:QName` without using the default namespace. This can be achieved by writing:
         if ( fn:contains($qname, ":") )
         then ( fn:resolve-QName($qname, $element) )
         else ( fn:QName("", $qname) )
If the requirement is to construct an `xs:QName` using the namespaces in the static context, then the `xs:QName` constructor should be used. If $qname does not have the correct lexical form for `xs:QName` an error is raised [err:FOCA0002]. If $qname is the empty sequence, returns the empty sequence. More specifically, the function searches the namespace bindings of $element for a binding whose name matches the prefix of $qname, or the zero-length string if it has no prefix, and constructs an expanded QName whose local name is taken from the supplied $qname, and whose namespace URI is taken from the string value of the namespace binding. If the $qname has a prefix and if there is no namespace binding for $element that matches this prefix, then an error is raised [err:FONS0004]. If the $qname has no prefix, and there is no namespace binding for $element corresponding to the default (unnamed) namespace, then the resulting expanded QName has no namespace part. The prefix (or absence of a prefix) in the supplied $qname argument is retained in the returned expanded QName, as discussed in Section 2.1 Terminology[DM].
Example:
    Assume that the element bound to $element has a single
    namespace binding bound to the prefix "eg".

    fn:resolve-QName("hello", $element)

    => a QName with local name "hello"
       that is in no namespace.

    fn:resolve-QName("eg:myFunc", $element)

    => an xs:QName whose namespace URI is specified
       by the namespace binding corresponding to the
       prefix "eg" and whose local name is "myFunc".

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