#include <DOMBuilderImpl.hpp>
Inheritance diagram for DOMBuilderImpl:
Public Member Functions | |
Constructors and Destructor | |
DOMBuilderImpl (XMLValidator *const valToAdopt=0, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager) | |
virtual | ~DOMBuilderImpl () |
Getter methods | |
DOMErrorHandler * | getErrorHandler () |
const DOMErrorHandler * | getErrorHandler () const |
DOMEntityResolver * | getEntityResolver () |
const DOMEntityResolver * | getEntityResolver () const |
DOMBuilderFilter * | getFilter () |
const DOMBuilderFilter * | getFilter () const |
Setter methods | |
void | setErrorHandler (DOMErrorHandler *const handler) |
void | setEntityResolver (DOMEntityResolver *const handler) |
void | setFilter (DOMBuilderFilter *const filter) |
Feature methods | |
void | setFeature (const XMLCh *const name, const bool state) |
bool | getFeature (const XMLCh *const name) const |
bool | canSetFeature (const XMLCh *const name, const bool state) const |
Parsing methods | |
DOMDocument * | parse (const DOMInputSource &source) |
DOMDocument * | parseURI (const XMLCh *const systemId) |
DOMDocument * | parseURI (const char *const systemId) |
virtual void | parseWithContext (const DOMInputSource &source, DOMNode *const contextNode, const short action) |
Non-standard Extension | |
virtual void * | getProperty (const XMLCh *const name) const |
virtual void | setProperty (const XMLCh *const name, void *value) |
virtual void | release () |
virtual void | resetDocumentPool () |
virtual Grammar * | loadGrammar (const DOMInputSource &source, const short grammarType, const bool toCache=false) |
virtual Grammar * | loadGrammar (const XMLCh *const systemId, const short grammarType, const bool toCache=false) |
virtual Grammar * | loadGrammar (const char *const systemId, const short grammarType, const bool toCache=false) |
virtual Grammar * | getGrammar (const XMLCh *const nameSpaceKey) const |
virtual Grammar * | getRootGrammar () const |
virtual const XMLCh * | getURIText (unsigned int uriId) const |
virtual void | resetCachedGrammarPool () |
virtual unsigned int | getSrcOffset () const |
Implementation of the XMLErrorReporter interface. | |
virtual void | error (const unsigned int errCode, const XMLCh *const msgDomain, const XMLErrorReporter::ErrTypes errType, const XMLCh *const errorText, const XMLCh *const systemId, const XMLCh *const publicId, const XMLSSize_t lineNum, const XMLSSize_t colNum) |
virtual void | resetErrors () |
Implementation of the XMLEntityHandler interface. | |
virtual void | endInputSource (const InputSource &inputSource) |
virtual bool | expandSystemId (const XMLCh *const systemId, XMLBuffer &toFill) |
virtual void | resetEntities () |
virtual InputSource * | resolveEntity (const XMLCh *const publicId, const XMLCh *const systemId, const XMLCh *const baseURI=0) |
virtual void | startInputSource (const InputSource &inputSource) |
Private Attributes | |
bool | fAutoValidation |
bool | fValidation |
DOMEntityResolver * | fEntityResolver |
DOMErrorHandler * | fErrorHandler |
DOMBuilderFilter * | fFilter |
bool | fCharsetOverridesXMLEncoding |
bool | fUserAdoptsDocument |
DOMBuilderImpl provides an implementation of a DOMBuilder interface. A DOMBuilder instance is obtained from the DOMImplementationLS interface by invoking its createDOMBuilder method.
Definition at line 80 of file DOMBuilderImpl.hpp.
DOMBuilderImpl::DOMBuilderImpl | ( | XMLValidator *const | valToAdopt = 0 , |
|
MemoryManager *const | manager = XMLPlatformUtils::fgMemoryManager | |||
) |
Construct a DOMBuilderImpl, with an optional validator
Constructor with an instance of validator class to use for validation. If you don't provide a validator, a default one will be created for you in the scanner.
valToAdopt | Pointer to the validator instance to use. The parser is responsible for freeing the memory. |
virtual DOMBuilderImpl::~DOMBuilderImpl | ( | ) | [virtual] |
Destructor
bool DOMBuilderImpl::canSetFeature | ( | const XMLCh *const | name, | |
const bool | state | |||
) | const [virtual] |
"Experimental - subject to change"
Query whether setting a feature to a specific value is supported.
name | The feature name. | |
state | The requested state of the feature (true or false). |
true
if the feature could be successfully set to the specified value, or false
if the feature is not recognized or the requested value is not supported. The value of the feature itself is not changed.Implements DOMBuilder.
void DOMBuilderImpl::endInputSource | ( | const InputSource & | inputSource | ) | [inline, virtual] |
Handle an end of input source event
This method is used to indicate the end of parsing of an external entity file.
<font color="#FF0000">This method is a no-op for this DOM implementation.</font>
inputSource | A const reference to the InputSource object which points to the XML file being parsed. |
Implements XMLEntityHandler.
Definition at line 841 of file DOMBuilderImpl.hpp.
virtual void DOMBuilderImpl::error | ( | const unsigned int | errCode, | |
const XMLCh *const | msgDomain, | |||
const XMLErrorReporter::ErrTypes | errType, | |||
const XMLCh *const | errorText, | |||
const XMLCh *const | systemId, | |||
const XMLCh *const | publicId, | |||
const XMLSSize_t | lineNum, | |||
const XMLSSize_t | colNum | |||
) | [virtual] |
Handle errors reported from the parser
This method is used to report back errors found while parsing the XML file. This method is also borrowed from the SAX specification. It calls the corresponding user installed Error Handler method: 'fatal', 'error', 'warning' depending on the severity of the error. This classification is defined by the XML specification.
errCode | An integer code for the error. | |
msgDomain | A const pointer to an Unicode string representing the message domain to use. | |
errType | An enumeration classifying the severity of the error. | |
errorText | A const pointer to an Unicode string representing the text of the error message. | |
systemId | A const pointer to an Unicode string representing the system id of the XML file where this error was discovered. | |
publicId | A const pointer to an Unicode string representing the public id of the XML file where this error was discovered. | |
lineNum | The line number where the error occurred. | |
colNum | The column number where the error occurred. |
Implements XMLErrorReporter.
bool DOMBuilderImpl::expandSystemId | ( | const XMLCh *const | systemId, | |
XMLBuffer & | toFill | |||
) | [inline, virtual] |
Expand a system id
This method allows an installed XMLEntityHandler to further process any system id's of enternal entities encountered in the XML file being parsed, such as redirection etc.
<font color="#FF0000">This method always returns 'false' for this DOM implementation.</font>
systemId | A const pointer to an Unicode string representing the system id scanned by the parser. | |
toFill | A pointer to a buffer in which the application processed system id is stored. |
Implements XMLEntityHandler.
Definition at line 846 of file DOMBuilderImpl.hpp.
const DOMEntityResolver * DOMBuilderImpl::getEntityResolver | ( | ) | const [inline, virtual] |
"Experimental - subject to change"
Get a const pointer to the entity resolver
This method returns the installed entity resolver. If no resolver has been installed, then it will be a zero pointer.
Implements DOMBuilder.
Definition at line 881 of file DOMBuilderImpl.hpp.
References fEntityResolver.
DOMEntityResolver * DOMBuilderImpl::getEntityResolver | ( | ) | [inline, virtual] |
"Experimental - subject to change"
Get a pointer to the entity resolver
This method returns the installed entity resolver. If no resolver has been installed, then it will be a zero pointer.
Implements DOMBuilder.
Definition at line 876 of file DOMBuilderImpl.hpp.
References fEntityResolver.
const DOMErrorHandler * DOMBuilderImpl::getErrorHandler | ( | ) | const [inline, virtual] |
"Experimental - subject to change"
Get a const pointer to the error handler
This method returns the installed error handler. If no handler has been installed, then it will be a zero pointer.
Implements DOMBuilder.
Definition at line 871 of file DOMBuilderImpl.hpp.
References fErrorHandler.
DOMErrorHandler * DOMBuilderImpl::getErrorHandler | ( | ) | [inline, virtual] |
"Experimental - subject to change"
Get a pointer to the error handler
This method returns the installed error handler. If no handler has been installed, then it will be a zero pointer.
Implements DOMBuilder.
Definition at line 866 of file DOMBuilderImpl.hpp.
References fErrorHandler.
bool DOMBuilderImpl::getFeature | ( | const XMLCh *const | name | ) | const [virtual] |
"Experimental - subject to change"
Look up the value of a feature.
name | The feature name. |
DOMException | NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize the feature name. |
Implements DOMBuilder.
const DOMBuilderFilter * DOMBuilderImpl::getFilter | ( | ) | const [inline, virtual] |
"Experimental - subject to change"
Get a const pointer to the application filter
This method returns the installed application filter. If no filter has been installed, then it will be a zero pointer.
Implements DOMBuilder.
Definition at line 891 of file DOMBuilderImpl.hpp.
References fFilter.
DOMBuilderFilter * DOMBuilderImpl::getFilter | ( | ) | [inline, virtual] |
"Experimental - subject to change"
Get a pointer to the application filter
This method returns the installed application filter. If no filter has been installed, then it will be a zero pointer.
Implements DOMBuilder.
Definition at line 886 of file DOMBuilderImpl.hpp.
References fFilter.
virtual Grammar* DOMBuilderImpl::getGrammar | ( | const XMLCh *const | nameSpaceKey | ) | const [virtual] |
Retrieve the grammar that is associated with the specified namespace key
nameSpaceKey | Namespace key |
Implements DOMBuilder.
virtual void* DOMBuilderImpl::getProperty | ( | const XMLCh *const | name | ) | const [virtual] |
Query the current value of a property in a DOMBuilder.
The builder owns the returned pointer. The memory allocated for the returned pointer will be destroyed when the builder is deleted.
To ensure assessiblity of the returned information after the builder is deleted, callers need to copy and store the returned information somewhere else; otherwise you may get unexpected result. Since the returned pointer is a generic void pointer, see http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties to learn exactly what type of property value each property returns for replication.
name | The unique identifier (URI) of the property being set. |
DOMException | NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize the requested property. |
Implements DOMBuilder.
virtual Grammar* DOMBuilderImpl::getRootGrammar | ( | ) | const [virtual] |
Retrieve the grammar where the root element is declared.
Implements DOMBuilder.
virtual unsigned int DOMBuilderImpl::getSrcOffset | ( | ) | const [virtual] |
Returns the current src offset within the input source.
Implements DOMBuilder.
virtual const XMLCh* DOMBuilderImpl::getURIText | ( | unsigned int | uriId | ) | const [virtual] |
Returns the string corresponding to a URI id from the URI string pool.
uriId | id of the string in the URI string pool. |
Implements DOMBuilder.
virtual Grammar* DOMBuilderImpl::loadGrammar | ( | const char *const | systemId, | |
const short | grammarType, | |||
const bool | toCache = false | |||
) | [virtual] |
Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
This method invokes the preparsing process on a schema grammar XML file specified by the file path parameter. If the 'toCache' flag is enabled, the parser will cache the grammars for re-use. If a grammar key is found in the pool, no caching of any grammar will take place.
"Experimental - subject to change"
systemId | A const char pointer to a native string which contains the path to the XML grammar file to be preparsed. | |
grammarType | The grammar type (Schema or DTD). | |
toCache | If true , we cache the preparsed grammar, otherwise, no chaching. Default is false . |
SAXException | Any SAX exception, possibly wrapping another exception. | |
XMLException | An exception from the parser or client handler code. | |
DOMException | A DOM exception as per DOM spec. |
Implements DOMBuilder.
virtual Grammar* DOMBuilderImpl::loadGrammar | ( | const XMLCh *const | systemId, | |
const short | grammarType, | |||
const bool | toCache = false | |||
) | [virtual] |
Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
This method invokes the preparsing process on a schema grammar XML file specified by the file path parameter. If the 'toCache' flag is enabled, the parser will cache the grammars for re-use. If a grammar key is found in the pool, no caching of any grammar will take place.
"Experimental - subject to change"
systemId | A const XMLCh pointer to the Unicode string which contains the path to the XML grammar file to be preparsed. | |
grammarType | The grammar type (Schema or DTD). | |
toCache | If true , we cache the preparsed grammar, otherwise, no chaching. Default is false . |
SAXException | Any SAX exception, possibly wrapping another exception. | |
XMLException | An exception from the parser or client handler code. | |
DOMException | A DOM exception as per DOM spec. |
Implements DOMBuilder.
virtual Grammar* DOMBuilderImpl::loadGrammar | ( | const DOMInputSource & | source, | |
const short | grammarType, | |||
const bool | toCache = false | |||
) | [virtual] |
Preparse schema grammar (XML Schema, DTD, etc.) via an input source object.
This method invokes the preparsing process on a schema grammar XML file specified by the DOMInputSource parameter. If the 'toCache' flag is enabled, the parser will cache the grammars for re-use. If a grammar key is found in the pool, no caching of any grammar will take place.
"Experimental - subject to change"
source | A const reference to the DOMInputSource object which points to the schema grammar file to be preparsed. | |
grammarType | The grammar type (Schema or DTD). | |
toCache | If true , we cache the preparsed grammar, otherwise, no chaching. Default is false . |
SAXException | Any SAX exception, possibly wrapping another exception. | |
XMLException | An exception from the parser or client handler code. | |
DOMException | A DOM exception as per DOM spec. |
Implements DOMBuilder.
DOMDocument* DOMBuilderImpl::parse | ( | const DOMInputSource & | source | ) | [virtual] |
"Experimental - subject to change"
Parse via an input source object
This method invokes the parsing process on the XML file specified by the DOMInputSource parameter. This API is borrowed from the SAX Parser interface.
source | A const reference to the DOMInputSource object which points to the XML file to be parsed. |
null
is returned since the document object is not yet parsed when this method returns. SAXException | Any SAX exception, possibly wrapping another exception. | |
XMLException | An exception from the parser or client handler code. | |
DOMException | A DOM exception as per DOM spec. |
Implements DOMBuilder.
DOMDocument* DOMBuilderImpl::parseURI | ( | const char *const | systemId | ) | [virtual] |
"Experimental - subject to change"
Parse via a file path or URL (in the local code page)
This method invokes the parsing process on the XML file specified by the native char* string parameter 'systemId'.
systemId | A const char pointer to a native string which contains the path to the XML file to be parsed. |
null
is returned since the document object is not yet parsed when this method returns. SAXException | Any SAX exception, possibly wrapping another exception. | |
XMLException | An exception from the parser or client handler code. | |
DOM_DOMException | A DOM exception as per DOM spec. |
Implements DOMBuilder.
DOMDocument* DOMBuilderImpl::parseURI | ( | const XMLCh *const | systemId | ) | [virtual] |
"Experimental - subject to change"
Parse via a file path or URL
This method invokes the parsing process on the XML file specified by the Unicode string parameter 'systemId'.
systemId | A const XMLCh pointer to the Unicode string which contains the path to the XML file to be parsed. |
null
is returned since the document object is not yet parsed when this method returns. SAXException | Any SAX exception, possibly wrapping another exception. | |
XMLException | An exception from the parser or client handler code. | |
DOM_DOMException | A DOM exception as per DOM spec. |
Implements DOMBuilder.
virtual void DOMBuilderImpl::parseWithContext | ( | const DOMInputSource & | source, | |
DOMNode *const | contextNode, | |||
const short | action | |||
) | [virtual] |
"Experimental - subject to change"
Parse via an input source object
This method invokes the parsing process on the XML file specified by the DOMInputSource parameter, and inserts the content into an existing document at the position specified with the contextNode and action arguments. When parsing the input stream the context node is used for resolving unbound namespace prefixes.
source | A const reference to the DOMInputSource object which points to the XML file to be parsed. | |
contextNode | The node that is used as the context for the data that is being parsed. This node must be a Document node, a DocumentFragment node, or a node of a type that is allowed as a child of an element, e.g. it can not be an attribute node. | |
action | This parameter describes which action should be taken between the new set of node being inserted and the existing children of the context node. |
DOMException | NOT_SUPPORTED_ERR: Raised when the DOMBuilder doesn't support this method. NO_MODIFICATION_ALLOWED_ERR: Raised if the context node is readonly. |
Implements DOMBuilder.
virtual void DOMBuilderImpl::release | ( | ) | [virtual] |
Called to indicate that this DOMBuilder is no longer in use and that the implementation may relinquish any resources associated with it.
Implements DOMBuilder.
virtual void DOMBuilderImpl::resetCachedGrammarPool | ( | ) | [virtual] |
Clear the cached grammar pool
Implements DOMBuilder.
virtual void DOMBuilderImpl::resetDocumentPool | ( | ) | [virtual] |
Reset the documents vector pool and release all the associated memory back to the system.
When parsing a document using a DOM parser, all memory allocated for a DOM tree is associated to the DOM document.
If you do multiple parse using the same DOM parser instance, then multiple DOM documents will be generated and saved in a vector pool. All these documents (and thus all the allocated memory) won't be deleted until the parser instance is destroyed.
If you don't need these DOM documents anymore and don't want to destroy the DOM parser instance at this moment, then you can call this method to reset the document vector pool and release all the allocated memory back to the system.
It is an error to call this method if you are in the middle of a parse (e.g. in the mid of a progressive parse).
IOException | An exception from the parser if this function is called when a parse is in progress. |
Implements DOMBuilder.
void DOMBuilderImpl::resetEntities | ( | ) | [inline, virtual] |
Reset any entity handler information
This method allows the installed XMLEntityHandler to reset itself.
<font color="#FF0000">This method is a no-op for this DOM implementation.</font>
Implements XMLEntityHandler.
Definition at line 852 of file DOMBuilderImpl.hpp.
virtual void DOMBuilderImpl::resetErrors | ( | ) | [virtual] |
Reset any error data before a new parse
This method allows the user installed Error Handler callback to 'reset' itself.
<font color="#FF0000">This method is a no-op for this DOM implementation.</font>
Implements XMLErrorReporter.
virtual InputSource* DOMBuilderImpl::resolveEntity | ( | const XMLCh *const | publicId, | |
const XMLCh *const | systemId, | |||
const XMLCh *const | baseURI = 0 | |||
) | [virtual] |
Resolve a public/system id
This method allows a user installed entity handler to further process any pointers to external entities. The applications can implement 'redirection' via this callback. This method is also borrowed from the SAX specification.
publicId | A const pointer to a Unicode string representing the public id of the entity just parsed. | |
systemId | A const pointer to a Unicode string representing the system id of the entity just parsed. | |
baseURI | A const pointer to a Unicode string representing the base URI of the entity just parsed, or null if there is no base URI. |
Implements XMLEntityHandler.
void DOMBuilderImpl::setEntityResolver | ( | DOMEntityResolver *const | handler | ) | [virtual] |
"Experimental - subject to change"
Set the entity resolver
This method allows applications to install their own entity resolver. By installing an entity resolver, the applications can trap and potentially redirect references to external entities.
Any previously set resolver is merely dropped, since the parser does not own them.
handler | A const pointer to the user supplied entity resolver. |
Implements DOMBuilder.
void DOMBuilderImpl::setErrorHandler | ( | DOMErrorHandler *const | handler | ) | [virtual] |
"Experimental - subject to change"
Set the error handler
This method allows applications to install their own error handler to trap error and warning messages.
Any previously set handler is merely dropped, since the parser does not own them.
handler | A const pointer to the user supplied error handler. |
Implements DOMBuilder.
void DOMBuilderImpl::setFeature | ( | const XMLCh *const | name, | |
const bool | state | |||
) | [virtual] |
"Experimental - subject to change"
Set the state of a feature
It is possible for a DOMBuilder to recognize a feature name but to be unable to set its value.
name | The feature name. | |
state | The requested state of the feature (true or false). |
DOMException | NOT_SUPPORTED_ERR: Raised when the DOMBuilder recognizes the feature name but cannot set the requested value. NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize the feature name. |
Implements DOMBuilder.
void DOMBuilderImpl::setFilter | ( | DOMBuilderFilter *const | filter | ) | [virtual] |
"Experimental - subject to change"
Set the application filter
When the application provides a filter, the parser will call out to the filter at the completion of the construction of each Element node. The filter implementation can choose to remove the element from the document being constructed (unless the element is the document element) or to terminate the parse early. If the document is being validated when it's loaded the validation happens before the filter is called.
Any previously set filter is merely dropped, since the parser does not own them.
filter | A const pointer to the user supplied application filter. |
Implements DOMBuilder.
virtual void DOMBuilderImpl::setProperty | ( | const XMLCh *const | name, | |
void * | value | |||
) | [virtual] |
Set the value of any property in a DOMBuilder. See http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties for the list of supported properties.
It takes a void pointer as the property value. Application is required to initialize this void pointer to a correct type. See http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties to learn exactly what type of property value each property expects for processing. Passing a void pointer that was initialized with a wrong type will lead to unexpected result. If the same property is set more than once, the last one takes effect.
name | The unique identifier (URI) of the property being set. | |
value | The requested value for the property. See http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties to learn exactly what type of property value each property expects for processing. Passing a void pointer that was initialized with a wrong type will lead to unexpected result. |
DOMException | NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize the requested property. |
Implements DOMBuilder.
void DOMBuilderImpl::startInputSource | ( | const InputSource & | inputSource | ) | [inline, virtual] |
Handle a 'start input source' event
This method is used to indicate the start of parsing an external entity file.
<font color="#FF0000">This method is a no-op for this DOM parse implementation.</font>
inputSource | A const reference to the InputSource object which points to the external entity being parsed. |
Implements XMLEntityHandler.
Definition at line 857 of file DOMBuilderImpl.hpp.
bool DOMBuilderImpl::fAutoValidation [private] |
Definition at line 827 of file DOMBuilderImpl.hpp.
bool DOMBuilderImpl::fCharsetOverridesXMLEncoding [private] |
Definition at line 832 of file DOMBuilderImpl.hpp.
DOMEntityResolver* DOMBuilderImpl::fEntityResolver [private] |
DOMErrorHandler* DOMBuilderImpl::fErrorHandler [private] |
DOMBuilderFilter* DOMBuilderImpl::fFilter [private] |
bool DOMBuilderImpl::fUserAdoptsDocument [private] |
Definition at line 833 of file DOMBuilderImpl.hpp.
bool DOMBuilderImpl::fValidation [private] |
Definition at line 828 of file DOMBuilderImpl.hpp.