Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > b3bdfe6d859a3d6920ff2c44b38e9a6f > files > 3064

saxon-manual-9.4.0.9-2.mga7.noarch.rpm

<?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 2011-12-09T20:47:22.916Z--><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 <code>java.lang.Double</code>, a string as an instance
of <code>java.lang.String</code>. An untyped atomic value is treated as a string. An
<code>xs:integer</code> (even if it belongs to a subtype such as <code>xs:short</code>) is converted
to a <code>java.lang.BigInteger</code>. The more specialized XML Schema primitive types
such as <code>xs:hexBinary</code> and <code>xs:duration</code> are passed in their native Saxon
                     representation (a subclass of <a class="bodylink" href="../../javadoc/net/sf/saxon/value/AtomicValue.html"><code>net.sf.saxon.value.AtomicValue</code></a>). 
                     A node will
                     be passed as an instance of <a class="bodylink" href="../../javadoc/net/sf/saxon/NodeInfo.html"><code>net.sf.saxon.NodeInfo</code></a>, 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>