# 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.

Expand |