SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Conditions of Use
Using XSLT 2.0
Using XQuery
Handling Source Documents
XML Schema Processing
XPath API for Java
| Introduction
| The JAXP XPath API
| The Standalone XPath API
| The NodeInfo Object
» | Building the Source Document
Saxon on .NET
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
Function Library
Standards Conformance

# Building the Source Document

The first thing the application must do is to build the source document, in the form of a tree. The simplest approach is to use the sequence:

        String systemId = new File(sourceFile).toURL().toString();
        DocumentInfo doc = new XPathEvaluator().buildDocument(
                             new SAXSource(new InputSource(systemId)));

You can define the parser to be used by supplying a parser within the `SAXSource` object. If you don't supply a parser, Saxon will select one using the JAXP mechanisms, specifically, the system property `javax.xml.parsers.DocumentBuilderFactory`.

If you want to use different parsers depending on the URI of the document being read, you can achieve this by writing a `URIResolver` that nominates the parser to be used for each input file.

For more information about the different ways of loading source documents, see Handling Source Documents.