PyDocumentBuilder¶
- class PyDocumentBuilder¶
Bases:
objectA 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
- Parameters:
processor (PySaxonProcessor) – the PySaxonProcessor that owns this builder
- __init__()¶
Creates a new instance, keeping a reference to its PySaxonProcessor
- Parameters:
processor (PySaxonProcessor) – the PySaxonProcessor that owns this builder
- classmethod __new__(*args, **kwargs)¶
- __reduce__()¶
Helper for pickle.
- __setstate__()¶
- base_uri¶
Get the default base URI of documents loaded with this PyDocumentBuilder
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.
- Return type:
- dtd_validation¶
Reports whether DTD validation is enabled
- Returns:
Ask whether DTD validation is to be applied to documents loaded using this PyDocumentBuilder
- Return type:
- get_schema_validator()¶
Get the PySchemaValidator used to validate documents
Get the PySchemaValidator used to validate documents loaded using this PyDocumentBuilder
- Returns:
if one has been set; otherwise None.
- Return type:
- line_numbering¶
Report whether line numbering is enabled
- Returns:
true if line numbering is enabled
- Return type:
- parse_xml(**kwds)¶
Parse a source XML document
Parse a source document supplied as a lexical representation, source file or uri, and return it as XDM node
- Parameters:
**kwds – Possible keyword arguments: one of the following (xml_file_name|xml_text|xml_uri) is required. The keyword ‘encoding’ (str) can be used to specify the encoding used to decode the xml_text string (if not specified then the platform default encoding is used).
- Returns:
The XDM node representation of the XML document
- Return type:
- Raises:
Exception – Error if invalid use of keywords.
PySaxonApiError – Error if failure to parse XML file or XML text
- set_base_uri(base_uri)¶
Set the base URI of a document loaded using this PyDocumentBuilder
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.
- Parameters:
base_uri (str) – the base output URI
- set_dtd_validation(value)¶
Enable/disable DTD validation for this builder
Set whether DTD validation should be applied to documents loaded using this PyDocumentBuilder. By default, no DTD validation takes place.
- Parameters:
value (bool) – true if DTD validation should be applied to loaded documents
- set_line_numbering(value)¶
Enable/disable line and column numbering
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.
- Parameters:
value (bool) – true if line numbers are to be maintained, false otherwise
- set_schema_validator(val)¶
Set the PySchemaValidator to be used
Set the
PySchemaValidatorto 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.
- Parameters:
val (PySchemaValidator) – the schema validator to be used