saxonica.com

Building a Source Document from an application

With the Java s9api interface, a source document can be built using the DocumentBuilder class, which is created using the factory method newDocumentBuilder on the Processor object. Various options for document building are available as methods on the DocumentBuilder, for example options to perform schema or DTD validation, to strip whitespace, to expand XInclude directives, and also to choose the tree implementation model to be used.

Similarly in the .NET API, there is a DocumentBuilder object that can be created from the processor. This allows options to be set controlling the way documents are built, and provides an overloaded Build method allowing a tree to be built from various kinds of source.

It is also possible to build a Saxon tree in memory by using the buildDocument method of the Configuration object. (When using the JAXP Transformation API, the Configuration can be obtained from the TransformerFactory as the value of the attribute named FeatureKeys.CONFIGURATION.)

The buildDocument() method takes a single argument, a JAXP Source. This can be any of the standard kinds of JAXP Source. See JAXP Sources for more information.

All the documents processed in a single transformation or query must be loaded using the same Configuration. However, it is possible to copy a document from one Configuration into another by supplying the DocumentInfo at the root of the existing document as the Source supplied to the buildDocument() method of the new Configuration.

Next