Fixed typos.

Fixed typos.

xquery version "3.0";

(:
 : Copyright 2006-2011 The FLWOR Foundation.
 :
 : Licensed under the Apache License, Version 2.0 (the "License");
 : you may not use this file except in compliance with the License.
 : You may obtain a copy of the License at
 :
 : http://www.apache.org/licenses/LICENSE-2.0
 :
 : Unless required by applicable law or agreed to in writing, software
 : distributed under the License is distributed on an "AS IS" BASIS,
 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 : See the License for the specific language governing permissions and
 : limitations under the License.
 :)

(:===========================================================================:)

(:~
 : This module provides an XQuery API to full-text functions.
 : For general information about Zorba's implementation of the
 : XQuery and XPath Full Text 1.0 specification
 : as well as instructions for building an installing a thesaurus,
 : see the Full Text Thesaurus documentation.
 :
Notes on languages

 : To refer to paricular human languages,
 : Zorba uses both the
 : ISO 639-1
 : and
 : ISO 639-2
 : languages codes.
 : Note that Zorba supports only a subset of the
 : complete list of language codes
 : and not every function supports the same subset.
 :

 : Most functions in this module take a language as a parameter
 : using the
 : xs:language
 : XML schema data type.
 :
Notes on stemming

 : The stem() functions return the
 : stem
 : of a word.
 : In Zorba,
 : the stem of a word itself, however, is not guaranteed to be a word.
 : It is best to consider a stem as an opaque byte sequence.
 : All that is guaranteed about a stem is that,
 : for a given word,
 : the stem of that word will always be the same byte sequence.
 : Hence,
 : you should never compare the result of one of the stem()
 : functions against a non-stemmed string,
 : for example:
 :

 :  if ( ft:stem( "apples" ) eq "apple" )             ** WRONG **
 :

 : Instead do:
 :

 :  if ( ft:stem( "apples" ) eq ft:stem( "apple" ) )  ** CORRECT **
 :

 :
Notes on the thesaurus

 : The thesaurus-lookup() functions have "levels"
 : and "relationship" parameters.
 : The values for these are implementation-defined.
 : Zorba's default implementation uses the
 : WordNet lexical database,
 : version 3.0.
 :

 : In WordNet,
 : the number of "levels" that two phrases are apart
 : are how many hierarchical meanings apart they are.
 : For example,
 : "canary" is 5 levels away from "vertebrate"
 : (carary > finch > oscine > passerine > bird > vertebrate).
 :

 : When using the WordNet implementation,
 : Zorba supports all of the relationships (and their abbreviations)
 : specified by
 : ISO 2788
 : and
 : ANSI/NISO Z39.19-2005
 : with the exceptions of "HN" (history note)
 : and "X SN" (see scope note for).
 : These relationships are:
 :

 :

 :      Rel.
 :      Meaning
 :      WordNet Rel.
 :

 :

 :      BT
 :      broader term
 :      hypernym
 :

 :

 :      BTG
 :      broader term generic
 :      hypernym
 :

 :

 :      BTI
 :      broader term instance
 :      instance hypernym
 :

 :

 :      BTP
 :      broader term partitive
 :      part meronym
 :

 :

 :      NT
 :      narrower term
 :      hyponym
 :

 :

 :      NTG
 :      narrower term generic
 :      hyponym
 :

 :

 :      NTI
 :      narrower term instance
 :      instance hyponym
 :

 :

 :      NTP
 :      narrower term partitive
 :      part holonym
 :

 :

 :      RT
 :      related term
 :      also see
 :

 :

 :      SN
 :      scope note
 :      n/a
 :

 :

 :      TT
 :      top term
 :      hypernym
 :

 :

 :      UF
 :      non-preferred term
 :      n/a
 :

 :

 :      USE
 :      preferred term
 :      n/a
 :

 :

 : Note that you can specify relationships
 : either by their abbreviation
 : or their meaning.
 : Relationships are case-insensitive.
 :
 : In addition to the
 : ISO 2788
 : and
 : ANSI/NISO Z39.19-2005
 : relationships,
 : Zorba also supports all of the relationships offered by WordNet.
 : These relationships are:
 :

 :

 :      Relationship
 :      Meaning
 :

 :

 :      also see
 :
 :        A word that is related to another,
 :        e.g., for "varnished" (furniture)
 :        one should also see "finished."
 :
 :

 :

 :      antonym
 :
 :        A word opposite in meaning to another,
 :        e.g., "light" is an antonym for "heavy."
 :
 :

 :

 :      attribute
 :
 :        A noun for which adjectives express values,
 :        e.g., "weight" is an attribute
 :        for which the adjectives "light" and "heavy"
 :        express values.
 :
 :

 :

 :      cause
 :
 :        A verb that causes another,
 :        e.g., "show" is a cause of "see."
 :
 :

 :

 :      derivationally related form
 :
 :        A word that is derived from a root word,
 :        e.g., "metric" is a derivationally related form of "meter."
 :
 :

 :

 :      derived from adjective
 :
 :        An adverb that is derived from an adjective,
 :        e.g., "correctly" is derived from the adjective "correct."
 :
 :

 :

 :      entailment
 :
 :        A verb that presupposes another,
 :        e.g., "snoring" entails "sleeping."
 :
 :

 :

 :      hypernym
 :
 :        A word with a broad meaning that more specific words fall under,
 :        e.g., "meal" is a hypernym of "breakfast."
 :
 :

 :

 :      hyponym
 :
 :        A word of more specific meaning than a general term applicable to it,
 :        e.g., "breakfast" is a hyponym of "meal."
 :
 :

 :

 :      instance hypernym
 :
 :        A word that denotes a category of some specific instance,
 :        e.g., "author" is an instance hypernym of "Asimov."
 :
 :

 :

 :      instance hyponym
 :
 :        A term that donotes a specific instance of some general category,
 :        e.g., "Asimov" is an instance hyponym of "author."
 :
 :

 :

 :      member holonym
 :
 :        A word that denotes a collection of individuals,
 :        e.g., "faculty" is a member holonym of "professor."
 :
 :

 :

 :      member meronym
 :
 :        A word that denotes a member of a larger group,
 :        e.g., a "person" is a member meronym of a "crowd."
 :
 :

 :

 :      part holonym
 :
 :        A word that denotes a larger whole comprised of some part,
 :        e.g., "car" is a part holonym of "engine."
 :
 :

 :

 :      part meronym
 :
 :        A word that denotes a part of a larger whole,
 :        e.g., an "engine" is part meronym of a "car."
 :
 :

 :

 :      participle of verb
 :
 :        An adjective that is the participle of some verb,
 :        e.g., "breaking" is the participle of the verb "break."
 :
 :

 :

 :      pertainym
 :
 :        An adjective that classifies its noun,
 :        e.g., "musical" is a pertainym in "musical instrument."
 :
 :

 :

 :      similar to
 :
 :        Similar, though not necessarily interchangeable, adjectives.
 :        For example, "shiny" is similar to "bright",
 :        but they have subtle differences.
 :
 :

 :

 :      substance holonym
 :
 :        A word that denotes a larger whole containing some constituent
 :        substance, e.g., "bread" is a substance holonym of "flour."
 :
 :

 :

 :      substance meronym
 :
 :        A word that denotes a constituant substance of some larger whole,
 :        e.g., "flour" is a substance meronym of "bread."
 :
 :

 :

 :      verb group
 :
 :        A verb that is a member of a group of similar verbs,
 :        e.g., "live" is in the verb group
 :        of "dwell", "live", "inhabit", etc.
 :
 :

 :

 :
Notes on tokenization

 : For general information about Zorba's implementation of tokenization,
 : including what constitutes a token,
 : see the Full Text Tokenizer documentation.
 : @author Paul J. Lucas
 :)
module namespace ft = "http://www.zorba-xquery.com/modules/full-text";

import schema namespace ft-schema =
  "http://www.zorba-xquery.com/modules/full-text";

declare namespace err = "http://www.w3.org/2005/xqt-errors";
declare namespace zerr = "http://www.zorba-xquery.com/errors";

declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
declare option ver:module-version "2.0";

(:===========================================================================:)

(:~
 : Predeclared constant for the Danish
 : xs:language.
 :)
declare variable $ft:lang-da as xs:language := xs:language("da");

(:~
 : Predeclared constant for the German
 : xs:language.
 :)
declare variable $ft:lang-de as xs:language := xs:language("de");

(:~
 : Predeclared constant for the English
 : xs:language.
 :)
declare variable $ft:lang-en as xs:language := xs:language("en");

(:~
 : Predeclared constant for the Spanish
 : xs:language.
 :)
declare variable $ft:lang-es as xs:language := xs:language("es");

(:~
 : Predeclared constant for the Finnish
 : xs:language.
 :)
declare variable $ft:lang-fi as xs:language := xs:language("fi");

(:~
 : Predeclared constant for the French
 : xs:language.
 :)
declare variable $ft:lang-fr as xs:language := xs:language("fr");

(:~
 : Predeclared constant for the Hungarian
 : xs:language.
 :)
declare variable $ft:lang-hu as xs:language := xs:language("hu");

(:~
 : Predeclared constant for the Italian
 : xs:language.
 :)
declare variable $ft:lang-it as xs:language := xs:language("it");

(:~
 : Predeclared constant for the Dutch
 : xs:language.
 :)
declare variable $ft:lang-nl as xs:language := xs:language("nl");

(:~
 : Predeclared constant for the Norwegian
 : xs:language.
 :)
declare variable $ft:lang-no as xs:language := xs:language("no");

(:~
 : Predeclared constant for the Portuguese
 : xs:language.
 :)
declare variable $ft:lang-pt as xs:language := xs:language("pt");

(:~
 : Predeclared constant for the Romanian
 : xs:language.
 :)
declare variable $ft:lang-ro as xs:language := xs:language("ro");

(:~
 : Predeclared constant for the Russian
 : xs:language.
 :)
declare variable $ft:lang-ru as xs:language := xs:language("ru");

(:~
 : Predeclared constant for the Swedish
 : xs:language.
 :)
declare variable $ft:lang-sv as xs:language := xs:language("sv");

(:~
 : Predeclared constant for the Turkish
 : xs:language.
 :)
declare variable $ft:lang-tr as xs:language := xs:language("tr");

(:===========================================================================:)

(:~
 : Gets the current compare options.
 :
 : @return said compare options.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-current-compare-options-1.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-current-compare-options-2.xq
 :)
declare function ft:current-compare-options()
  as element(ft-schema:compare-options) external;

(:~
 : Gets the current
 : language:
 : either the language specified by the
 : declare ft-option using
 : language
 : statement (if any)
 : or the one returned by ft:host-lang() (if none).
 :
 : @return said language.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-current-lang-true-1.xq
 :)
declare function ft:current-lang()
  as xs:language external;

(:~
 : Gets the host's current
 : language.
 : The "host" is the computer on which Zorba is running.
 : The host's current language is obtained as follows:
 :

 :

 :      For *nix systems:
 :

 :

 :          If setlocale(3) returns non-null,
 :          the language corresponding to that locale is used.
 :

 :

 :          Else, if the LANG environment variable is set,
 :          that language is ued.
 :

 :

 :          Otherwise, there is no default language.
 :

 :

 :

 :

 :      For Windows systems,
 :      the language corresponding to the locale returned by the
 :      GetLocaleInfo()
 :      function is used.
 :

 :

 :
 : @return said language.
 :)
declare function ft:host-lang()
  as xs:language external;

(:~
 : Checks whether the given
 : language
 : is supported for stemming.
 :
 : @param $lang The language to check.
 : @return true only if the language is supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stem-lang-es-supported-true.xq
 :)
declare function ft:is-stem-lang-supported( $lang as xs:language )
  as xs:boolean external;

(:~
 : Checks whether the given word is a stop-word.
 :
 : @param $word The word to check.
 : @param $lang The
 : language
 : of $word.
 : @return true only if $word is a stop-word.
 : @error err:FTST0009 if $lang is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-true-1.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-true-3.xq
 :)
declare function ft:is-stop-word( $word as xs:string, $lang as xs:language )
  as xs:boolean external;

(:~
 : Checks whether the given word is a stop-word.
 :
 : @param $word The word to check.
 : The word's language
 : is assumed to be the one returned by ft:current-lang().
 : @return true only if $word is a stop-word.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-true-2.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-true-4.xq
 :)
declare function ft:is-stop-word( $word as xs:string )
  as xs:boolean external;

(:~
 : Checks whether the given
 : language
 : is supported for stop words.
 :
 : @param $lang The language to check.
 : @return true only if the language is supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-lang-en-supported-true.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-lang-supported-false-1.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-lang-supported-false-2.xq
 :)
declare function ft:is-stop-word-lang-supported( $lang as xs:language )
  as xs:boolean external;

(:~
 : Checks whether the given
 : language
 : is supported for look-up using the default thesaurus.
 :
 : @param $lang The language to check.
 : @return true only if the language is supported.
 :)
declare function ft:is-thesaurus-lang-supported( $lang as xs:language )
  as xs:boolean external;

(:~
 : Checks whether the given
 : language
 : is supported for look-up using the thesaurus specified by the given URI.
 :
 : @param $uri The URI specifying the thesaurus to use.
 : @param $lang The language to check.
 : @return true only if the language is supported.
 : @error err:FTST0018 if $uri refers to a thesaurus
 : that is not found in the statically known thesauri.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-thesaurus-lang-supported-true-1.xq
 :)
declare function ft:is-thesaurus-lang-supported( $uri as xs:string,
                                                 $lang as xs:language )
  as xs:boolean external;

(:~
 : Checks whether the given
 : language
 : is supported for tokenization.
 :
 : @param $lang The language to check.
 : @return true only if the language is supported.
 :)
declare function ft:is-tokenizer-lang-supported( $lang as xs:language )
  as xs:boolean external;

(:~
 : Stems the given word.
 :
 : @param $word The word to stem.
 : @param $lang The
 : language
 : of $word.
 : @return the stem of $word.
 : @error err:FTST0009 if $lang is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-stem-1.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-stem-2.xq
 :)
declare function ft:stem( $word as xs:string, $lang as xs:language )
  as xs:string external;

(:~
 : Stems the given word.
 :
 : @param $word The word to stem.
 : The word's language
 : is assumed to be the one returned by ft:current-lang().
 : @return the stem of $word.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-stem-3.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-stem-4.xq
 :)
declare function ft:stem( $word as xs:string )
  as xs:string external;

(:~
 : Strips all diacritical marks from all characters.
 :
 : @param $string The string to strip diacritical marks from.
 : @return $string with diacritical marks stripped.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-strip-diacritics-1.xq
 :)
declare function ft:strip-diacritics( $string as xs:string )
  as xs:string external;

(:~
 : Looks-up the given phrase in the default thesaurus.
 :
 : @param $phrase The phrase to look up.
 : The phrase's
 : language
 : is assumed to be the one returned by ft:current-lang().
 : @return the related phrases if $phrase is found in the
 : thesaurus or the empty sequence if not.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @error zerr:ZXQP8401 if the thesaurus data file's version is not supported
 : by the currently running version of Zorba.
 : @error zerr:ZXQP8402 if the thesaurus data file's endianness does not match
 : that of the CPU on which Zorba is currently running.
 : @error zerr:ZXQP8403 if there was an error reading the thesaurus data.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-thesaurus-lookup-1.xq
 :)
declare function ft:thesaurus-lookup( $phrase as xs:string )
  as xs:string* external;

(:~
 : Looks-up the given phrase in the thesaurus specified by the given URI.
 :
 : @param $uri The URI specifying the thesaurus to use.
 : @param $phrase The phrase to look up.
 : @param $lang The
 : language
 : of $phrase.
 : @return the related phrases if $phrase is found in the
 : thesaurus or the empty sequence if not.
 : @error err:FTST0009 if $lang is not supported.
 : @error err:FTST0018 if $uri refers to a thesaurus
 : that is not found in the statically known thesauri.
 : @error zerr:ZOSE0001 if the thesaurus data file could not be found.
 : @error zerr:ZOSE0002 if the thesaurus data file is not a plain file.
 : @error zerr:ZXQP8401 if the thesaurus data file's version is not supported
 : by the currently running version of Zorba.
 : @error zerr:ZXQP8402 if the thesaurus data file's endianness does not match
 : that of the CPU on which Zorba is currently running.
 : @error zerr:ZXQP8403 if there was an error reading the thesaurus data file.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-thesaurus-lookup-2.xq
 :)
declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string,
                                      $lang as xs:language )
  as xs:string* external;

(:~
 : Looks-up the given phrase in a thesaurus.
 :
 : @param $uri The URI specifying the thesaurus to use.
 : @param $phrase The phrase to look up.
 : The phrase's
 : language
 : is assumed to be the one the one returned by ft:current-lang().
 : @return the related phrases if $phrase is found in the
 : thesaurus or the empty sequence if not.
 : @error err:FTST0009 if ft:current-lang() is unsupported.
 : @error err:FTST0018 if $uri refers to a thesaurus
 : that is not found in the statically known thesauri.
 : @error zerr:ZOSE0001 if the thesaurus data file could not be found.
 : @error zerr:ZOSE0002 if the thesaurus data file is not a plain file.
 : @error zerr:ZXQP8401 if the thesaurus data file's version is not supported
 : by the currently running version of Zorba.
 : @error zerr:ZXQP8402 if the thesaurus data file's endianness does not match
 : that of the CPU on which Zorba is currently running.
 : @error zerr:ZXQP8403 if there was an error reading the thesaurus data file.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-thesaurus-lookup-3.xq
 :)
declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string )
  as xs:string* external;

(:~
 : Looks-up the given phrase in a thesaurus.
 :
 : @param $uri The URI specifying the thesaurus to use.
 : @param $phrase The phrase to look up.
 : @param $lang The
 : language
 : of $phrase.
 : @param $relationship The relationship the results are to have to
 : $phrase.
 : @return the related phrases if $phrase is found in the
 : thesaurus or the empty sequence if not.
 : @error err:FTST0018 if $uri refers to a thesaurus
 : that is not found in the statically known thesauri.
 : @error err:FTST0009 if $lang is not supported.
 : @error zerr:ZOSE0001 if the thesaurus data file could not be found.
 : @error zerr:ZOSE0002 if the thesaurus data file is not a plain file.
 : @error zerr:ZXQP8401 if the thesaurus data file's version is not supported
 : by the currently running version of Zorba.
 : @error zerr:ZXQP8402 if the thesaurus data file's endianness does not match
 : that of the CPU on which Zorba is currently running.
 : @error zerr:ZXQP8403 if there was an error reading the thesaurus data file.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-thesaurus-lookup-4.xq
 :)
declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string,
                                      $lang as xs:language,
                                      $relationship as xs:string )
  as xs:string* external;

(:~
 : Looks-up the given phrase in a thesaurus.
 :
 : @param $uri The URI specifying the thesaurus to use.
 : @param $phrase The phrase to look up.
 : @param $lang The
 : language
 : of $phrase.
 : @param $relationship The relationship the results are to have to
 : $phrase.
 : @param $level-least The minimum number of levels within the thesaurus to be
 : traversed.
 : @param $level-most The maximum number of levels within the thesaurus to be
 : traversed.
 : @return the related phrases if $phrase is found in the
 : thesaurus or the empty sequence if not.
 : @error err:FOCA0003 if either $level-least or
 : $level-most is either negative or too large.
 : @error err:FTST0018 if $uri refers to a thesaurus
 : that is not found in the statically known thesauri.
 : @error err:FTST0009 if $lang is not supported.
 : @error zerr:ZOSE0001 if the thesaurus data file could not be found.
 : @error zerr:ZOSE0002 if the thesaurus data file is not a plain file.
 : @error zerr:ZXQP8401 if the thesaurus data file's version is not supported
 : by the currently running version of Zorba.
 : @error zerr:ZXQP8402 if the thesaurus data file's endianness does not match
 : that of the CPU on which Zorba is currently running.
 : @error zerr:ZXQP8403 if there was an error reading the thesaurus data file.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-thesaurus-lookup-5.xq
 :)
declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string,
                                      $lang as xs:language,
                                      $relationship as xs:string,
                                      $level-least as xs:integer,
                                      $level-most as xs:integer )
  as xs:string* external;

(:~
 : Tokenizes the given node and all of its decendants.
 :
 : @param $node The node to tokenize.
 : @param $lang The default
 : language
 : of $node.
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if $lang is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-node-1.xq
 :)
declare function ft:tokenize-node( $node as node(), $lang as xs:language )
  as element(ft-schema:token)* external;

(:~
 : Tokenizes the given node and all of its descendants.
 :
 : @param $node The node to tokenize.
 : The node's default
 : language
 : is assumed to be the one returned by ft:current-lang().
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-node-2.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-node-3.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-node-4.xq
 :)
declare function ft:tokenize-node( $node as node() )
  as element(ft-schema:token)* external;

(:~
 : Tokenizes the set of nodes comprising $includes (and all of its
 : descendants) but excluding $excludes (and all of its
 : descendants), if any.
 :
 : @param $includes The set of nodes (and its descendants) to include.
 : The default
 : language
 : is assumed to be the one returned by ft:current-lang().
 : @param $excludes The set of nodes (and its descendants) to exclude.
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-nodes-1.xq
 :)
declare function ft:tokenize-nodes( $includes as node()+,
                                    $excludes as node()* )
  as element(ft-schema:token)* external;

(:~
 : Tokenizes the set of nodes comprising $includes (and all of its
 : descendants) but excluding $excludes (and all of its
 : descendants), if any.
 :
 : @param $includes The set of nodes (and its descendants) to include.
 : @param $excludes The set of nodes (and its descendants) to exclude.
 : @param $lang The default
 : language
 : for nodes.
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if $lang is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-nodes-1.xq
 :)
declare function ft:tokenize-nodes( $includes as node()+,
                                    $excludes as node()*,
                                    $lang as xs:language )
  as element(ft-schema:token)* external;

(:~
 : Tokenizes the given string.
 :
 : @param $string The string to tokenize.
 : @param $lang The
 : language
 : of $string.
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if $lang is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-string-1.xq
 :)
declare function ft:tokenize-string( $string as xs:string,
                                     $lang as xs:language )
  as xs:string* external;

(:~
 : Tokenizes the given string.
 :
 : @param $string The string to tokenize.
 : The string's
 : language
 : is assumed to be the one returned by ft:current-lang().
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-string-2.xq
 :)
declare function ft:tokenize-string( $string as xs:string )
  as xs:string* external;

(:~
 : Gets properties of the tokenizer for the given
 : language.
 :
 : @param $lang The language of the tokenizer to get the properties of.
 : @return said properties.
 : @error err:FTST0009 if $lang is not supported.
 : tokenization specifically.
 :)
declare function ft:tokenizer-properties( $lang as xs:language )
  as element(ft-schema:tokenizer-properties) external;

(:~
 : Gets properties of the tokenizer for the
 : language
 : returned by ft:current-lang().
 :
 : @return said properties.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 :)
declare function ft:tokenizer-properties()
  as element(ft-schema:tokenizer-properties) external;

(:===========================================================================:)

(: vim:set et sw=2 ts=2: :)

xquery version "3.0";

(:
 : Copyright 2006-2011 The FLWOR Foundation.
 :
 : Licensed under the Apache License, Version 2.0 (the "License");
 : you may not use this file except in compliance with the License.
 : You may obtain a copy of the License at
 :
 : http://www.apache.org/licenses/LICENSE-2.0
 :
 : Unless required by applicable law or agreed to in writing, software
 : distributed under the License is distributed on an "AS IS" BASIS,
 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 : See the License for the specific language governing permissions and
 : limitations under the License.
 :)

(:===========================================================================:)

(:~
 : This module provides an XQuery API to full-text functions.
 : For general information about Zorba's implementation of the
 : XQuery and XPath Full Text 1.0 specification
 : as well as instructions for building an installing a thesaurus,
 : see the Full Text Thesaurus documentation.
 :
Notes on languages

 : To refer to paricular human languages,
 : Zorba uses both the
 : ISO 639-1
 : and
 : ISO 639-2
 : languages codes.
 : Note that Zorba supports only a subset of the
 : complete list of language codes
 : and not every function supports the same subset.
 :

 : Most functions in this module take a language as a parameter
 : using the
 : xs:language
 : XML schema data type.
 :
Notes on stemming

 : The stem() functions return the
 : stem
 : of a word.
 : In Zorba,
 : the stem of a word itself, however, is not guaranteed to be a word.
 : It is best to consider a stem as an opaque byte sequence.
 : All that is guaranteed about a stem is that,
 : for a given word,
 : the stem of that word will always be the same byte sequence.
 : Hence,
 : you sould never compare the result of one of the stem()
 : functions against a non-stemmed string,
 : for example:
 :

 :  if ( ft:stem( "apples" ) eq "apple" )             ** WRONG **
 :

 : Instead do:
 :

 :  if ( ft:stem( "apples" ) eq ft:stem( "apple" ) )  ** CORRECT **
 :

 :
Notes on the thesaurus

 : The thesaurus-lookup() functions have "levels"
 : and "relationship" parameters.
 : The values for these are implementation-defined.
 : Zorba's default implementation uses the
 : WordNet lexical database,
 : version 3.0.
 :

 : In WordNet,
 : the number of "levels" that two phrases are apart
 : are how many hierarchical meanings apart they are.
 : For example,
 : "canary" is 5 levels away from "vertebrate"
 : (carary > finch > oscine > passerine > bird > vertebrate).
 :

 : When using the WordNet implementation,
 : Zorba supports all of the relationships (and their abbreviations)
 : specified by
 : ISO 2788
 : and
 : ANSI/NISO Z39.19-2005
 : with the exceptions of "HN" (history note)
 : and "X SN" (see scope note for).
 : These relationships are:
 :

 :

 :      Rel.
 :      Meaning
 :      WordNet Rel.
 :

 :

 :      BT
 :      broader term
 :      hypernym
 :

 :

 :      BTG
 :      broader term generic
 :      hypernym
 :

 :

 :      BTI
 :      broader term instance
 :      instance hypernym
 :

 :

 :      BTP
 :      broader term partitive
 :      part meronym
 :

 :

 :      NT
 :      narrower term
 :      hyponym
 :

 :

 :      NTG
 :      narrower term generic
 :      hyponym
 :

 :

 :      NTI
 :      narrower term instance
 :      instance hyponym
 :

 :

 :      NTP
 :      narrower term partitive
 :      part holonym
 :

 :

 :      RT
 :      related term
 :      also see
 :

 :

 :      SN
 :      scope note
 :      n/a
 :

 :

 :      TT
 :      top term
 :      hypernym
 :

 :

 :      UF
 :      non-preferred term
 :      n/a
 :

 :

 :      USE
 :      preferred term
 :      n/a
 :

 :

 : Note that you can specify relationships
 : either by their abbreviation
 : or their meaning.
 : Relationships are case-insensitive.
 :
 : In addition to the
 : ISO 2788
 : and
 : ANSI/NISO Z39.19-2005
 : relationships,
 : Zorba also supports all of the relationships offered by WordNet.
 : These relationships are:
 :

 :

 :      Relationship
 :      Meaning
 :

 :

 :      also see
 :
 :        A word that is related to another,
 :        e.g., for "varnished" (furniture)
 :        one should also see "finished."
 :
 :

 :

 :      antonym
 :
 :        A word opposite in meaning to another,
 :        e.g., "light" is an antonym for "heavy."
 :
 :

 :

 :      attribute
 :
 :        A noun for which adjectives express values,
 :        e.g., "weight" is an attribute
 :        for which the adjectives "light" and "heavy"
 :        express values.
 :
 :

 :

 :      cause
 :
 :        A verb that causes another,
 :        e.g., "show" is a cause of "see."
 :
 :

 :

 :      derivationally related form
 :
 :        A word that is derived from a root word,
 :        e.g., "metric" is a derivationally related form of "meter."
 :
 :

 :

 :      derived from adjective
 :
 :        An adverb that is derived from an adjective,
 :        e.g., "correctly" is derived from the adjective "correct."
 :
 :

 :

 :      entailment
 :
 :        A verb that presupposes another,
 :        e.g., "snoring" entails "sleeping."
 :
 :

 :

 :      hypernym
 :
 :        A word with a broad meaning that more specific words fall under,
 :        e.g., "meal" is a hypernym of "breakfast."
 :
 :

 :

 :      hyponym
 :
 :        A word of more specific meaning than a general term applicable to it,
 :        e.g., "breakfast" is a hyponym of "meal."
 :
 :

 :

 :      instance hypernym
 :
 :        A word that denotes a category of some specific instance,
 :        e.g., "author" is an instance hypernym of "Asimov."
 :
 :

 :

 :      instance hyponym
 :
 :        A term that donotes a specific instance of some general category,
 :        e.g., "Asimov" is an instance hyponym of "author."
 :
 :

 :

 :      member holonym
 :
 :        A word that denotes a collection of individuals,
 :        e.g., "faculty" is a member holonym of "professor."
 :
 :

 :

 :      member meronym
 :
 :        A word that denotes a member of a larger group,
 :        e.g., a "person" is a member meronym of a "crowd."
 :
 :

 :

 :      part holonym
 :
 :        A word that denotes a larger whole comprised of some part,
 :        e.g., "car" is a part holonym of "engine."
 :
 :

 :

 :      part meronym
 :
 :        A word that denotes a part of a larger whole,
 :        e.g., an "engine" is part meronym of a "car."
 :
 :

 :

 :      participle of verb
 :
 :        An adjective that is the participle of some verb,
 :        e.g., "breaking" is the participle of the verb "break."
 :
 :

 :

 :      pertainym
 :
 :        An adjective that classifies its noun,
 :        e.g., "musical" is a pertainym in "musical instrument."
 :
 :

 :

 :      similar to
 :
 :        Similar, though not necessarily interchangeable, adjectives.
 :        For example, "shiny" is similar to "bright",
 :        but they have subtle differences.
 :
 :

 :

 :      substance holonym
 :
 :        A word that denotes a larger whole containing some constituent
 :        substance, e.g., "bread" is a substance holonym of "flour."
 :
 :

 :

 :      substance meronym
 :
 :        A word that denotes a constituant substance of some larger whole,
 :        e.g., "flour" is a substance meronym of "bread."
 :
 :

 :

 :      verb group
 :
 :        A verb that is a member of a group of similar verbs,
 :        e.g., "live" is in the verb group
 :        of "dwell", "live", "inhabit", etc.
 :
 :

 :

 :
Notes on tokenization

 : For general information about Zorba's implementation of tokenization,
 : including what constitutes a token,
 : see the Full Text Tokenizer documentation.
 : @author Paul J. Lucas
 :)
module namespace ft = "http://www.zorba-xquery.com/modules/full-text";

import schema namespace ft-schema =
  "http://www.zorba-xquery.com/modules/full-text";

declare namespace err = "http://www.w3.org/2005/xqt-errors";
declare namespace zerr = "http://www.zorba-xquery.com/errors";

declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
declare option ver:module-version "2.0";

(:===========================================================================:)

(:~
 : Predeclared constant for the Danish
 : xs:language.
 :)
declare variable $ft:lang-da as xs:language := xs:language("da");

(:~
 : Predeclared constant for the German
 : xs:language.
 :)
declare variable $ft:lang-de as xs:language := xs:language("de");

(:~
 : Predeclared constant for the English
 : xs:language.
 :)
declare variable $ft:lang-en as xs:language := xs:language("en");

(:~
 : Predeclared constant for the Spanish
 : xs:language.
 :)
declare variable $ft:lang-es as xs:language := xs:language("es");

(:~
 : Predeclared constant for the Finnish
 : xs:language.
 :)
declare variable $ft:lang-fi as xs:language := xs:language("fi");

(:~
 : Predeclared constant for the French
 : xs:language.
 :)
declare variable $ft:lang-fr as xs:language := xs:language("fr");

(:~
 : Predeclared constant for the Hungarian
 : xs:language.
 :)
declare variable $ft:lang-hu as xs:language := xs:language("hu");

(:~
 : Predeclared constant for the Italian
 : xs:language.
 :)
declare variable $ft:lang-it as xs:language := xs:language("it");

(:~
 : Predeclared constant for the Dutch
 : xs:language.
 :)
declare variable $ft:lang-nl as xs:language := xs:language("nl");

(:~
 : Predeclared constant for the Norwegian
 : xs:language.
 :)
declare variable $ft:lang-no as xs:language := xs:language("no");

(:~
 : Predeclared constant for the Portuguese
 : xs:language.
 :)
declare variable $ft:lang-pt as xs:language := xs:language("pt");

(:~
 : Predeclared constant for the Romanian
 : xs:language.
 :)
declare variable $ft:lang-ro as xs:language := xs:language("ro");

(:~
 : Predeclared constant for the Russian
 : xs:language.
 :)
declare variable $ft:lang-ru as xs:language := xs:language("ru");

(:~
 : Predeclared constant for the Swedish
 : xs:language.
 :)
declare variable $ft:lang-sv as xs:language := xs:language("sv");

(:~
 : Predeclared constant for the Turkish
 : xs:language.
 :)
declare variable $ft:lang-tr as xs:language := xs:language("tr");

(:===========================================================================:)

(:~
 : Gets the current compare options.
 :
 : @return said compare options.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-current-compare-options-1.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-current-compare-options-2.xq
 :)
declare function ft:current-compare-options()
  as element(ft-schema:compare-options) external;

(:~
 : Gets the current
 : language:
 : either the language specified by the
 : declare ft-option using
 : language
 : statement (if any)
 : or the one returned by ft:host-lang() (if none).
 :
 : @return said language.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-current-lang-true-1.xq
 :)
declare function ft:current-lang()
  as xs:language external;

(:~
 : Gets the host's current
 : language.
 : The "host" is the computer on which Zorba is running.
 : The host's current language is obtained as follows:
 :

 :

 :      For *nix systems:
 :

 :

 :          If setlocale(3) returns non-null,
 :          the language corresponding to that locale is used.
 :

 :

 :          Else, if the LANG environment variable is set,
 :          that language is ued.
 :

 :

 :          Otherwise, there is no default language.
 :

 :

 :

 :

 :      For Windows systems,
 :      the language corresponding to the locale returned by the
 :      GetLocaleInfo()
 :      function is used.
 :

 :

 :
 : @return said language.
 :)
declare function ft:host-lang()
  as xs:language external;

(:~
 : Checks whether the given
 : language
 : is supported for stemming.
 :
 : @param $lang The language to check.
 : @return true only if the language is supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stem-lang-es-supported-true.xq
 :)
declare function ft:is-stem-lang-supported( $lang as xs:language )
  as xs:boolean external;

(:~
 : Checks whether the given word is a stop-word.
 :
 : @param $word The word to check.
 : @param $lang The
 : language
 : of $word.
 : @return true only if $word is a stop-word.
 : @error err:FTST0009 if $lang is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-true-1.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-true-3.xq
 :)
declare function ft:is-stop-word( $word as xs:string, $lang as xs:language )
  as xs:boolean external;

(:~
 : Checks whether the given word is a stop-word.
 :
 : @param $word The word to check.
 : The word's language
 : is assumed to be the one returned by ft:current-lang().
 : @return true only if $word is a stop-word.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-true-2.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-true-4.xq
 :)
declare function ft:is-stop-word( $word as xs:string )
  as xs:boolean external;

(:~
 : Checks whether the given
 : language
 : is supported for stop words.
 :
 : @param $lang The language to check.
 : @return true only if the language is supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-lang-en-supported-true.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-lang-supported-false-1.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-stop-word-lang-supported-false-2.xq
 :)
declare function ft:is-stop-word-lang-supported( $lang as xs:language )
  as xs:boolean external;

(:~
 : Checks whether the given
 : language
 : is supported for look-up using the default thesaurus.
 :
 : @param $lang The language to check.
 : @return true only if the language is supported.
 :)
declare function ft:is-thesaurus-lang-supported( $lang as xs:language )
  as xs:boolean external;

(:~
 : Checks whether the given
 : language
 : is supported for look-up using the thesaurus specified by the given URI.
 :
 : @param $uri The URI specifying the thesaurus to use.
 : @param $lang The language to check.
 : @return true only if the language is supported.
 : @error err:FTST0018 if $uri refers to a thesaurus
 : that is not found in the statically known thesauri.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-is-thesaurus-lang-supported-true-1.xq
 :)
declare function ft:is-thesaurus-lang-supported( $uri as xs:string,
                                                 $lang as xs:language )
  as xs:boolean external;

(:~
 : Checks whether the given
 : language
 : is supported for tokenization.
 :
 : @param $lang The language to check.
 : @return true only if the language is supported.
 :)
declare function ft:is-tokenizer-lang-supported( $lang as xs:language )
  as xs:boolean external;

(:~
 : Stems the given word.
 :
 : @param $word The word to stem.
 : @param $lang The
 : language
 : of $word.
 : @return the stem of $word.
 : @error err:FTST0009 if $lang is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-stem-1.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-stem-2.xq
 :)
declare function ft:stem( $word as xs:string, $lang as xs:language )
  as xs:string external;

(:~
 : Stems the given word.
 :
 : @param $word The word to stem.
 : The word's language
 : is assumed to be the one returned by ft:current-lang().
 : @return the stem of $word.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-stem-3.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-stem-4.xq
 :)
declare function ft:stem( $word as xs:string )
  as xs:string external;

(:~
 : Strips all diacritical marks from all characters.
 :
 : @param $string The string to strip diacritical marks from.
 : @return $string with diacritical marks stripped.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-strip-diacritics-1.xq
 :)
declare function ft:strip-diacritics( $string as xs:string )
  as xs:string external;

(:~
 : Looks-up the given phrase in the default thesaurus.
 :
 : @param $phrase The phrase to look up.
 : The phrase's
 : language
 : is assumed to be the one returned by ft:current-lang().
 : @return the related phrases if $phrase is found in the
 : thesaurus or the empty sequence if not.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @error zerr:ZXQP8401 if the thesaurus data file's version is not supported
 : by the currently running version of Zorba.
 : @error zerr:ZXQP8402 if the thesaurus data file's endianness does not match
 : that of the CPU on which Zorba is currently running.
 : @error zerr:ZXQP8403 if there was an error reading the thesaurus data.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-thesaurus-lookup-1.xq
 :)
declare function ft:thesaurus-lookup( $phrase as xs:string )
  as xs:string* external;

(:~
 : Looks-up the given phrase in the thesaurus specified by the given URI.
 :
 : @param $uri The URI specifying the thesaurus to use.
 : @param $phrase The phrase to look up.
 : @param $lang The
 : language
 : of $phrase.
 : @return the related phrases if $phrase is found in the
 : thesaurus or the empty sequence if not.
 : @error err:FTST0009 if $lang is not supported.
 : @error err:FTST0018 if $uri refers to a thesaurus
 : that is not found in the statically known thesauri.
 : @error zerr:ZOSE0001 if the thesaurus data file could not be found.
 : @error zerr:ZOSE0002 if the thesaurus data file is not a plain file.
 : @error zerr:ZXQP8401 if the thesaurus data file's version is not supported
 : by the currently running version of Zorba.
 : @error zerr:ZXQP8402 if the thesaurus data file's endianness does not match
 : that of the CPU on which Zorba is currently running.
 : @error zerr:ZXQP8403 if there was an error reading the thesaurus data file.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-thesaurus-lookup-2.xq
 :)
declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string,
                                      $lang as xs:language )
  as xs:string* external;

(:~
 : Looks-up the given phrase in a thesaurus.
 :
 : @param $uri The URI specifying the thesaurus to use.
 : @param $phrase The phrase to look up.
 : The phrase's
 : language
 : is assumed to be the one the one returned by ft:current-lang().
 : @return the related phrases if $phrase is found in the
 : thesaurus or the empty sequence if not.
 : @error err:FTST0009 if ft:current-lang() is unsupported.
 : @error err:FTST0018 if $uri refers to a thesaurus
 : that is not found in the statically known thesauri.
 : @error zerr:ZOSE0001 if the thesaurus data file could not be found.
 : @error zerr:ZOSE0002 if the thesaurus data file is not a plain file.
 : @error zerr:ZXQP8401 if the thesaurus data file's version is not supported
 : by the currently running version of Zorba.
 : @error zerr:ZXQP8402 if the thesaurus data file's endianness does not match
 : that of the CPU on which Zorba is currently running.
 : @error zerr:ZXQP8403 if there was an error reading the thesaurus data file.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-thesaurus-lookup-3.xq
 :)
declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string )
  as xs:string* external;

(:~
 : Looks-up the given phrase in a thesaurus.
 :
 : @param $uri The URI specifying the thesaurus to use.
 : @param $phrase The phrase to look up.
 : @param $lang The
 : language
 : of $phrase.
 : @param $relationship The relationship the results are to have to
 : $phrase.
 : @return the related phrases if $phrase is found in the
 : thesaurus or the empty sequence if not.
 : @error err:FTST0018 if $uri refers to a thesaurus
 : that is not found in the statically known thesauri.
 : @error err:FTST0009 if $lang is not supported.
 : @error zerr:ZOSE0001 if the thesaurus data file could not be found.
 : @error zerr:ZOSE0002 if the thesaurus data file is not a plain file.
 : @error zerr:ZXQP8401 if the thesaurus data file's version is not supported
 : by the currently running version of Zorba.
 : @error zerr:ZXQP8402 if the thesaurus data file's endianness does not match
 : that of the CPU on which Zorba is currently running.
 : @error zerr:ZXQP8403 if there was an error reading the thesaurus data file.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-thesaurus-lookup-4.xq
 :)
declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string,
                                      $lang as xs:language,
                                      $relationship as xs:string )
  as xs:string* external;

(:~
 : Looks-up the given phrase in a thesaurus.
 :
 : @param $uri The URI specifying the thesaurus to use.
 : @param $phrase The phrase to look up.
 : @param $lang The
 : language
 : of $phrase.
 : @param $relationship The relationship the results are to have to
 : $phrase.
 : @param $level-least The minimum number of levels within the thesaurus to be
 : travers$ed.
 : @param $level-most The maximum number of levels within the thesaurus to be
 : traversed.
 : @return the related phrases if $phrase is found in the
 : thesaurus or the empty sequence if not.
 : @error err:FOCA0003 if either $level-least or
 : $level-most is either negative or too large.
 : @error err:FTST0018 if $uri refers to a thesaurus
 : that is not found in the statically known thesauri.
 : @error err:FTST0009 if $lang is not supported.
 : @error zerr:ZOSE0001 if the thesaurus data file could not be found.
 : @error zerr:ZOSE0002 if the thesaurus data file is not a plain file.
 : @error zerr:ZXQP8401 if the thesaurus data file's version is not supported
 : by the currently running version of Zorba.
 : @error zerr:ZXQP8402 if the thesaurus data file's endianness does not match
 : that of the CPU on which Zorba is currently running.
 : @error zerr:ZXQP8403 if there was an error reading the thesaurus data file.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-thesaurus-lookup-5.xq
 :)
declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string,
                                      $lang as xs:language,
                                      $relationship as xs:string,
                                      $level-least as xs:integer,
                                      $level-most as xs:integer )
  as xs:string* external;

(:~
 : Tokenizes the given node and all of its decendants.
 :
 : @param $node The node to tokenize.
 : @param $lang The default
 : language
 : of $node.
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if $lang is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-node-1.xq
 :)
declare function ft:tokenize-node( $node as node(), $lang as xs:language )
  as element(ft-schema:token)* external;

(:~
 : Tokenizes the given node and all of its descendants.
 :
 : @param $node The node to tokenize.
 : The node's default
 : language
 : is assumed to be the one returned by ft:current-lang().
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-node-2.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-node-3.xq
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-node-4.xq
 :)
declare function ft:tokenize-node( $node as node() )
  as element(ft-schema:token)* external;

(:~
 : Tokenizes the set of nodes comprising $includes (and all of its
 : descendants) but excluding $excludes (and all of its
 : descendants), if any.
 :
 : @param $includes The set of nodes (and its descendants) to include.
 : The default
 : language
 : is assumed to be the one returned by ft:current-lang().
 : @param $excludes The set of nodes (and its descendants) to exclude.
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-nodes-1.xq
 :)
declare function ft:tokenize-nodes( $includes as node()+,
                                    $excludes as node()* )
  as element(ft-schema:token)* external;

(:~
 : Tokenizes the set of nodes comprising $includes (and all of its
 : descendants) but excluding $excludes (and all of its
 : descendants), if any.
 :
 : @param $includes The set of nodes (and its descendants) to include.
 : @param $excludes The set of nodes (and its descendants) to exclude.
 : @param $lang The default
 : language
 : for nodes.
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if $lang is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-nodes-1.xq
 :)
declare function ft:tokenize-nodes( $includes as node()+,
                                    $excludes as node()*,
                                    $lang as xs:language )
  as element(ft-schema:token)* external;

(:~
 : Tokenizes the given string.
 :
 : @param $string The string to tokenize.
 : @param $lang The
 : language
 : of $string.
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if $lang is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-string-1.xq
 :)
declare function ft:tokenize-string( $string as xs:string,
                                     $lang as xs:language )
  as xs:string* external;

(:~
 : Tokenizes the given string.
 :
 : @param $string The string to tokenize.
 : The string's
 : language
 : is assumed to be the one returned by ft:current-lang().
 : @return a (possibly empty) sequence of tokens.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 : @example test/rbkt/Queries/zorba/fulltext/ft-module-tokenize-string-2.xq
 :)
declare function ft:tokenize-string( $string as xs:string )
  as xs:string* external;

(:~
 : Gets properties of the tokenizer for the given
 : language.
 :
 : @param $lang The language of the tokenizer to get the properties of.
 : @return said properties.
 : @error err:FTST0009 if $lang is not supported.
 : tokenization specifically.
 :)
declare function ft:tokenizer-properties( $lang as xs:language )
  as element(ft-schema:tokenizer-properties) external;

(:~
 : Gets properties of the tokenizer for the
 : language
 : returned by ft:current-lang().
 :
 : @return said properties.
 : @error err:FTST0009 if ft:current-lang() is not supported.
 :)
declare function ft:tokenizer-properties()
  as element(ft-schema:tokenizer-properties) external;

(:===========================================================================:)

(: vim:set et sw=2 ts=2: :)


introducing a link to the quick reference card in the fn doc

(:~
 :
This module contains all the functions specified in the
 : W3C's XQuery 1.0 and XPath 2.0 Functions and Operators specification.

 :
 :
A quick reference card of all those functions can be found at
 :
 : http://www.xml.dvint.com/docs/XQueryXMLSyntax.pdf.

 :
 : @author www.w3c.org
 :)
module namespace  fn = "http://www.w3.org/2005/xpath-functions";

(:~
 : @see for semantics please check fn:abs
 :)
declare function  fn:abs ($arg as numeric?) as numeric?  external;

(:~
 : @see for semantics please check fn:adjust-date-to-timezone
 :)
declare function  fn:adjust-date-to-timezone ( $arg as xs:date?) as xs:date?  external;

(:~
 : @see for semantics please check fn:adjust-date-to-timezone
 :)
declare function  fn:adjust-date-to-timezone ( $arg as xs:date?, $timezone as xs:dayTimeDuration?) as xs:date?  external;

(:~
 : @see for semantics please check fn:adjust-dateTime-to-timezone
 :)
declare function  fn:adjust-dateTime-to-timezone ( $arg as xs:dateTime?) as xs:dateTime?  external;

(:~
 : @see for semantics please check fn:adjust-dateTime-to-timezone
 :)
declare function  fn:adjust-dateTime-to-timezone ( $arg as xs:dateTime?, $timezone as xs:dayTimeDuration?) as xs:dateTime?  external;

(:~
 : @see for semantics please check fn:adjust-time-to-timezone
 :)
declare function  fn:adjust-time-to-timezone ( $arg as xs:time?) as xs:time?  external;

(:~
 : @see for semantics please check fn:adjust-time-to-timezone
 :)
declare function  fn:adjust-time-to-timezone ( $arg as xs:time?, $timezone as xs:dayTimeDuration?) as xs:time?  external;

(:~
 : @see for semantics please check fn:avg
 :)
declare function  fn:avg ($arg as xs:anyAtomicType*) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:base-uri
 :)
declare function  fn:base-uri () as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:base-uri
 :)
declare function  fn:base-uri ($arg as node()?) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:boolean
 :)
declare function  fn:boolean ($arg as item()*) as xs:boolean  external;

(:~
 : @see for semantics please check fn:ceiling
 :)
declare function  fn:ceiling ($arg as numeric?) as numeric?  external;

(:~
 : @see for semantics please check fn:codepoint-equal
 :)
declare function  fn:codepoint-equal ($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:boolean?  external;

(:~
 : @see for semantics please check fn:codepoints-to-string
 :)
declare function  fn:codepoints-to-string ( $arg as xs:integer*) as xs:string  external;

(:~
 : @see for semantics please check fn:collection
 :)
declare function  fn:collection () as node()*  external;

(:~
 : @see for semantics please check fn:collection
 :)
declare function  fn:collection ($arg as xs:string?) as node()*  external;

(:~
 : @see for semantics please check fn:compare
 :)
declare function  fn:compare ($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:compare
 :)
declare function  fn:compare ($comparand1 as xs:string?, $comparand2 as xs:string?, $collation as xs:string) as xs:integer?  external;

(:~
 : @see for semantics please check fn:concat
 :)
declare function  fn:concat ($arg1 as xs:anyAtomicType?, $arg2 as xs:anyAtomicType?) as xs:string  external;

(:~
 : @see for semantics please check fn:contains
 :)
declare function  fn:contains ($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean  external;

(:~
 : @see for semantics please check fn:contains
 :)
declare function  fn:contains ($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:count
 :)
declare function  fn:count ($arg as item()*) as xs:integer  external;

(:~
 : @see for semantics please check fn:current-date
 :)
declare function  fn:current-date () as xs:date  external;

(:~
 : @see for semantics please check fn:current-dateTime
 :)
declare function  fn:current-dateTime () as xs:dateTime  external;

(:~
 : @see for semantics please check fn:current-time
 :)
declare function  fn:current-time () as xs:time  external;

(:~
 : @see for semantics please check fn:data
 :)
declare function  fn:data ($arg as item()*) as xs:anyAtomicType*  external;

(:~
 : @see for semantics please check fn:dateTime
 :)
declare function  fn:dateTime ($arg1 as xs:date?, $arg2 as xs:time?) as xs:dateTime?  external;

(:~
 : @see for semantics please check fn:day-from-date
 :)
declare function  fn:day-from-date ($arg as xs:date?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:day-from-dateTime
 :)
declare function  fn:day-from-dateTime ( $arg as xs:dateTime?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:days-from-duration
 :)
declare function  fn:days-from-duration ( $arg as xs:duration?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:deep-equal
 :)
declare function  fn:deep-equal ($parameter1 as item()*, $parameter2 as item()*) as xs:boolean  external;

(:~
 : @see for semantics please check fn:deep-equal
 :)
declare function  fn:deep-equal ($parameter1 as item()*, $parameter2 as item()*, $collation as string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:default-collation
 :)
declare function  fn:default-collation () as xs:string  external;

(:~
 : @see for semantics please check fn:distinct-values
 :)
declare function  fn:distinct-values ($arg as xs:anyAtomicType*) as xs:anyAtomicType*  external;

(:~
 : @see for semantics please check fn:distinct-values
 :)
declare function  fn:distinct-values ($arg as xs:anyAtomicType*, $collation as xs:string) as xs:anyAtomicType*  external;

(:~
 : @see for semantics please check fn:doc
 :)
declare function  fn:doc ($uri as xs:string?) as document-node()?  external;

(:~
 : @see for semantics please check fn:doc-available
 :)
declare function  fn:doc-available ($uri as xs:string?) as xs:boolean  external;

(:~
 : @see for semantics please check fn:document-uri
 :)
declare function  fn:document-uri ($arg as node()?) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:empty
 :)
declare function  fn:empty ($arg as item()*) as xs:boolean  external;

(:~
 : @see for semantics please check fn:encode-for-uri
 :)
declare function  fn:encode-for-uri ($uri-part as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:ends-with
 :)
declare function  fn:ends-with ($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean  external;

(:~
 : @see for semantics please check fn:ends-with
 :)
declare function  fn:ends-with ($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:error
 :)
declare function  fn:error () as none  external;

(:~
 : @see for semantics please check fn:error
 :)
declare function  fn:error ($error as xs:QName) as none  external;

(:~
 : @see for semantics please check fn:error
 :)
declare function  fn:error ($error as xs:QName?, $description as xs:string) as none  external;

(:~
 : @see for semantics please check fn:error
 :)
declare function  fn:error ($error as xs:QName?, $description as xs:string, $error-object as item()*) as none  external;

(:~
 : @see for semantics please check fn:escape-html-uri
 :)
declare function  fn:escape-html-uri ($uri as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:exactly-one
 :)
declare function  fn:exactly-one ($arg as item()*) as item()  external;

(:~
 : @see for semantics please check fn:exists
 :)
declare function  fn:exists ($arg as item()*) as xs:boolean  external;

(:~
 : @see for semantics please check fn:false
 :)
declare function  fn:false () as xs:boolean  external;

(:~
 : @see for semantics please check fn:floor
 :)
declare function  fn:floor ($arg as numeric?) as numeric?  external;

(:~
 : @see for semantics please check fn:hours-from-dateTime
 :)
declare function  fn:hours-from-dateTime ( $arg as xs:dateTime?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:hours-from-duration
 :)
declare function  fn:hours-from-duration ( $arg as xs:duration?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:hours-from-time
 :)
declare function  fn:hours-from-time ($arg as xs:time?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:id
 :)
declare function  fn:id ($arg as xs:string*) as element()*  external;

(:~
 : @see for semantics please check fn:id
 :)
declare function  fn:id ($arg as xs:string*, $node as node()) as element()*  external;

(:~
 : @see for semantics please check fn:idref
 :)
declare function  fn:idref ($arg as xs:string*) as node()*  external;

(:~
 : @see for semantics please check fn:idref
 :)
declare function  fn:idref ($arg as xs:string*, $node as node()) as node()*  external;

(:~
 : @see for semantics please check fn:implicit-timezone
 :)
declare function  fn:implicit-timezone () as xs:dayTimeDuration  external;

(:~
 : @see for semantics please check fn:in-scope-prefixes
 :)
declare function  fn:in-scope-prefixes ( $element as element()) as xs:string*  external;

(:~
 : @see for semantics please check fn:index-of
 :)
declare function  fn:index-of ($seqParam as xs:anyAtomicType*, $srchParam as xs:anyAtomicType) as xs:integer*  external;

(:~
 : @see for semantics please check fn:index-of
 :)
declare function  fn:index-of ($seqParam as xs:anyAtomicType*, $srchParam as xs:anyAtomicType, $collation as xs:string) as xs:integer*  external;

(:~
 : @see for semantics please check fn:insert-before
 :)
declare function  fn:insert-before ($target as item()*, $position as xs:integer, $inserts as item()*) as item()*  external;

(:~
 : @see for semantics please check fn:iri-to-uri
 :)
declare function  fn:iri-to-uri ($iri as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:lang
 :)
declare function  fn:lang ($testlang as xs:string?) as xs:boolean  external;

(:~
 : @see for semantics please check fn:lang
 :)
declare function  fn:lang ($testlang as xs:string?, $node as node()) as xs:boolean  external;

(:~
 : @see for semantics please check fn:last
 :)
declare function  fn:last () as xs:integer  external;

(:~
 : @see for semantics please check fn:local-name
 :)
declare function  fn:local-name () as xs:string  external;

(:~
 : @see for semantics please check fn:local-name
 :)
declare function  fn:local-name ($arg as node()?) as xs:string  external;

(:~
 : @see for semantics please check fn:local-name-from-QName
 :)
declare function  fn:local-name-from-QName ( $arg as xs:QName?) as xs:NCName?  external;

(:~
 : @see for semantics please check fn:lower-case
 :)
declare function  fn:lower-case ($arg as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:matches
 :)
declare function  fn:matches ($input as xs:string?, $pattern as xs:string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:matches
 :)
declare function  fn:matches ($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:max
 :)
declare function  fn:max ($arg as xs:anyAtomicType*) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:max
 :)
declare function  fn:max ($arg as xs:anyAtomicType*, $collation as string) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:min
 :)
declare function  fn:min ($arg as xs:anyAtomicType*) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:min
 :)
declare function  fn:min ($arg as xs:anyAtomicType*, $collation as string) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:minutes-from-dateTime
 :)
declare function  fn:minutes-from-dateTime ( $arg as xs:dateTime?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:minutes-from-duration
 :)
declare function  fn:minutes-from-duration ( $arg as xs:duration?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:minutes-from-time
 :)
declare function  fn:minutes-from-time ( $arg as xs:time?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:month-from-date
 :)
declare function  fn:month-from-date ($arg as xs:date?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:month-from-dateTime
 :)
declare function  fn:month-from-dateTime ( $arg as xs:dateTime?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:months-from-duration
 :)
declare function  fn:months-from-duration ( $arg as xs:duration?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:name
 :)
declare function  fn:name () as xs:string  external;

(:~
 : @see for semantics please check fn:name
 :)
declare function  fn:name ($arg as node()?) as xs:string  external;

(:~
 : @see for semantics please check fn:namespace-uri
 :)
declare function  fn:namespace-uri () as xs:anyURI  external;

(:~
 : @see for semantics please check fn:namespace-uri
 :)
declare function  fn:namespace-uri ($arg as node()?) as xs:anyURI  external;

(:~
 : @see for semantics please check fn:namespace-uri-for-prefix
 :)
declare function  fn:namespace-uri-for-prefix ( $prefix as xs:string?, $element as element()) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:namespace-uri-from-QName
 :)
declare function  fn:namespace-uri-from-QName ( $arg as xs:QName?) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:nilled
 :)
declare function  fn:nilled ($arg as node()?) as xs:boolean?  external;

(:~
 : @see for semantics please check fn:node-name
 :)
declare function  fn:node-name ($arg as node()?) as xs:QName?  external;

(:~
 : @see for semantics please check fn:normalize-space
 :)
declare function  fn:normalize-space () as xs:string  external;

(:~
 : @see for semantics please check fn:normalize-space
 :)
declare function  fn:normalize-space ($arg as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:normalize-unicode
 :)
declare function  fn:normalize-unicode ( $arg as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:normalize-unicode
 :)
declare function  fn:normalize-unicode ( $arg as xs:string?, $normalizationForm as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:not
 :)
declare function  fn:not ($arg as item()*) as xs:boolean  external;

(:~
 : @see for semantics please check fn:number
 :)
declare function  fn:number () as xs:double  external;

(:~
 : @see for semantics please check fn:number
 :)
declare function  fn:number ($arg as xs:anyAtomicType?) as xs:double  external;

(:~
 : @see for semantics please check fn:one-or-more
 :)
declare function  fn:one-or-more ($arg as item()*) as item()+  external;

(:~
 : @see for semantics please check fn:position
 :)
declare function  fn:position () as xs:integer  external;

(:~
 : @see for semantics please check fn:prefix-from-QName
 :)
declare function  fn:prefix-from-QName ( $arg as xs:QName?) as xs:NCName?  external;

(:~
 : @see for semantics please check fn:QName
 :)
declare function  fn:QName ($paramURI as xs:string?, $paramQName as xs:string) as xs:QName  external;

(:~
 : @see for semantics please check fn:remove
 :)
declare function  fn:remove ($target as item()*, $position as xs:integer) as item()*  external;

(:~
 : @see for semantics please check fn:replace
 :)
declare function  fn:replace ($input as xs:string?, $pattern as xs:string, $replacement as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:replace
 :)
declare function  fn:replace ($input as xs:string?, $pattern as xs:string, $replacement as xs:string, $flags as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:resolve-QName
 :)
declare function  fn:resolve-QName ($qname as xs:string?, $element as element()) as xs:QName?  external;

(:~
 : @see for semantics please check fn:resolve-uri
 :)
declare function  fn:resolve-uri ($relative as xs:string?) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:resolve-uri
 :)
declare function  fn:resolve-uri ($relative as xs:string?, $base as xs:string) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:reverse
 :)
declare function  fn:reverse ($arg as item()*) as item()*  external;

(:~
 : @see for semantics please check fn:root
 :)
declare function  fn:root () as node()  external;

(:~
 : @see for semantics please check fn:root
 :)
declare function  fn:root ($arg as node()?) as node()?  external;

(:~
 : @see for semantics please check fn:round
 :)
declare function  fn:round ($arg as numeric?) as numeric?  external;

(:~
 : @see for semantics please check fn:round-half-to-even
 :)
declare function  fn:round-half-to-even ( $arg as numeric?) as numeric?  external;

(:~
 : @see for semantics please check fn:round-half-to-even
 :)
declare function  fn:round-half-to-even ( $arg as numeric?, $precision as xs:integer) as numeric?  external;

(:~
 : @see for semantics please check fn:seconds-from-dateTime
 :)
declare function  fn:seconds-from-dateTime ( $arg as xs:dateTime?) as xs:decimal?  external;

(:~
 : @see for semantics please check fn:seconds-from-duration
 :)
declare function  fn:seconds-from-duration ( $arg as xs:duration?) as xs:decimal?  external;

(:~
 : @see for semantics please check fn:seconds-from-time
 :)
declare function  fn:seconds-from-time ( $arg as xs:time?) as xs:decimal?  external;

(:~
 : @see for semantics please check fn:starts-with
 :)
declare function  fn:starts-with ($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean  external;

(:~
 : @see for semantics please check fn:starts-with
 :)
declare function  fn:starts-with ($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:static-base-uri
 :)
declare function  fn:static-base-uri () as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:string
 :)
declare function  fn:string () as xs:string  external;

(:~
 : @see for semantics please check fn:string
 :)
declare function  fn:string ($arg as item()?) as xs:string  external;

(:~
 : @see for semantics please check fn:string-join
 :)
declare function  fn:string-join ($arg1 as xs:string*, $arg2 as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:string-length
 :)
declare function  fn:string-length () as xs:integer  external;

(:~
 : @see for semantics please check fn:string-length
 :)
declare function  fn:string-length ($arg as xs:string?) as xs:integer  external;

(:~
 : @see for semantics please check fn:string-to-codepoints
 :)
declare function  fn:string-to-codepoints ( $arg as xs:string?) as xs:integer*  external;

(:~
 : @see for semantics please check fn:subsequence
 :)
declare function  fn:subsequence ($sourceSeq as item()*, $startingLoc as xs:double) as item()*  external;

(:~
 : @see for semantics please check fn:subsequence
 :)
declare function  fn:subsequence ($sourceSeq as item()*, $startingLoc as xs:double, $length as xs:double) as item()*  external;

(:~
 : @see for semantics please check fn:substring
 :)
declare function  fn:substring ($sourceString as xs:string?, $startingLoc as xs:double) as xs:string  external;

(:~
 : @see for semantics please check fn:substring
 :)
declare function  fn:substring ($sourceString as xs:string?, $startingLoc as xs:double, $length as xs:double) as xs:string  external;

(:~
 : @see for semantics please check fn:substring-after
 :)
declare function  fn:substring-after ($arg1 as xs:string?, $arg2 as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:substring-after
 :)
declare function  fn:substring-after ($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:substring-before
 :)
declare function  fn:substring-before ( $arg1 as xs:string?, $arg2 as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:substring-before
 :)
declare function  fn:substring-before ( $arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:sum
 :)
declare function  fn:sum ($arg as xs:anyAtomicType*) as xs:anyAtomicType  external;

(:~
 : @see for semantics please check fn:sum
 :)
declare function  fn:sum ($arg as xs:anyAtomicType*, $zero as xs:anyAtomicType?) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:timezone-from-date
 :)
declare function  fn:timezone-from-date ( $arg as xs:date?) as xs:dayTimeDuration?  external;

(:~
 : @see for semantics please check fn:timezone-from-dateTime
 :)
declare function  fn:timezone-from-dateTime ( $arg as xs:dateTime?) as xs:dayTimeDuration?  external;

(:~
 : @see for semantics please check fn:timezone-from-time
 :)
declare function  fn:timezone-from-time ( $arg as xs:time?) as xs:dayTimeDuration?  external;

(:~
 : @see for semantics please check fn:tokenize
 :)
declare function  fn:tokenize ($input as xs:string?, $pattern as xs:string) as xs:string*  external;

(:~
 : @see for semantics please check fn:tokenize
 :)
declare function  fn:tokenize ($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:string*  external;

(:~
 : @see for semantics please check fn:trace
 :)
declare function  fn:trace ($value as item()*, $label as xs:string) as item()*  external;

(:~
 : @see for semantics please check fn:translate
 :)
declare function  fn:translate ($arg as xs:string?, $mapString as xs:string, $transString as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:true
 :)
declare function  fn:true () as xs:boolean  external;

(:~
 : @see for semantics please check fn:unordered
 :)
declare function  fn:unordered ($sourceSeq as item()*) as item()*  external;

(:~
 : @see for semantics please check fn:upper-case
 :)
declare function  fn:upper-case ($arg as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:year-from-date
 :)
declare function  fn:year-from-date ($arg as xs:date?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:year-from-dateTime
 :)
declare function  fn:year-from-dateTime ( $arg as xs:dateTime?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:years-from-duration
 :)
declare function  fn:years-from-duration ( $arg as xs:duration?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:zero-or-one
 :)
declare function  fn:zero-or-one ($arg as item()*) as item()?  external;

(:~
 : @author www.w3c.org
 :)
module namespace  fn = "http://www.w3.org/2005/xpath-functions";

(:~
 : @see for semantics please check fn:abs
 :)
declare function  fn:abs ($arg as numeric?) as numeric?  external;

(:~
 : @see for semantics please check fn:adjust-date-to-timezone
 :)
declare function  fn:adjust-date-to-timezone ( $arg as xs:date?) as xs:date?  external;

(:~
 : @see for semantics please check fn:adjust-date-to-timezone
 :)
declare function  fn:adjust-date-to-timezone ( $arg as xs:date?, $timezone as xs:dayTimeDuration?) as xs:date?  external;

(:~
 : @see for semantics please check fn:adjust-dateTime-to-timezone
 :)
declare function  fn:adjust-dateTime-to-timezone ( $arg as xs:dateTime?) as xs:dateTime?  external;

(:~
 : @see for semantics please check fn:adjust-dateTime-to-timezone
 :)
declare function  fn:adjust-dateTime-to-timezone ( $arg as xs:dateTime?, $timezone as xs:dayTimeDuration?) as xs:dateTime?  external;

(:~
 : @see for semantics please check fn:adjust-time-to-timezone
 :)
declare function  fn:adjust-time-to-timezone ( $arg as xs:time?) as xs:time?  external;

(:~
 : @see for semantics please check fn:adjust-time-to-timezone
 :)
declare function  fn:adjust-time-to-timezone ( $arg as xs:time?, $timezone as xs:dayTimeDuration?) as xs:time?  external;

(:~
 : @see for semantics please check fn:avg
 :)
declare function  fn:avg ($arg as xs:anyAtomicType*) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:base-uri
 :)
declare function  fn:base-uri () as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:base-uri
 :)
declare function  fn:base-uri ($arg as node()?) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:boolean
 :)
declare function  fn:boolean ($arg as item()*) as xs:boolean  external;

(:~
 : @see for semantics please check fn:ceiling
 :)
declare function  fn:ceiling ($arg as numeric?) as numeric?  external;

(:~
 : @see for semantics please check fn:codepoint-equal
 :)
declare function  fn:codepoint-equal ($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:boolean?  external;

(:~
 : @see for semantics please check fn:codepoints-to-string
 :)
declare function  fn:codepoints-to-string ( $arg as xs:integer*) as xs:string  external;

(:~
 : @see for semantics please check fn:collection
 :)
declare function  fn:collection () as node()*  external;

(:~
 : @see for semantics please check fn:collection
 :)
declare function  fn:collection ($arg as xs:string?) as node()*  external;

(:~
 : @see for semantics please check fn:compare
 :)
declare function  fn:compare ($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:compare
 :)
declare function  fn:compare ($comparand1 as xs:string?, $comparand2 as xs:string?, $collation as xs:string) as xs:integer?  external;

(:~
 : @see for semantics please check fn:concat
 :)
declare function  fn:concat ($arg1 as xs:anyAtomicType?, $arg2 as xs:anyAtomicType?) as xs:string  external;

(:~
 : @see for semantics please check fn:contains
 :)
declare function  fn:contains ($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean  external;

(:~
 : @see for semantics please check fn:contains
 :)
declare function  fn:contains ($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:count
 :)
declare function  fn:count ($arg as item()*) as xs:integer  external;

(:~
 : @see for semantics please check fn:current-date
 :)
declare function  fn:current-date () as xs:date  external;

(:~
 : @see for semantics please check fn:current-dateTime
 :)
declare function  fn:current-dateTime () as xs:dateTime  external;

(:~
 : @see for semantics please check fn:current-time
 :)
declare function  fn:current-time () as xs:time  external;

(:~
 : @see for semantics please check fn:data
 :)
declare function  fn:data ($arg as item()*) as xs:anyAtomicType*  external;

(:~
 : @see for semantics please check fn:dateTime
 :)
declare function  fn:dateTime ($arg1 as xs:date?, $arg2 as xs:time?) as xs:dateTime?  external;

(:~
 : @see for semantics please check fn:day-from-date
 :)
declare function  fn:day-from-date ($arg as xs:date?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:day-from-dateTime
 :)
declare function  fn:day-from-dateTime ( $arg as xs:dateTime?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:days-from-duration
 :)
declare function  fn:days-from-duration ( $arg as xs:duration?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:deep-equal
 :)
declare function  fn:deep-equal ($parameter1 as item()*, $parameter2 as item()*) as xs:boolean  external;

(:~
 : @see for semantics please check fn:deep-equal
 :)
declare function  fn:deep-equal ($parameter1 as item()*, $parameter2 as item()*, $collation as string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:default-collation
 :)
declare function  fn:default-collation () as xs:string  external;

(:~
 : @see for semantics please check fn:distinct-values
 :)
declare function  fn:distinct-values ($arg as xs:anyAtomicType*) as xs:anyAtomicType*  external;

(:~
 : @see for semantics please check fn:distinct-values
 :)
declare function  fn:distinct-values ($arg as xs:anyAtomicType*, $collation as xs:string) as xs:anyAtomicType*  external;

(:~
 : @see for semantics please check fn:doc
 :)
declare function  fn:doc ($uri as xs:string?) as document-node()?  external;

(:~
 : @see for semantics please check fn:doc-available
 :)
declare function  fn:doc-available ($uri as xs:string?) as xs:boolean  external;

(:~
 : @see for semantics please check fn:document-uri
 :)
declare function  fn:document-uri ($arg as node()?) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:empty
 :)
declare function  fn:empty ($arg as item()*) as xs:boolean  external;

(:~
 : @see for semantics please check fn:encode-for-uri
 :)
declare function  fn:encode-for-uri ($uri-part as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:ends-with
 :)
declare function  fn:ends-with ($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean  external;

(:~
 : @see for semantics please check fn:ends-with
 :)
declare function  fn:ends-with ($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:error
 :)
declare function  fn:error () as none  external;

(:~
 : @see for semantics please check fn:error
 :)
declare function  fn:error ($error as xs:QName) as none  external;

(:~
 : @see for semantics please check fn:error
 :)
declare function  fn:error ($error as xs:QName?, $description as xs:string) as none  external;

(:~
 : @see for semantics please check fn:error
 :)
declare function  fn:error ($error as xs:QName?, $description as xs:string, $error-object as item()*) as none  external;

(:~
 : @see for semantics please check fn:escape-html-uri
 :)
declare function  fn:escape-html-uri ($uri as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:exactly-one
 :)
declare function  fn:exactly-one ($arg as item()*) as item()  external;

(:~
 : @see for semantics please check fn:exists
 :)
declare function  fn:exists ($arg as item()*) as xs:boolean  external;

(:~
 : @see for semantics please check fn:false
 :)
declare function  fn:false () as xs:boolean  external;

(:~
 : @see for semantics please check fn:floor
 :)
declare function  fn:floor ($arg as numeric?) as numeric?  external;

(:~
 : @see for semantics please check fn:hours-from-dateTime
 :)
declare function  fn:hours-from-dateTime ( $arg as xs:dateTime?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:hours-from-duration
 :)
declare function  fn:hours-from-duration ( $arg as xs:duration?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:hours-from-time
 :)
declare function  fn:hours-from-time ($arg as xs:time?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:id
 :)
declare function  fn:id ($arg as xs:string*) as element()*  external;

(:~
 : @see for semantics please check fn:id
 :)
declare function  fn:id ($arg as xs:string*, $node as node()) as element()*  external;

(:~
 : @see for semantics please check fn:idref
 :)
declare function  fn:idref ($arg as xs:string*) as node()*  external;

(:~
 : @see for semantics please check fn:idref
 :)
declare function  fn:idref ($arg as xs:string*, $node as node()) as node()*  external;

(:~
 : @see for semantics please check fn:implicit-timezone
 :)
declare function  fn:implicit-timezone () as xs:dayTimeDuration  external;

(:~
 : @see for semantics please check fn:in-scope-prefixes
 :)
declare function  fn:in-scope-prefixes ( $element as element()) as xs:string*  external;

(:~
 : @see for semantics please check fn:index-of
 :)
declare function  fn:index-of ($seqParam as xs:anyAtomicType*, $srchParam as xs:anyAtomicType) as xs:integer*  external;

(:~
 : @see for semantics please check fn:index-of
 :)
declare function  fn:index-of ($seqParam as xs:anyAtomicType*, $srchParam as xs:anyAtomicType, $collation as xs:string) as xs:integer*  external;

(:~
 : @see for semantics please check fn:insert-before
 :)
declare function  fn:insert-before ($target as item()*, $position as xs:integer, $inserts as item()*) as item()*  external;

(:~
 : @see for semantics please check fn:iri-to-uri
 :)
declare function  fn:iri-to-uri ($iri as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:lang
 :)
declare function  fn:lang ($testlang as xs:string?) as xs:boolean  external;

(:~
 : @see for semantics please check fn:lang
 :)
declare function  fn:lang ($testlang as xs:string?, $node as node()) as xs:boolean  external;

(:~
 : @see for semantics please check fn:last
 :)
declare function  fn:last () as xs:integer  external;

(:~
 : @see for semantics please check fn:local-name
 :)
declare function  fn:local-name () as xs:string  external;

(:~
 : @see for semantics please check fn:local-name
 :)
declare function  fn:local-name ($arg as node()?) as xs:string  external;

(:~
 : @see for semantics please check fn:local-name-from-QName
 :)
declare function  fn:local-name-from-QName ( $arg as xs:QName?) as xs:NCName?  external;

(:~
 : @see for semantics please check fn:lower-case
 :)
declare function  fn:lower-case ($arg as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:matches
 :)
declare function  fn:matches ($input as xs:string?, $pattern as xs:string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:matches
 :)
declare function  fn:matches ($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:max
 :)
declare function  fn:max ($arg as xs:anyAtomicType*) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:max
 :)
declare function  fn:max ($arg as xs:anyAtomicType*, $collation as string) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:min
 :)
declare function  fn:min ($arg as xs:anyAtomicType*) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:min
 :)
declare function  fn:min ($arg as xs:anyAtomicType*, $collation as string) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:minutes-from-dateTime
 :)
declare function  fn:minutes-from-dateTime ( $arg as xs:dateTime?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:minutes-from-duration
 :)
declare function  fn:minutes-from-duration ( $arg as xs:duration?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:minutes-from-time
 :)
declare function  fn:minutes-from-time ( $arg as xs:time?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:month-from-date
 :)
declare function  fn:month-from-date ($arg as xs:date?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:month-from-dateTime
 :)
declare function  fn:month-from-dateTime ( $arg as xs:dateTime?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:months-from-duration
 :)
declare function  fn:months-from-duration ( $arg as xs:duration?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:name
 :)
declare function  fn:name () as xs:string  external;

(:~
 : @see for semantics please check fn:name
 :)
declare function  fn:name ($arg as node()?) as xs:string  external;

(:~
 : @see for semantics please check fn:namespace-uri
 :)
declare function  fn:namespace-uri () as xs:anyURI  external;

(:~
 : @see for semantics please check fn:namespace-uri
 :)
declare function  fn:namespace-uri ($arg as node()?) as xs:anyURI  external;

(:~
 : @see for semantics please check fn:namespace-uri-for-prefix
 :)
declare function  fn:namespace-uri-for-prefix ( $prefix as xs:string?, $element as element()) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:namespace-uri-from-QName
 :)
declare function  fn:namespace-uri-from-QName ( $arg as xs:QName?) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:nilled
 :)
declare function  fn:nilled ($arg as node()?) as xs:boolean?  external;

(:~
 : @see for semantics please check fn:node-name
 :)
declare function  fn:node-name ($arg as node()?) as xs:QName?  external;

(:~
 : @see for semantics please check fn:normalize-space
 :)
declare function  fn:normalize-space () as xs:string  external;

(:~
 : @see for semantics please check fn:normalize-space
 :)
declare function  fn:normalize-space ($arg as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:normalize-unicode
 :)
declare function  fn:normalize-unicode ( $arg as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:normalize-unicode
 :)
declare function  fn:normalize-unicode ( $arg as xs:string?, $normalizationForm as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:not
 :)
declare function  fn:not ($arg as item()*) as xs:boolean  external;

(:~
 : @see for semantics please check fn:number
 :)
declare function  fn:number () as xs:double  external;

(:~
 : @see for semantics please check fn:number
 :)
declare function  fn:number ($arg as xs:anyAtomicType?) as xs:double  external;

(:~
 : @see for semantics please check fn:one-or-more
 :)
declare function  fn:one-or-more ($arg as item()*) as item()+  external;

(:~
 : @see for semantics please check fn:position
 :)
declare function  fn:position () as xs:integer  external;

(:~
 : @see for semantics please check fn:prefix-from-QName
 :)
declare function  fn:prefix-from-QName ( $arg as xs:QName?) as xs:NCName?  external;

(:~
 : @see for semantics please check fn:QName
 :)
declare function  fn:QName ($paramURI as xs:string?, $paramQName as xs:string) as xs:QName  external;

(:~
 : @see for semantics please check fn:remove
 :)
declare function  fn:remove ($target as item()*, $position as xs:integer) as item()*  external;

(:~
 : @see for semantics please check fn:replace
 :)
declare function  fn:replace ($input as xs:string?, $pattern as xs:string, $replacement as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:replace
 :)
declare function  fn:replace ($input as xs:string?, $pattern as xs:string, $replacement as xs:string, $flags as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:resolve-QName
 :)
declare function  fn:resolve-QName ($qname as xs:string?, $element as element()) as xs:QName?  external;

(:~
 : @see for semantics please check fn:resolve-uri
 :)
declare function  fn:resolve-uri ($relative as xs:string?) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:resolve-uri
 :)
declare function  fn:resolve-uri ($relative as xs:string?, $base as xs:string) as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:reverse
 :)
declare function  fn:reverse ($arg as item()*) as item()*  external;

(:~
 : @see for semantics please check fn:root
 :)
declare function  fn:root () as node()  external;

(:~
 : @see for semantics please check fn:root
 :)
declare function  fn:root ($arg as node()?) as node()?  external;

(:~
 : @see for semantics please check fn:round
 :)
declare function  fn:round ($arg as numeric?) as numeric?  external;

(:~
 : @see for semantics please check fn:round-half-to-even
 :)
declare function  fn:round-half-to-even ( $arg as numeric?) as numeric?  external;

(:~
 : @see for semantics please check fn:round-half-to-even
 :)
declare function  fn:round-half-to-even ( $arg as numeric?, $precision as xs:integer) as numeric?  external;

(:~
 : @see for semantics please check fn:seconds-from-dateTime
 :)
declare function  fn:seconds-from-dateTime ( $arg as xs:dateTime?) as xs:decimal?  external;

(:~
 : @see for semantics please check fn:seconds-from-duration
 :)
declare function  fn:seconds-from-duration ( $arg as xs:duration?) as xs:decimal?  external;

(:~
 : @see for semantics please check fn:seconds-from-time
 :)
declare function  fn:seconds-from-time ( $arg as xs:time?) as xs:decimal?  external;

(:~
 : @see for semantics please check fn:starts-with
 :)
declare function  fn:starts-with ($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean  external;

(:~
 : @see for semantics please check fn:starts-with
 :)
declare function  fn:starts-with ($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean  external;

(:~
 : @see for semantics please check fn:static-base-uri
 :)
declare function  fn:static-base-uri () as xs:anyURI?  external;

(:~
 : @see for semantics please check fn:string
 :)
declare function  fn:string () as xs:string  external;

(:~
 : @see for semantics please check fn:string
 :)
declare function  fn:string ($arg as item()?) as xs:string  external;

(:~
 : @see for semantics please check fn:string-join
 :)
declare function  fn:string-join ($arg1 as xs:string*, $arg2 as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:string-length
 :)
declare function  fn:string-length () as xs:integer  external;

(:~
 : @see for semantics please check fn:string-length
 :)
declare function  fn:string-length ($arg as xs:string?) as xs:integer  external;

(:~
 : @see for semantics please check fn:string-to-codepoints
 :)
declare function  fn:string-to-codepoints ( $arg as xs:string?) as xs:integer*  external;

(:~
 : @see for semantics please check fn:subsequence
 :)
declare function  fn:subsequence ($sourceSeq as item()*, $startingLoc as xs:double) as item()*  external;

(:~
 : @see for semantics please check fn:subsequence
 :)
declare function  fn:subsequence ($sourceSeq as item()*, $startingLoc as xs:double, $length as xs:double) as item()*  external;

(:~
 : @see for semantics please check fn:substring
 :)
declare function  fn:substring ($sourceString as xs:string?, $startingLoc as xs:double) as xs:string  external;

(:~
 : @see for semantics please check fn:substring
 :)
declare function  fn:substring ($sourceString as xs:string?, $startingLoc as xs:double, $length as xs:double) as xs:string  external;

(:~
 : @see for semantics please check fn:substring-after
 :)
declare function  fn:substring-after ($arg1 as xs:string?, $arg2 as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:substring-after
 :)
declare function  fn:substring-after ($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:substring-before
 :)
declare function  fn:substring-before ( $arg1 as xs:string?, $arg2 as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:substring-before
 :)
declare function  fn:substring-before ( $arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:sum
 :)
declare function  fn:sum ($arg as xs:anyAtomicType*) as xs:anyAtomicType  external;

(:~
 : @see for semantics please check fn:sum
 :)
declare function  fn:sum ($arg as xs:anyAtomicType*, $zero as xs:anyAtomicType?) as xs:anyAtomicType?  external;

(:~
 : @see for semantics please check fn:timezone-from-date
 :)
declare function  fn:timezone-from-date ( $arg as xs:date?) as xs:dayTimeDuration?  external;

(:~
 : @see for semantics please check fn:timezone-from-dateTime
 :)
declare function  fn:timezone-from-dateTime ( $arg as xs:dateTime?) as xs:dayTimeDuration?  external;

(:~
 : @see for semantics please check fn:timezone-from-time
 :)
declare function  fn:timezone-from-time ( $arg as xs:time?) as xs:dayTimeDuration?  external;

(:~
 : @see for semantics please check fn:tokenize
 :)
declare function  fn:tokenize ($input as xs:string?, $pattern as xs:string) as xs:string*  external;

(:~
 : @see for semantics please check fn:tokenize
 :)
declare function  fn:tokenize ($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:string*  external;

(:~
 : @see for semantics please check fn:trace
 :)
declare function  fn:trace ($value as item()*, $label as xs:string) as item()*  external;

(:~
 : @see for semantics please check fn:translate
 :)
declare function  fn:translate ($arg as xs:string?, $mapString as xs:string, $transString as xs:string) as xs:string  external;

(:~
 : @see for semantics please check fn:true
 :)
declare function  fn:true () as xs:boolean  external;

(:~
 : @see for semantics please check fn:unordered
 :)
declare function  fn:unordered ($sourceSeq as item()*) as item()*  external;

(:~
 : @see for semantics please check fn:upper-case
 :)
declare function  fn:upper-case ($arg as xs:string?) as xs:string  external;

(:~
 : @see for semantics please check fn:year-from-date
 :)
declare function  fn:year-from-date ($arg as xs:date?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:year-from-dateTime
 :)
declare function  fn:year-from-dateTime ( $arg as xs:dateTime?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:years-from-duration
 :)
declare function  fn:years-from-duration ( $arg as xs:duration?) as xs:integer?  external;

(:~
 : @see for semantics please check fn:zero-or-one
 :)
declare function  fn:zero-or-one ($arg as item()*) as item()?  external;