The SAXParser Package provides an interface to the XML SAX parser. The SAX parser provides the ability to use a lightweight XML parser. One set of methods configures the various options for parsing. Another set of methods is used to set up the callbacks that are necessary for the SAX parser to report its results. Two callbacks, StartDocument and EndDocument, signals of the start and end of parsing a document. Another set of callbacks, StartElement and EndElement tell when the start and end of a tag is found. Last the callback, Characters, reports the data value for a tag.


Class Methods Index

 o New()
Create a new SAXParser instance.

Instance Methods Index

 o Parse( String xmlFile )
Parse an XML file.
 o SetDoValidation( Boolean arg1 )
Determines whether the XML document should be validated against the Document Type Definition (DTD).
 o SetDoNamespaces( Boolean arg1 )
Determines whether support for XML Namespaces should be enabled.
 o SetExitOnFirstFatalError( Boolean arg1 )
Determines whether parsing should be ended when the first fatal error occurs.
 o SetDeleteTmpFiles( Boolean arg1 )
Determines if temporary files should be deleted immediately after the element that uses the the temporary file is processed.
 o RemoveTmpFiles()
Forces the removal of all temporary files if a document is not being parsed.
 o SetTmpFileTags( List arg1 )
Sets a list of tags that require temporary files because their content (value) is too large for an Oscript string.
 o SetCharactersHandler( Dynamic sax, Dynamic handler )
Receive notification of character data.
 o SetEndDocumentHandler( Dynamic sax, Dynamic handler )
Receive notification of the end of a document.
 o SetEndElementHandler( Dynamic sax, Dynamic handler )
Receive notification of the end of an element.
 o SetIgnorableWhitespaceHandler( Dynamic sax, Dynamic handler )
Receive notification of ignorable whitespace in element content.
 o SetProcessingInstructionHandler( Dynamic sax, Dynamic handler )
Receive notification of a processing instruction.
 o SetResetDocumentHandler( Dynamic sax, Dynamic handler )
Reset the Document object on its reuse.
 o SetStartDocumentHandler( Dynamic sax, Dynamic handler )
Receive notification of the beginning of a document.
 o SetStartElementHandler( Dynamic sax, Dynamic handler )
Receive notification of the beginning of an element.

Class Methods

 o New
 SAXParser New()

Create a new SAXParser instance.

Returns:
A new SAXParser.

Instance Methods

 o Parse
 Assoc Parse(
          String xmlFile )

Parse an XML file.

Parameters:
xmlFile  -  XML file to be parsed.
Returns:
An Assoc that contains:
Boolean   OK  -  Status of the parse.
RecArray   Error  -  Errors that occurred during parsing.
 
If the status of the parse is false, then the error RecArray contains:
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.
 
 
 o SetDoValidation
 Void SetDoValidation(
              Boolean newState )

Determines whether the XML document should be validated against the Document Type Definition (DTD).

Parameters:
newState  -  True if the XML document should be validated against the DTD.
 
 o SetDoNamespaces
 Void SetDoNamespaces(
              Boolean newState )

Determines whether support for XML Namespaces should be enabled.

Parameters:
newState  -  True if namespaces should be enabled.
 
 o SetExitOnFirstFatalError
 Void SetExitOnFirstFatalError(
                   Boolean newState )

Determines whether parsing should be ended when the first fatal error occurs.

Parameters:
newState  -  True if exit on first error.
 
 o SetDeleteTmpFiles
 Void SetDeleteTmpFiles(
                   Boolean newState )

Determines if temporary files should be deleted immediately after the element that uses the the temporary file is processed.

Parameters:
newState  -  True if temporary file should be deleted after tag is processed.
 
 o RemoveTmpFiles
 Void RemoveTmpFiles()

Removes temporary files if a document is not being parsed.

 o SetTmpFileTags
 Void SetTmpFileTags(
                   List tags )

Sets a list of tags that require temporary files because their content (value) is too large for an oscript string. If a tag is passed in this list, then when the StartElement callback occurs an attribute "filename" is added to the attribute list. The value for the attribute holds the name of the temporary file.

Parameters:
tags  -  List of strings that will require temporary files.
 
 o SetCharactersHandler
 Void SetCharactersHandler(
                   Dynamic sax,
                   Dynamic handler )

Receive notification of character data. The characters handler is void Characters ( String name, Integer size ) , where the tag name is stored in the variable name, and the variable size is the length of the name.

Parameters:
sax  -  An instance of the sax parser.
handler  -  An instance of the handler method.
 
 o SetEndDocumentHandler
 Void SetEndDocumentHandler(
                   Dynamic sax,
                   Dynamic handler )

Receive notification of the end of a document. The end document handler is EndDocument ().

Parameters:
sax  -  An instance of the sax parser.
handler  -  An instance of the handler method.
 
 o SetEndElementHandler
 Void SetEndElementHandler(
                   Dynamic sax,
                   Dynamic handler )

Receive notification of the end of an element. The end element handler is void EndElement ( String name ) , where the tag name is stored in the variable name.

Parameters:
sax  -  An instance of the sax parser.
handler  -  An instance of the handler method.
 
 o SetIgnorableWhitespaceHandler
 Void SetIgnorableWhitespaceHandler(
                   Dynamic sax,
                   Dynamic handler )

Receive notification of the end of an element. The ignorable whitespace handler is void IgnorableWhitespace ( String chars, Integer size ) , where the variable chars stores the characters to ignore, and the variable size is the length of the chars.

Parameters:
sax  -  An instance of the sax parser.
handler  -  An instance of the handler method.
 
 o SetProcessingInstructionHandler
 Void SetProcessingInstructionHandler(
                   Dynamic sax,
                   Dynamic handler )

Receive notification of a processing instruction. The handler for processing instruction of the form void ProcessingInstruction ( String target, String data ) , where target is the target of the processing instruction and data is the processing instruction data.

Parameters:
sax  -  An instance of the sax parser.
handler  -  An instance of the handler method.
 
 o SetResetDocumentHandler
 Void SetResetDocumentHandler(
                   Dynamic sax,
                   Dynamic handler )

Reset the document on its reuse. The handler is void ResetDocument ( )

Parameters:
sax  -  An instance of the sax parser.
handler  -  An instance of the handler method.
 
 o SetStartDocumentHandler
 Void SetStartDocumentHandler(
                   Dynamic sax,
                   Dynamic handler )

Receive notification of the beginning of a document. The handler signature is StartDocument ( ).

Parameters:
sax  -  An instance of the sax parser.
handler  -  An instance of the handler method.
 
 o SetStartElementHandler
 Void SetStartElementHandler(
                   Dynamic sax,
                   Dynamic handler )

Receive notification of the beginning of an element. The handler signature is StartElement ( String name, Assoc attributes ), where the name of the element is the first argument and attributes is an Assoc which holds the name, value pairs for the attributes of the element.

Parameters:
sax  -  An instance of the sax parser.
handler  -  An instance of the handler method.