<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="schema-processing" page="validation-api" subpage="schema-s9api"/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: Schema Processing using s9api</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Schema Processing using s9api"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Schema Processing using s9api</h1>
      <p>The s9api interface allows schemas to be loaded into a <a class="bodylink" href="../../javadoc/net/sf/saxon/s9api/Processor.html"><code>Processor</code></a>, and then
to be used for validating instances, or for schema-aware XSLT and XQuery processing.</p>
      <p>The main steps are:</p>
      <ol>
         <li content="para">
            <p>Create a Processor (<a class="bodylink" href="../../javadoc/net/sf/saxon/s9api/Processor.html"><code>net.sf.saxon.s9api.Processor</code></a>) and call its
<code>getSchemaManager()</code> method to get a <a class="bodylink" href="../../javadoc/net/sf/saxon/s9api/SchemaManager.html"><code>SchemaManager</code></a>.</p>
         </li>
         <li content="para">
            <p>If required, set options on the <code>SchemaManager</code> to control the way in which schema documents
will be loaded.</p>
         </li>
         <li content="para">
            <p>Load a schema document by calling the <code>load()</code> method, which takes a JAXP
Source object as its argument. The resulting schema document is available to all applications run within
the containing <code>Processor</code>.</p>
         </li>
         <li content="para">
            <p>To validate an instance document, call the <code>newSchemaValidator</code> method on the
<code>SchemaManager</code> object. </p>
         </li>
         <li content="para">
            <p>Set options on the <a class="bodylink" href="../../javadoc/net/sf/saxon/s9api/SchemaValidator.html"><code>SchemaValidator</code></a> to control the way in which a particular validation
episode is performed, and then invoke its <code>validate()</code> method to validate an instance document.</p>
         </li>
      </ol>
      <p>Note that additional schemas referenced from the <code>xsi:schemaLocation</code> attributes
within the source documents will be loaded as necessary. A target namespace is ignored if there is already
a loaded schema for that namespace; Saxon makes no attempt to load multiple schemas for the same
namespace and check them for consistency.</p>
      <p>Although the API is defined in such a way that a <a class="bodylink" href="../../javadoc/net/sf/saxon/s9api/SchemaValidator.html"><code>SchemaValidator</code></a>
            is created for a particular <a class="bodylink" href="../../javadoc/net/sf/saxon/s9api/SchemaManager.html"><code>SchemaManager</code></a>, in the Saxon implementation the schema components that
are available to the validator are not only the components within that schema, but all the components that form part
of any schema registered with the <code>Processor</code> (or indeed, with the underlying <code>Configuration</code>)</p>
      <p>The <code>SchemaValidator</code> implements the <a class="bodylink" href="../../javadoc/net/sf/saxon/s9api/Destination.html"><code>Destination</code></a> interface, which means it can be used to receive
input from any process that writes to a <code>Destination</code>, for example an XSLT transformation or an XQuery query.
The result of validation can also be sent to any <code>Destination</code>, for example an XSLT transformer.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="schema-jaxp.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>