<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="xpath-api" page="jaxp-xpath" subpage="jaxp-xpath-extension-functions"/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: Calling JAXP XPath extension functions</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Calling JAXP XPath extension functions"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Calling JAXP XPath extension functions</h1>
      <p>The JAXP XPath interface includes an interface <code>FunctionResolver</code> which can be used to
  bind a function call appearing in the XPath expression to a user-written Java implementation of the
  interface <code>java.xml.xpath.XPathFunction</code>. The form in which parameters are passed to such a function,
  and the form in which it returns its results, are not precisely defined in the JAXP specification, so this
  section fills the gap. Note that the calling conventions are likely to differ from those used by other products.</p>
      <p>The extension function is called by invoking the method <code>XPathFunction.evaluate()</code>, which takes a list
  of arguments, and returns the function result.</p>
      <p>The arguments are therefore supplied as a list. Each item in this list represents one argument. The argument value
  is represented as follows:</p>
      <ol>
         <li content="para">
            <p>if the value of the argument is a singleton item, it will be passed as
the "natural Java equivalent" of the item's type. For example, a double
will be passed as an instance of java.lang.Double, a string as an instance
of java.lang.String. An untyped atomic value is treated as a string. An
xs:integer (even if it belongs to a subtype such as xs:short) is converted
to a java.lang.BigInteger. The more specialized XML Schema primitive types
such as xs:hexBinary and xs:duration are passed in their native Saxon
representation (a subclass of net.sf.saxon.value.AtomicValue). A node will
be passed as an instance of net.sf.saxon.NodeInfo, unless it wraps a
foreign node (e.g. a DOM or JDOM node) in which case the foreign node is
passed.</p>
         </li>
         <li content="para">
            <p>if the value is a sequence of any length other than one (including
zero), then the value that is passed is a List, where each item in the list
is converted as described in rule (1).</p>
         </li>
      </ol>
      <p>If the return value conforms to the above conventions, then it will be
accepted. However Saxon will also accept a wide range of other return
values, including of course a <code>List</code> containing one item.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="../nodeinfo.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>