http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Download
Installation
Build

API Docs
Samples
Schema

FAQs
Programming
Migration

Releases
Bug-Reporting
Feedback

Y2K Compliance
PDF Document

CVS Repository
Mail Archive

API Docs for SAX and DOM
 

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

DOMParser Class Reference

This class implements the Document Object Model (DOM) interface. More...

#include <DOMParser.hpp>

Inheritance diagram for DOMParser

Inheritance graph
[legend]
Collaboration diagram for DOMParser:

Collaboration graph
[legend]
List of all members.

Public Types

enum  ValSchemes { Val_Never, Val_Always, Val_Auto }

Public Methods

void reset ()
 Reset the parser. More...

Constructors and Destructor
 DOMParser (XMLValidator *const valToAdopt=0)
 Construct a DOMParser, with an optional validator. More...

 ~DOMParser ()
 Destructor.

Getter methods
DOM_Document getDocument ()
 Get the DOM document. More...

ErrorHandlergetErrorHandler ()
 Get a pointer to the error handler. More...

const ErrorHandlergetErrorHandler ()const
 Get a const pointer to the error handler. More...

EntityResolvergetEntityResolver ()
 Get a pointer to the entity resolver. More...

const EntityResolvergetEntityResolver ()const
 Get a const pointer to the entity resolver. More...

const XMLScanner& getScanner ()const
 Get a const reference to the underlying scanner. More...

const XMLValidatorgetValidator ()const
 Get a const reference to the validator. More...

ValSchemes getValidationScheme ()const
 This method returns an enumerated value that indicates the current validation scheme set on this parser. More...

bool getDoSchema ()const
 Get the 'do schema' flag. More...

bool getValidationSchemaFullChecking ()const
 Get the 'full schema constraint checking' flag. More...

int getErrorCount ()const
 Get error count from the last parse operation. More...

bool getDoNamespaces ()const
 Get the 'do namespaces' flag. More...

bool getExitOnFirstFatalError ()const
 Get the 'exit on first error' flag. More...

bool getValidationConstraintFatal ()const
 This method returns the state of the parser's validation-constraint-fatal flag. More...

bool getExpandEntityReferences ()const
 Get the 'expand entity references' flag. More...

bool getCreateEntityReferenceNodes ()const
 Get the 'include entity references' flag. More...

bool getIncludeIgnorableWhitespace ()const
 Get the 'include ignorable whitespace' flag. More...

bool getToCreateXMLDeclTypeNode ()const
 Get the 'to create MXLDecl node' flag. More...

Setter methods
void setErrorHandler (ErrorHandler *const handler)
 Set the error handler. More...

void setEntityResolver (EntityResolver *const handler)
 Set the entity resolver. More...

void setDoNamespaces (const bool newState)
 Set the 'do namespaces' flag. More...

void setExitOnFirstFatalError (const bool newState)
 Set the 'exit on first error' flag. More...

void setValidationConstraintFatal (const bool newState)
 This method allows users to set the parser's behaviour when it encounters a validtion constraint error. More...

void setExpandEntityReferences (const bool expand)
 Set the 'expand entity references' flag. More...

void setCreateEntityReferenceNodes (const bool create)
 Set the 'include entity references' flag. More...

void setIncludeIgnorableWhitespace (const bool include)
 Set the 'include ignorable whitespace' flag. More...

void setValidationScheme (const ValSchemes newScheme)
 This method allows users to set the validation scheme to be used by this parser. More...

void setDoSchema (const bool newState)
 Set the 'do schema' flag. More...

void setValidationSchemaFullChecking (const bool schemaFullChecking)
 This method allows the user to turn full Schema constraint checking on/off. More...

void setToCreateXMLDeclTypeNode (const bool create)
 This method allows users to set the toCreateXMLDeclTypeNode flag by this parser. More...

Parsing methods
void parse (const InputSource &source,const bool reuseGrammar=false)
 Parse via an input source object. More...

void parse (const XMLCh *const systemId,const bool reuseGrammar=false)
 Parse via a file path or URL. More...

void parse (const char *const systemId,const bool reuseGrammar=false)
 Parse via a file path or URL (in the local code page). More...

bool parseFirst (const XMLCh *const systemId,XMLPScanToken &toFill,const bool reuseGrammar=false)
 Begin a progressive parse operation. More...

bool parseFirst (const char *const systemId,XMLPScanToken &toFill,const bool reuseGrammar=false)
 Begin a progressive parse operation. More...

bool parseFirst (const InputSource &source,XMLPScanToken &toFill,const bool reuseGrammar=false)
 Begin a progressive parse operation. More...

bool parseNext (XMLPScanToken &token)
 Continue a progressive parse operation. More...

void parseReset (XMLPScanToken &token)
 Reset the parser after a progressive parse. More...

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 unsigned int lineNum,const unsigned int colNum)
 Handle errors reported from the parser. More...

virtual void resetErrors ()
 Reset any error data before a new parse. More...

Implementation of the XMLEntityHandler interface.
virtual void endInputSource (const InputSource &inputSource)
 Handle an end of input source event. More...

virtual bool expandSystemId (const XMLCh *const systemId,XMLBuffer &toFill)
 Expand a system id. More...

virtual void resetEntities ()
 Reset any entity handler information. More...

virtual InputSourceresolveEntity (const XMLCh *const publicId,const XMLCh *const systemId)
 Resolve a public/system id. More...

virtual void startInputSource (const InputSource &inputSource)
 Handle a 'start input source' event. More...

Implementation of the XMLDocumentHandler interface.
virtual void docCharacters (const XMLCh *const chars,const unsigned int length,const bool cdataSection)
 Handle document character events. More...

virtual void docComment (const XMLCh *const comment)
 Handle a document comment event. More...

virtual void docPI (const XMLCh *const target,const XMLCh *const data)
 Handle a document PI event. More...

virtual void endDocument ()
 Handle the end of document event. More...

virtual void endElement (const XMLElementDecl &elemDecl,const unsigned int urlId,const bool isRoot)
 Handle and end of element event. More...

virtual void endEntityReference (const XMLEntityDecl &entDecl)
 Handle and end of entity reference event. More...

virtual void ignorableWhitespace (const XMLCh *const chars,const unsigned int length,const bool cdataSection)
 Handle an ignorable whitespace vent. More...

virtual void resetDocument ()
 Handle a document reset event. More...

virtual void startDocument ()
 Handle a start document event. More...

virtual void startElement (const XMLElementDecl &elemDecl,const unsigned int urlId,const XMLCh *const elemPrefix,const RefVectorOf< XMLAttr > &attrList,const unsigned int attrCount,const bool isEmpty,const bool isRoot)
 Handle a start element event. More...

virtual void startEntityReference (const XMLEntityDecl &entDecl)
 Handle a start entity reference event. More...

virtual void XMLDecl (const XMLCh *const versionStr,const XMLCh *const encodingStr,const XMLCh *const standaloneStr,const XMLCh *const actualEncStr)
 Handle an XMLDecl event. More...

Deprecated Methods
bool getDoValidation ()const
 This method returns the state of the parser's validation handling flag which controls whether validation checks are enforced or not. More...

void setDoValidation (const bool newState)
 This method allows users to enable or disable the parser's validation checks. More...

virtual void attDef (const DTDElementDecl &elemDecl,const DTDAttDef &attDef,const bool ignoring)
 Deprecated doctypehandler interfaces.

virtual void doctypeComment (const XMLCh *const comment)
virtual void doctypeDecl (const DTDElementDecl &elemDecl,const XMLCh *const publicId,const XMLCh *const systemId,const bool hasIntSubset)
virtual void doctypePI (const XMLCh *const target,const XMLCh *const data)
virtual void doctypeWhitespace (const XMLCh *const chars,const unsigned int length)
virtual void elementDecl (const DTDElementDecl &decl,const bool isIgnored)
virtual void endAttList (const DTDElementDecl &elemDecl)
virtual void endIntSubset ()
virtual void endExtSubset ()
virtual void entityDecl (const DTDEntityDecl &entityDecl,const bool isPEDecl,const bool isIgnored)
virtual void resetDocType ()
virtual void notationDecl (const XMLNotationDecl &notDecl,const bool isIgnored)
virtual void startAttList (const DTDElementDecl &elemDecl)
virtual void startIntSubset ()
virtual void startExtSubset ()
virtual void TextDecl (const XMLCh *const versionStr,const XMLCh *const encodingStr)

Protected Methods

Protected getter methods
DOM_Node getCurrentNode ()
 Get the current DOM node. More...

Protected setter methods
void setCurrentNode (DOM_Node toSet)
 Set the current DOM node. More...

void setDocument (DOM_Document toSet)
 Set the document node. More...


Detailed Description

This class implements the Document Object Model (DOM) interface.

It should be used by applications which choose to parse and process the XML document using the DOM api's. This implementation also allows the applications to install an error and an entitty handler (useful extensions to the DOM specification).

It can be used to instantiate a validating or non-validating parser, by setting a member flag.


Member Enumeration Documentation

enum DOMParser::ValSchemes
 

Enumeration values:
Val_Never  
Val_Always  
Val_Auto  


Constructor & Destructor Documentation

DOMParser::DOMParser ( XMLValidator *const valToAdopt = 0 )
 

Construct a DOMParser, 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.

Parameters:
valToAdopt   Pointer to the validator instance to use. The parser is responsible for freeing the memory.

DOMParser::~DOMParser ( )
 

Destructor.


Member Function Documentation

void DOMParser::TextDecl ( const XMLCh *const versionStr,
const XMLCh *const encodingStr ) [virtual]
 

void DOMParser::XMLDecl ( const XMLCh *const versionStr,
const XMLCh *const encodingStr,
const XMLCh *const standaloneStr,
const XMLCh *const actualEncStr ) [virtual]
 

Handle an XMLDecl event.

This method is used to report the XML decl scanned by the parser. Refer to the XML specification to see the meaning of parameters.

<font color="FF0000">This method is a no-op for this DOM implementation.</font>

Parameters:
versionStr   A const pointer to a Unicode string representing version string value.
encodingStr   A const pointer to a Unicode string representing the encoding string value.
standaloneStr   A const pointer to a Unicode string representing the standalone string value.
actualEncodingStr   A const pointer to a Unicode string representing the actual encoding string value.

Reimplemented from XMLDocumentHandler.

void DOMParser::attDef ( const DTDElementDecl & elemDecl,
const DTDAttDef & attDef,
const bool ignoring ) [virtual]
 

Deprecated doctypehandler interfaces.

void DOMParser::docCharacters ( const XMLCh *const chars,
const unsigned int length,
const bool cdataSection ) [virtual]
 

Handle document character events.

This method is used to report all the characters scanned by the parser. This DOM implementation stores this data in the appropriate DOM node, creating one if necessary.

Parameters:
chars   A const pointer to a Unicode string representing the character data.
length   The length of the Unicode string returned in 'chars'.
cdataSection   A flag indicating if the characters represent content from the CDATA section.

Reimplemented from XMLDocumentHandler.

void DOMParser::docComment ( const XMLCh *const comment ) [virtual]
 

Handle a document comment event.

This method is used to report any comments scanned by the parser. A new comment node is created which stores this data.

Parameters:
comment   A const pointer to a null terminated Unicode string representing the comment text.

Reimplemented from XMLDocumentHandler.

void DOMParser::docPI ( const XMLCh *const target,
const XMLCh *const data ) [virtual]
 

Handle a document PI event.

This method is used to report any PI scanned by the parser. A new PI node is created and appended as a child of the current node in the tree.

Parameters:
target   A const pointer to a Unicode string representing the target of the PI declaration.
data   A const pointer to a Unicode string representing the data of the PI declaration. See the PI production rule in the XML specification for details.

Reimplemented from XMLDocumentHandler.

void DOMParser::doctypeComment ( const XMLCh *const comment ) [virtual]
 

void DOMParser::doctypeDecl ( const DTDElementDecl & elemDecl,
const XMLCh *const publicId,
const XMLCh *const systemId,
const bool hasIntSubset ) [virtual]
 

void DOMParser::doctypePI ( const XMLCh *const target,
const XMLCh *const data ) [virtual]
 

void DOMParser::doctypeWhitespace ( const XMLCh *const chars,
const unsigned int length ) [virtual]
 

void DOMParser::elementDecl ( const DTDElementDecl & decl,
const bool isIgnored ) [virtual]
 

void DOMParser::endAttList ( const DTDElementDecl & elemDecl ) [virtual]
 

void DOMParser::endDocument ( ) [virtual]
 

Handle the end of document event.

This method is used to indicate the end of the current document.

Reimplemented from XMLDocumentHandler.

void DOMParser::endElement ( const XMLElementDecl & elemDecl,
const unsigned int urlId,
const bool isRoot ) [virtual]
 

Handle and end of element event.

This method is used to indicate the end tag of an element. The DOMParse pops the current element off the top of the element stack, and make it the new current element.

Parameters:
elemDecl   A const reference to the object containing element declaration information.
urlId   An id referring to the namespace prefix, if namespaces setting is switched on.
isRoot   A flag indicating whether this element was the root element.

Reimplemented from XMLDocumentHandler.

void DOMParser::endEntityReference ( const XMLEntityDecl & entDecl ) [virtual]
 

Handle and end of entity reference event.

This method is used to indicate that an end of an entity reference was just scanned.

Parameters:
entDecl   A const reference to the object containing the entity declaration information.

Reimplemented from XMLDocumentHandler.

void DOMParser::endExtSubset ( ) [virtual]
 

void DOMParser::endInputSource ( const InputSource & inputSource ) [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>

Parameters:
inputSource   A const reference to the InputSource object which points to the XML file being parsed.
See also:
InputSource

Reimplemented from XMLEntityHandler.

void DOMParser::endIntSubset ( ) [virtual]
 

void DOMParser::entityDecl ( const DTDEntityDecl & entityDecl,
const bool isPEDecl,
const bool isIgnored ) [virtual]
 

void DOMParser::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 unsigned int lineNum,
const unsigned int 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.

Parameters:
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.
See also:
ErrorHandler

bool DOMParser::expandSystemId ( const XMLCh * const,
XMLBuffer & toFill ) [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>

Parameters:
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.
Returns:
'true', if any processing is done, 'false' otherwise.

Reimplemented from XMLEntityHandler.

bool DOMParser::getCreateEntityReferenceNodes ( ) const
 

Get the 'include entity references' flag.

This flag specifies whether the parser is creating entity reference nodes in the DOM tree being produced. When the 'create' flag is true, the DOM tree will contain entity reference nodes. When the 'create' flag is false, no entity reference nodes are included in the DOM tree.

The replacement text of the entity is included in either case, either as a child of the Entity Reference node or in place at the location of the reference.

Returns:
The state of the create entity reference node flag.
See also:
setCreateEntityReferenceNodes

DOM_Node DOMParser::getCurrentNode ( ) [protected]
 

Get the current DOM node.

This provides derived classes with access to the current node, i.e. the node to which new nodes are being added.

bool DOMParser::getDoNamespaces ( ) const
 

Get the 'do namespaces' flag.

This method returns the state of the parser's namespace processing flag.

Returns:
true, if the parser is currently configured to understand namespaces, false otherwise.

See also:
setDoNamespaces

bool DOMParser::getDoSchema ( ) const
 

Get the 'do schema' flag.

This method returns the state of the parser's schema processing flag.

Returns:
true, if the parser is currently configured to understand schema, false otherwise.

See also:
setDoSchema

bool DOMParser::getDoValidation ( ) const
 

This method returns the state of the parser's validation handling flag which controls whether validation checks are enforced or not.

Returns:
true, if the parser is currently configured to do validation, false otherwise.

See also:
setDoValidation

DOM_Document DOMParser::getDocument ( )
 

Get the DOM document.

This method returns the DOM_Document object representing the root of the document tree. This object provides the primary access to the document's data.

Returns:
The DOM_Document object which represents the entire XML document.

const EntityResolver * DOMParser::getEntityResolver ( ) const
 

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.

Returns:
A const pointer to the installed entity resolver object.

EntityResolver * DOMParser::getEntityResolver ( )
 

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.

Returns:
The pointer to the installed entity resolver object.

int DOMParser::getErrorCount ( ) const
 

Get error count from the last parse operation.

This method returns the error count from the last parse operation. Note that this count is actually stored in the scanner, so this method simply returns what the scanner reports.

Returns:
number of errors encountered during the latest parse operation.

const ErrorHandler * DOMParser::getErrorHandler ( ) const
 

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.

Returns:
A const pointer to the installed error handler object.

ErrorHandler * DOMParser::getErrorHandler ( )
 

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.

Returns:
The pointer to the installed error handler object.

bool DOMParser::getExitOnFirstFatalError ( ) const
 

Get the 'exit on first error' flag.

This method returns the state of the parser's exit-on-First-Fatal-Error flag. If this flag is true, then the parse will exit the first time it sees any non-wellformed XML or any validity error. The default state is true.

Returns:
true, if the parser is currently configured to exit on the first fatal error, false otherwise.

See also:
setExitOnFirstFatalError

bool DOMParser::getExpandEntityReferences ( ) const
 

Get the 'expand entity references' flag.

DEPRECATED Use getCreateEntityReferenceNodes() instead.

This method returns the state of the parser's expand entity references flag.

Returns:
'true' if the expand entity reference flag is set on the parser, 'false' otherwise.

See also:
setExpandEntityReferences

bool DOMParser::getIncludeIgnorableWhitespace ( ) const
 

Get the 'include ignorable whitespace' flag.

This method returns the state of the parser's include ignorable whitespace flag.

Returns:
'true' if the include ignorable whitespace flag is set on the parser, 'false' otherwise.

See also:
setIncludeIgnorableWhitespace

const XMLScanner & DOMParser::getScanner ( ) const
 

Get a const reference to the underlying scanner.

This method returns a reference to the underlying scanner object. It allows read only access to data maintained in the scanner.

Returns:
A const reference to the underlying scanner object.

bool DOMParser::getToCreateXMLDeclTypeNode ( ) const
 

Get the 'to create MXLDecl node' flag.

This method returns the state of the parser's to create XMLDecl DOM Node flag.

Returns:
'true' if the toCreateXMLDeclTypeNode flag is set on the parser, 'false' otherwise.

bool DOMParser::getValidationConstraintFatal ( ) const
 

This method returns the state of the parser's validation-constraint-fatal flag.

Returns:
true, if the parser is currently configured to set validation constraint errors as fatal, false otherwise.

See also:
setValidationContraintFatal

bool DOMParser::getValidationSchemaFullChecking ( ) const
 

Get the 'full schema constraint checking' flag.

This method returns the state of the parser's full schema constraint checking flag.

Returns:
true, if the parser is currently configured to have full schema constraint checking, false otherwise.

See also:
setValidationSchemaFullChecking

ValSchemes DOMParser::getValidationScheme ( ) const
 

This method returns an enumerated value that indicates the current validation scheme set on this parser.

Returns:
The ValSchemes value current set on this parser.
See also:
setValidationScheme

const XMLValidator & DOMParser::getValidator ( ) const
 

Get a const reference to the validator.

This method returns a reference to the parser's installed validator.

Returns:
A const reference to the installed validator object.

void DOMParser::ignorableWhitespace ( const XMLCh *const chars,
const unsigned int length,
const bool cdataSection ) [virtual]
 

Handle an ignorable whitespace vent.

This method is used to report all the whitespace characters, which are determined to be 'ignorable'. This distinction between characters is only made, if validation is enabled.

Any whitespace before content is ignored. If the current node is already of type DOM_Node::TEXT_NODE, then these whitespaces are appended, otherwise a new Text node is created which stores this data. Essentially all contiguous ignorable characters are collected in one node.

Parameters:
chars   A const pointer to a Unicode string representing the ignorable whitespace character data.
length   The length of the Unicode string 'chars'.
cdataSection   A flag indicating if the characters represent content from the CDATA section.

Reimplemented from XMLDocumentHandler.

void DOMParser::notationDecl ( const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const