Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
An XML Parser

This library contains an API for creating, using and destroying a standards-compliant, non-validating XML parser. This serves both as an example of a relatively complex APG-generated parser and as a practical, useful, non-validating XML parser. It will parse both the XML declaration and the Document Type Declaration (DTD) if present. As a non-validating XML parser it will:

  • check the document for well-formedness
  • parse the XML declaration, if any
  • parse the DTD internal subset, if any
  • record any defined entity values
  • record any defined default attribute names and (normalized) values
  • recognize and honor defined entity and default attribute values while parsing the body of the XML document

This is an event-based parser as opposed to a Document Object Model (DOM) type parser. It provides an API that exposes parsed information at well-defined document events. The document events are handled through user-written callback functions. Be aware that data presented to the callback function is transient. It is valid only for the duration of the call. The application will need to make copies into it's own memory space of any data that needs to be retained for later use. Events may be ignored simply by not providing a callback function for the event. The document events are:

  • the XML declaration information
  • the DTD information
  • the element name, attribute names and values in an empty element
  • the element name, attribute names and values in a start tag
  • the element name and content at the end tag
  • the target name and instructions of a Processing Instruction
  • the comment text of parsed comments

Full documentation can be found in xml.h, xmlp.h and xml.c.

APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.