PyDocumentBuilder

class PyDocumentBuilder

Bases: object

A PyDocumentBuilder holds properties controlling how a Saxon document tree should be built, and provides methods to invoke the tree construction. This class has no public constructor. To construct a PyDocumentBuilder, use the factory method PySaxonProcessor.new_document_builder().

Creates a new instance, keeping a reference to its PySaxonProcessor :param processor:

__init__()

Creates a new instance, keeping a reference to its PySaxonProcessor :param processor:

classmethod __new__(*args, **kwargs)
__reduce__()

Helper for pickle.

__setstate__()
base_uri

Get the base URI of documents loaded using this PyDocumentBuilder when no other URI is available. :returns: String value of the base URI to be used. This may be NULL if no value has been set. :rtype: str

dtd_validation

Ask whether DTD validation is to be applied to documents loaded using this PyDocumentBuilder

Type:

bool

get_schema_validator(self)

Get the PySchemaValidator used to validate documents loaded using this PyDocumentBuilder :returns: if one has been set; otherwise None. :rtype: PySchemaValidator

line_numbering

true if line numbering is enabled

Type:

bool

parse_xml(self, **kwds)

Parse a source document supplied as a lexical representation, source file or uri, and return it as XDM node :param **kwds: Possible keyword arguments: one of the following (xml_file_name|xml_text|xml_uri) is required. :param The keyword ‘encoding’: :type The keyword ‘encoding’: str :param (if not specified then the platform default encoding is used).:

Returns:

The XDM node representation of the XML document

Return type:

PyXdmNode

Raises:
set_base_uri(self, base_uri)

Set the base URI of a document loaded using this PyDocumentBuilder. This is used for resolving any relative URIs appearing within the document, for example in references to DTDs and external entities. This information is required when the document is loaded from a source that does not provide an intrinsic URI, notably when loading from a String. The value is ignored when loading from a source that does have an intrinsic base URI. :param base_uri: the base output URI :type base_uri: str

set_dtd_validation(self, value)

Set whether DTD validation should be applied to documents loaded using this PyDocumentBuilder. By default, no DTD validation takes place. :param value: true if DTD validation should be applied to loaded documents :type value: bool

set_line_numbering(self, value)

Set whether line and column numbering and is to be enabled for documents constructed using this PyDocumentBuilder. By default, line and column numbering is disabled. :param value: true if line numbers are to be maintained, false otherwise :type value: bool

set_schema_validator(self, PySchemaValidator val)

Set the PySchemaValidator to be used. This determines whether schema validation is applied to an input document and whether type annotations in a supplied document are retained. If no PySchemaValidator is supplied, then schema validation does not take place. This option requires the schema-aware version of the Saxon product (SaxonC-EE). Since a PySchemaValidator is serially reusable but not thread-safe, using this method is not appropriate when the PyDocumentBuilder is shared between threads. :param val: the schema validator to be used :type val: PySchemaValidator