<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="using-xquery" page="intro" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Using XQuery</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: Using XQuery"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Using XQuery</h1>
      <p>This section describes how to use Saxon as an XQuery processor, either from the command line,
or from the Java API.</p>
      <p>For details of the .NET API, see <a class="bodylink" href="../dotnet/dotnetapi.xml">Saxon API for .NET</a></p>
      <p>For information about the conformance of Saxon to the XQuery 1.0 and XQuery 3.0 specifications,
      and about the handling of implementation-defined features of the specifications, see 
      <a class="bodylink" href="../Conformance/intro.xml">Conformance</a>.</p>
      <p>Saxon uses the same run-time engine to support both XQuery and XSLT, reflecting the fact that
the two languages have very similar semantics. Most of the compile-time code (in particular, the
type checking logic and the optimizer) is also common. The XQuery support in Saxon consists essentially
of an XQuery parser (which is itself an extension of the XPath parser); the parser
generates the same internal interpretable code as the XSLT processor. There are also some constructs
in the internal expression tree that will only be generated from XQuery source rather than XSLT source;
examples are the XQuery <code>order by</code> and <code>group by</code> clauses, which have no direct XSLT equivalent.</p>
      <p>The XQuery processor may be invoked either from the operating system command line,
or via an API from a user-written application. There is no graphical user interface provided.</p>
      <p>Saxon is an in-memory processor. Unless you can take advantage of <a class="bodylink" href="../sourcedocs/streaming.xml">streaming</a>, Saxon is designed
to process source documents that fit in memory. Saxon has been used successfully to process
source documents of 100Mbytes or more without streaming, but if you attempt anything this large, you need to be
aware (a) that you will need to allocate sufficient memory to the Java VM (at least 5 times the size
of the source document), and (b) that complex FLWOR expressions may be very time-consuming to
execute. (In this scenario, Saxon-EE is recommended, because it has a more powerful optimizer for
complex joins). </p>
      <div class="boxed"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">The memory available in the Java heap is controlled using the -Xmx option on the command line,
      for example <code>java -Xmx1024m net.sf.saxon.Query ...</code> allocates 1Gb.</div>
      <p><i>For details of how to set up collation URIs for use in XQuery,
see <a class="bodylink" href="../extensibility/collation.xml">Implementing a Collating Sequence</a></i></p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="commandline.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>