The DOMParser Package provides an interface to the Document Object Model (DOM) XML parser. The DOM parser provides the ability to validate an XML document according to a Document Type Definition (DTD), to validate for well-formedness, support for namespaces. A set of methods configure various options for parsing and the ability to retrieve the DOMDocument node that represents the root node of the document.
Integer INDEX_SIZE_ERR
If index or size is negative, or greater than the allowed value
DOMSTRING_SIZE_ERRInteger DOMSTRING_SIZE_ERR
If the specified range of text does not fit into a DOMString
HIERARCHY_REQUEST_ERRInteger HIERARCHY_REQUEST_ERR
If any node is inserted somewhere it doesn't belong
WRONG_DOCUMENT_ERRInteger WRONG_DOCUMENT_ERR
If a node is used in a different document than the one that created it (that doesn't support it)
INVALID_CHARACTER_ERRInteger INVALID_CHARACTER_ERR
If an invalid character is specified, such as in a name
NO_DATA_ALLOWED_ERRInteger NO_DATA_ALLOWED_ERR
If data is specified for a node which does not support data
NO_MODIFICATION_ALLOWED_ERRInteger NO_MODIFICATION_ALLOWED_ERR
If an attempt is made to modify an object where modifications are not allowed
NOT_FOUND_ERRInteger NOT_FOUND_ERR
If an attempt was made to reference a node in a context where it does not exist
NOT_SUPPORTED_ERRInteger NOT_SUPPORTED_ERR
If the implementation does not support the type of object requested
INUSE_ATTRIBUTE_ERRInteger INUSE_ATTRIBUTE_ERR
If an attempt is made to add an attribute that is already inuse elsewhere
INVALID_STATE_ERRInteger INVALID_STATE_ERR
Introduced in DOM Level 2. If an attempt is made to use an object that is not, or no longer, usable
SYNTAX_ERRInteger SYNTAX_ERR
Introduced in DOM Level 2. If an invalid or illegal string is specified.
INVALID_MODIFICATION_ERRInteger INVALID_MODIFICATION_ERR
Introduced in DOM Level 2. If an attempt is made to modify the type of the underlying object.
NAMESPACE_ERRInteger NAMESPACE_ERR
Introduced in DOM Level 2. If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
INVALID_ACCESS_ERRInteger INVALID_ACCESS_ERR
Introduced in DOM Level 2. If a parameter or an operation is not supported by the underlying object.
UNKNOWN_EXCEPTIONInteger UNKNOWN_EXCEPTION
Exception thrown that does not correspond to any of the known DOM exceptions.
MessageInteger Message
Informational status or message.
WarningInteger Warning
Warning message.
ErrorInteger Error
Recoverable error.
FatalErrorInteger FatalError
Error that will stop processing.
Val_NeverInteger Val_Never
Validation scheme - never validate. See SetValidationScheme.
Val_AlwaysInteger Val_Always
Validation scheme - always validate. See SetValidationScheme.
Val_AutoInteger Val_Auto
Validation scheme - automatically validate (default). See SetValidationScheme.
NewDOMParser New()
Create a new DOMParser instance.
Assoc Parse( String xmlFile )
Parse an XML file into a DOM representation.
xmlFile | - | XML file to be parsed. |
Boolean | OK | - | Status of the parse. | |
RecArray | Error | - | Errors that occurred during parsing. |
String | ErrType | - | The type of error: warning, error or fatal. | |
String | ErrMsg | - | Parser generated error message. | |
String | PublicID | - | Public Identifier of the XML file, filename in this instance. | |
String | SystemId | - | System Identifier of the XML file, usually empty. | |
Integer | LineNumber | - | Line number in the file in which the error occurred. | |
Integer | ColumnNumber | - | Column number in the file in which the error occurred. |
Assoc ParseBytes( Bytes xmlData )
Parse an XML bytes array into a DOM representation.
xmlData | - | XML bytes array to be parsed. |
Boolean | OK | - | Status of the parse. | |
RecArray | Error | - | Errors that occurred during parsing. |
DOMDocument GetDocument()
Retrieves the Document node of the parsed document.
Integer GetErrorCount()
Retrieves the number of parse errors associated with the parsed document.
Void SetDoValidation( Boolean newState )
Determines whether the XML document should be validated against the Document Type Definition (DTD). This method has been DEPRECATED and is replaced with SetValidationScheme
newState | - | TRUE if the XML document should be validated against the DTD. |
Boolean GetDoNamespaces()
Returns whether parser support for XML Namespaces is enabled.
Void SetDoNamespaces( Boolean newState )
Determines whether support for XML Namespaces should be enabled.
newState | - | TRUE if namespaces should be enabled. |
Void SetExpandEntityReferences( Boolean newState )
Determines whether Entities should be expanded when parsed. This method has been DEPRECATED, and is replaced with SetCreateEntityReferenceNodes
newState | - | TRUE if entities should be expanded when parsed. |
Void SetEntityResolver( Dynamic objref, Dynamic entryName )
Sets the object reference and entry point name for the resolve entity callback.
The callback script prototype is:
String ResolveEntity( String publicID, String systemID )The return value is a string to the resolved entity. An undefined return value indicates to the parser that it should use its default internal entity resolution.
objref | - | The reference to the object that has the script to be used in the callback. |
entryName | - | The script name of the callback that will be executed on callback. |
Boolean GetExitOnFirstFatalError()
Returns whether parsing should exit with the first fatal error.
Void SetExitOnFirstFatalError( Boolean newState )
Determines whether parsing should exit with the first fatal error.
newState | - | TRUE if parsing should exit with the first fatal error. |
Boolean GetValidationConstraintFatal()
Returns whether the parser will consider validation constraint errors as fatal.
Void SetValidationConstraintFatal( Boolean newState )
Determines whether the parser should consider validation constraint errors as fatal errors.
newState | - | TRUE, if the parser should consider validation constraint errors as fatal errors, FALSE otherwise. |
Boolean GetCreateEntityReferenceNodes()
Returns whether the parser will expand/create entity references when parsed.
Void SetCreateEntityReferenceNodes( Boolean newState )
Determines whether the parser should expand/create entity references.
newState | - | TRUE, if the parser should expand/create entity references, FALSE otherwise. |
Boolean GetIncludeIgnorableWhitespace()
Returns whether parsed text nodes that can be considered ignorable whitespace are included in the DOM tree.
Void SetIncludeIgnorableWhitespace( Boolean newState )
Determines whether the parser will create text nodes for ignorable whitespace.
newState | - | TRUE, if the parser will create text nodes for ignorable whitespace, FALSE otherwise. |
Integer GetValidationScheme()
Returns the parser validation scheme.
Void SetValidationScheme( Integer scheme )
Determines parser validation scheme.
scheme | - |
Val_Never The parser does not report validation errors. Val_Always The parser will always report validation errors. Val_Auto The parser will report validation errors only if a grammar is specified. |
Boolean GetDoSchema()
Returns whether the parser's schema support is enabled.
Void SetDoSchema( Boolean newState )
Determines whether the parser's schema support is enabled.
newState | - | TRUE, to enable the parser's schema support. FALSE, to disable the parser's schema support. |
Boolean GetValidationSchemaFullChecking()
Returns whether the parser will perform full schema constraint checking.
Void SetValidationSchemaFullChecking( Boolean newState )
Determines whether the parser will perform checks on the schema grammar itself for additional errors. These additional checks could be time-consuming or memory intensive. The default is FALSE.
newState | - | TRUE, enable full schema constraint checking. FALSE, disable full schema constraint checking. |
String GetExternalSchemaLocation()
Returns the previously specified list of schemas to use.
Void SetExternalSchemaLocation( String schemaList )
Set a list of schemas to use. The targetNamespace of a schema specified in this list will override the internal schema location in the instance document for both the schemaLocation attribute, or the "import" element.
schemaList | - | The syntax is the same as for schemaLocation attributes in an instance document: e.g, "http://www.schemas.com sample.xsd". The user can specify more than one XML schema in the list. |
String GetExternalNoNamespaceSchemaLocation()
Returns the previously specified no target namespace XML schema location.
Void SetExternalSchemaLocation( String location )
Provide the no target namespace XML schema location.
location | - | The syntax is the same as for the noNamespaceSchemaLocation attribute in an instance document: e.g, "sample.xsd". |
Boolean GetLoadExternalDTD()
Returns whether the parser will load external DTD when the validation scheme is Val_Never.
Void SetLoadExternalDTD( Boolean newState )
Determines whether the parser will load external DTD when the validation scheme is Val_Never. This flag is ignored if the validation scheme is set (see SetValidationScheme) to Val_Always or Val_Auto.
newState | - | FALSE, parser will ignore any external DTD completely when the validation scheme is Val_Never. TRUE, otherwise (default). |
Boolean GetCreateCommentNodes()
Returns whether the parser will create comment nodes in the DOM tree.
Void SetCreateCommentNodes( Boolean newState )
Determines whether the parser will create comment nodes in the DOM tree.
newState | - | TRUE, enables the creation of comment nodes in the DOM tree.
FALSE, disables the creation of comment nodes in the DOM tree. |