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.
SAXParser New()
Create a new SAXParser instance.
Assoc Parse( String xmlFile )
Parse an XML file.
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. |
Void SetDoValidation( Boolean newState )
Determines whether the XML document should be validated against the Document Type Definition (DTD).
newState | - | True if the XML document should be validated against the DTD. |
Void SetDoNamespaces( Boolean newState )
Determines whether support for XML Namespaces should be enabled.
newState | - | True if namespaces should be enabled. |
Void SetExitOnFirstFatalError( Boolean newState )
Determines whether parsing should be ended when the first fatal error occurs.
newState | - | True if exit on first error. |
Void SetDeleteTmpFiles( Boolean newState )
Determines if temporary files should be deleted immediately after the element that uses the the temporary file is processed.
newState | - | True if temporary file should be deleted after tag is processed. |
Void RemoveTmpFiles()
Removes temporary files if a document is not being parsed.
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.
tags | - | List of strings that will require temporary files. |
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.
sax | - | An instance of the sax parser. |
handler | - | An instance of the handler method. |
Void SetEndDocumentHandler( Dynamic sax, Dynamic handler )
Receive notification of the end of a document. The end document handler is EndDocument ().
sax | - | An instance of the sax parser. |
handler | - | An instance of the handler method. |
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.
sax | - | An instance of the sax parser. |
handler | - | An instance of the handler method. |
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.
sax | - | An instance of the sax parser. |
handler | - | An instance of the handler method. |
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.
sax | - | An instance of the sax parser. |
handler | - | An instance of the handler method. |
Void SetResetDocumentHandler( Dynamic sax, Dynamic handler )
Reset the document on its reuse. The handler is void ResetDocument ( )
sax | - | An instance of the sax parser. |
handler | - | An instance of the handler method. |
Void SetStartDocumentHandler( Dynamic sax, Dynamic handler )
Receive notification of the beginning of a document. The handler signature is StartDocument ( ).
sax | - | An instance of the sax parser. |
handler | - | An instance of the handler method. |
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.
sax | - | An instance of the sax parser. |
handler | - | An instance of the handler method. |