SaxonC 12.5
Saxon Processor library for C/C++, PHP and Python
|
#include <DocumentBuilder.h>
Public Member Functions | |
~DocumentBuilder () | |
void | setLineNumbering (bool option) |
bool | isLineNumbering () |
void | setSchemaValidator (SchemaValidator *validator) |
SchemaValidator * | getSchemaValidator () |
void | setDTDValidation (bool option) |
bool | isDTDValidation () |
void | setBaseUri (const char *uri) |
const char * | getBaseUri () |
XdmNode * | parseXmlFromString (const char *content, const char *encoding=nullptr) |
XdmNode * | parseXmlFromFile (const char *filename) |
XdmNode * | parseXmlFromUri (const char *source) |
bool | exceptionOccurred () |
void | exceptionClear () |
Clear any exception thrown. | |
const char * | getErrorMessage () |
Get the error message if an error has been reported by JNI. | |
const char * | getErrorCode () |
Get the error code if an error has been reported by JNI. | |
SaxonApiException * | getException () |
Get the SaxonApiException object created when we have an error. | |
Friends | |
class | SaxonProcessor |
A document builder 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 DocumentBuilder, use the factory method SaxonProcessor.newDocumentBuilder().
All documents used in a single Saxon query, transformation, or validation episode must be built with the same Configuration. However, there is no requirement that they should use the same DocumentBuilder
.
Sharing of a DocumentBuilder
across multiple threads is not recommended. However, in the current implementation sharing a DocumentBuilder
(once initialized) will only cause problems if a SchemaValidator
is used.
DocumentBuilder::~DocumentBuilder | ( | ) |
DocumentBuilder Destructor
bool DocumentBuilder::exceptionOccurred | ( | ) |
Checks for pending exceptions without creating a local reference to the exception object
const char * DocumentBuilder::getBaseUri | ( | ) |
Get the base URI of documents loaded using this DocumentBuilder when no other URI is available.
const char * DocumentBuilder::getErrorCode | ( | ) |
Get the error code if an error has been reported by JNI.
After the execution of the XPath expression there may be a number of errors reported against it.
const char * DocumentBuilder::getErrorMessage | ( | ) |
Get the error message if an error has been reported by JNI.
A transformation may have a number of errors reported against it.
SaxonApiException * DocumentBuilder::getException | ( | ) |
Get the SaxonApiException object created when we have an error.
After the execution of the processor if there is an error, then a SaxonApiException is created. NULL returned if there is no error.
SchemaValidator * DocumentBuilder::getSchemaValidator | ( | ) |
Get the SchemaValidator used to validate documents loaded using this DocumentBuilder
.
bool DocumentBuilder::isDTDValidation | ( | ) |
Ask whether DTD validation is to be applied to documents loaded using this DocumentBuilder
bool DocumentBuilder::isLineNumbering | ( | ) |
Ask whether line and column numbering is enabled for documents loaded using this DocumentBuilder
.
By default, line and column numbering is disabled.
Line numbering is not available for all kinds of source: in particular, it is not available when loading from an existing DOM Document.
XdmNode * DocumentBuilder::parseXmlFromFile | ( | const char * | filename | ) |
Build a document from a supplied XML file.
filename | - the supplied file |
XdmNode * DocumentBuilder::parseXmlFromString | ( | const char * | content, |
const char * | encoding = nullptr ) |
Load an XML document, to create a tree representation of the document in memory.
content | - the XML document as a serialized string |
encoding | of the source string argument. If not specified then platform default encoding is used |
XdmNode
. This will be the document node at the root of the tree of the resulting in-memory document. XdmNode * DocumentBuilder::parseXmlFromUri | ( | const char * | source | ) |
Build a document from a supplied URI source
source | - URI to the XML source |
XdmNode
. This will be the document node at the root of the tree of the resulting in-memory document.void DocumentBuilder::setBaseUri | ( | const char * | uri | ) |
Set the base URI of a document loaded using this DocumentBuilder
.
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 Stream or a DOMSource. The value is ignored when loading from a source that does have an intrinsic base URI.
uri | the base URI of documents loaded using this DocumentBuilder . This must be an absolute URI. |
void DocumentBuilder::setDTDValidation | ( | bool | option | ) |
Set whether DTD validation should be applied to documents loaded using this DocumentBuilder
.
By default, no DTD validation takes place.
option | true if DTD validation is to be applied to the document |
void DocumentBuilder::setLineNumbering | ( | bool | option | ) |
Say whether line and column numbering and is to be enabled for documents constructed using this DocumentBuilder. This has the effect that the line and column number in the original source document is maintained in the constructed tree, for each element node (and only for elements). The line and column number in question are generally the position at which the closing ">" of the element start tag appears.
By default, line and column numbers are not maintained.
Errors relating to document parsing and validation will generally contain line numbers whether or not this option is set, because such errors are detected during document construction.
Line numbering is not available for all kinds of source: for example, it is not available when loading from an existing DOM Document.
option | true if line numbers are to be maintained, false otherwise. |
void DocumentBuilder::setSchemaValidator | ( | SchemaValidator * | validator | ) |
Set the schemaValidator 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 schemaValidator is supplied, then schema validation does not take place.
This option requires the schema-aware version of the Saxon product (Saxon-EE).
Since a SchemaValidator
is serially reusable but not thread-safe, using this method is not appropriate when the DocumentBuilder
is shared between threads.
validator | the SchemaValidator to be used |