XML parsers

XML parsers

The interface between Sculptor and XML requires tools that enable XML information to be read and written. The first release contains XML parser routines, constructed to enable Sculptor programmers to read and validate XML data. Future releases will contain additional tools.

There are two types of parser, SAX (Simple API for XML) and DOM (Document Object Model).


SAX (Simple API for XML)

This is the parser type implemented on Sculptor. It works in a callback way. Whenever it encounters start tags, end tags and attributes, it calls an event function. This parser type needs little memory space, and a standard SAX 1.0 parser has been chosen for use with Sculptor.

This is the sequence of events in an XML application using a SAX parser:

1

Register the three event handlers, to process XML definitions, DTD definitions and errors. See Event handler functions.

2

Call the parser function xml_parse() to start processing the XML file.

3

SAX calls the event handler functions as required to process the contents of the XML file. This enables the Sculptor programmer to retrieve the attributes and contents of the elements that compose the XML file.


DOM (Document Object Model)

Reads all the XML data and generates a tree structure in memory, representing the entire XML document. This requires large memory resources. Big data files are difficult to parse because of limited memory space. Although this parser type has not been implemented in Sculptor, an ActiveX object implementing a DOM parser is available under Windows if required.


RELATED TOPICS

XML