<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="extensions" page="functions" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Extension functions</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Extension functions"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Extension functions</h1>
      <p><i>This section describes extension functions built in to the Saxon product. For information
on writing your own extension functions, see 
<a class="bodylink" href="../extensibility/functions.xml">Writing extension functions (Java)</a> or
    <a class="bodylink" href="../extensibility/dotnetextensions.xml">Writing extension functions (.NET)</a></i></p>
      <p>A Saxon extension function is invoked using a name such as <code>saxon:localname()</code>.</p>
      <p>The <code>saxon</code> prefix (or whatever prefix you choose to use) must be associated with the
Saxon namespace URI <code>http://saxon.sf.net/</code>. </p>
      <p>For example, to invoke the <code>saxon:evaluate()</code> function in XSLT, write:</p>
      <div class="codeblock"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">
         <pre>
            <code>&lt;xsl:variable name="expression"
      select="concat('child::', $param, '[', $index, ']')"/&gt;
..
&lt;xsl:copy-of select="saxon:evaluate($expression)"
     xmlns:saxon="http://saxon.sf.net/"/&gt;
</code>
         </pre>
      </div>
      <p>The equivalent in XQuery is:</p>
      <div class="codeblock"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">
         <pre>
            <code>declare namespace saxon="http://saxon.sf.net/";
declare variable $param as xs:string external;
declare variable $index as xs:integer external;
declare variable $expression :=
      concat('child::', $param, '[', $index, ']');
saxon:evaluate($expression)
</code>
         </pre>
      </div>
      <p>The extension functions supplied with the Saxon product are as follows:</p>
      <ul>
         <li>
            <p><a class="bodylink" href="functions/adjusttociviltime.xml">saxon:adjust-to-civil-time()</a>: converts an xs:dateTime to the local civil time in a named timezone</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/analyze-string.xml">saxon:analyze-string()</a>: analyzes a string using a regular expression</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/base64binarytooctets.xml">saxon:base64Binary-to-octets()</a>: converts an xs:base64Binary value to a sequence of octets</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/base64binarytostring.xml">saxon:base64Binary-to-string()</a>: converts an xs:base64Binary value to a string, given its encoding</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/call.xml">saxon:call()</a>: calls a first-class function previously created using saxon:function()</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/columnnumber.xml">saxon:column-number(node)</a>: gets the column number of a node in the source document</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/compile-query.xml">saxon:compile-query()</a>: compiles a query that can subsequently be used as input to saxon:query()</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/compile-stylesheet.xml">saxon:compile-stylesheet()</a>: compiles a stylesheet that can subsequently be used as input to saxon:transform()</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/currentmode.xml">saxon:current-mode-name()</a>: returns the name of the current mode in XSLT</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/decimaldivide.xml">saxon:decimal-divide()</a>: performs decimal division with user-specified precision</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/deepequal.xml">saxon:deep-equal()</a>: compares two sequences for deep equality</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/discarddocument.xml">saxon:discard-document()</a>: marks a document as being eligible for garbage collection</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/eval.xml">saxon:eval()</a>: evaluates a stored expression created using saxon:expression</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/evaluate.xml">saxon:evaluate()</a>: evaluates an XPath expression supplied dynamically as a string</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/evaluate-node.xml">saxon:evaluate-node()</a>: evaluates an XPath expression held in a node of a source document</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/expression.xml">saxon:expression()</a>: creates a stored expression for subsequent evaluation using saxon:eval()</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/find.xml">saxon:find()</a>: finds items that match a given key value within an indexed sequence</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/for-each-group.xml">saxon:for-each-group()</a>: groups a set of items on the basis of a grouping key</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/format-dateTime.xml">saxon:format-dateTime()</a>: formats a date, time, or dateTime value</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/format-number.xml">saxon:format-number()</a>: formats a number for output</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/function.xml">saxon:function()</a>: creates a first-class function that can be passed as an argument to other functions</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/generateid.xml">saxon:generate-id()</a>: generates a unique ASCII identifier for a node</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/getpseudoattribute.xml">saxon:get-pseudo-attribute()</a>: parses the content of a processing instruction</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/hassamenodes.xml">saxon:has-same-nodes()</a>: tests whether two sequences contain the same nodes</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/hexbinarytooctets.xml">saxon:hexBinary-to-octets()</a>: converts an xs:hexBinary value to a sequence of octets</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/hexbinarytostring.xml">saxon:hexBinary-to-string()</a>: converts an xs:hexBinary value to a string, given its encoding</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/highest.xml">saxon:highest()</a>: finds the nodes having the highest value for some expression</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/index.xml">saxon:index()</a>: creates an indexed sequence, allowing efficient retrieval using a key value</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/in-summer-time.xml">saxon:in-summer-time()</a>: tests whether a given date/time is in summer time (daylight savings time)</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/is-whole-number.xml">saxon:is-whole-number()</a>: tests whether a given value has no fractional part</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/item-at.xml">saxon:item-at()</a>: selects the item at a given position in a sequence</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/last-modified.xml">saxon:last-modified()</a>: determines when a file was last modified</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/leading.xml">saxon:leading()</a>: returns items in a sequence up to the first one matching a condition</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/linenumber.xml">saxon:line-number(node)</a>: gets the line number of a node in the source document</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/lowest.xml">saxon:lowest()</a>: finds the nodes having the lowest value for some expression</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/namespace-node.xml">saxon:namespace-node()</a>: creates a namespace node</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/stream.xml">saxon:stream()</a>: evaluates an expression in streaming mode</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/octetstobase64binary.xml">saxon:octets-to-base64Binary()</a>: converts a sequence of octets to an xs:base64Binary value</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/octetstohexbinary.xml">saxon:octets-to-hexBinary()</a>: converts a sequence of octets to an xs:hexBinary value</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/parse.xml">saxon:parse()</a>: parses an XML document supplied as a string</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/parse-html.xml">saxon:parse-html()</a>: parses an HTML document supplied as a string</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/path.xml">saxon:path()</a>: returns an XPath expression that identifies a node</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/printstack.xml">saxon:print-stack()</a>: returns a formatted string representing the current execution stack</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/query.xml">saxon:query()</a>: Runs an XQuery that was previously compiled using saxon:compile-query()</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/result-document.xml">saxon:result-document()</a>: constructs a document and serializes it, writing the result to a file in filestore</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/serialize.xml">saxon:serialize()</a>: returns the XML representation of a document or element, as a string</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/sort.xml">saxon:sort()</a>: sorts a sequence of nodes or atomic values</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/stringtobase64binary.xml">saxon:string-to-base64Binary()</a>: encodes a string to an xs:base64Binary value, using a given encoding</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/stringtohexbinary.xml">saxon:string-to-hexBinary()</a>: encodes a string to an xs:hexBinary value, using a given encoding</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/stringtoutf8.xml">saxon:string-to-utf8()</a>: returns the UTF8 representation of a string</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/systemid.xml">saxon:system-id()</a>: returns the system ID of the document containing the context node</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/transform.xml">saxon:transform()</a>: Runs an XSLT transformation</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/try.xml">saxon:try()</a>: allows recovery from dynamic errors</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/typeannotation.xml">saxon:type-annotation()</a>: returns the type annotation of a node or atomic value</p>
         </li>
         <li>
            <p><a class="bodylink" href="functions/unparsedentities.xml">saxon:unparsed-entities()</a>: returns a list of the unparsed entities declared within a document</p>
         </li>
      </ul>
      <p><i>These extension functions are available in Saxon-PE and Saxon-EE except where otherwise stated. 
They are not available in Saxon-HE.</i></p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="functions/adjusttociviltime.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>