XML Parsing For Tcl
Download and Installation
TclXML is an API for parsing XML documents using the Tcl scripting language. It is also a package including a DOM implementation (TclDOM) and XSL Transformations (TclXSLT). These allow Tcl scripts to read, manipulate and write XML documents.
The goal of the TclXML package is to provide an API for Tcl scripts that allows "Plug-and-Play" parser implementations; ie. an application will be able to use different parser implementations without change to the application code.
The TclXML package provides a streaming, or "event-based", interface to an XML document. An application using TclXML creates a parser "object", sets a number of callback scripts and then instructs the parser to parse an XML document. The parser scans the XML document's text and as it finds certain constructs, such as the start/end of elements, character data, and so on, it invokes the appropriate callback script.
This processing model is very similar to SAX. However, TclXML does not use exactly the same method names, etc, as SAX and so it is not 100% SAX compliant. Functionally, TclXML is equivalent to SAX2.
TclXML v3.X's architecture separates the application interface from the parser implementation, in the same fashion as SAX. Currently there are two parser implementations available: tcl-parser and libxml2.
The TclXML package provides a parser implementation written purely as a Tcl script. When no other parser is available, this one can always be used.
Having a pure-Tcl parser has some advantages, apart from the obvious advantages in not having to compile any code. This parser implementation is more configurable, can provide better error reporting and recovery and can also be modified at run-time to achieve various special features.
The Gnome libxml2 library is a C-based XML parser. It has the advantage of having high performance, as well as being able to (DTD, XSD, RNG) validate documents.
A wrapper for this library is available as part of version 3.2 of the TclXML package.
Download and Installation
TclXML v3.2 is the current release and includes the TclDOM and TclXSLT packages. This version is known to work with Tcl v8.1 and above1. Download from SourceForge:
Pull the Subversion trunk tree to get the latest-and-greatest code. There are no guarantees that the code is in any particular state (or even working at all).
You can never have enough...
Contributions of any kind to the project are welcome.
An important contribution you can make is to test the package and report any bugs. Use SourceForge bug tracking to report problems or request features. Please make sure you set the category to "TclXML".
We are very grateful to Invisible Worlds, who sponsored the TclXML project for most of 2000. Their contribution resulted in the development of XML Namespace support, the xmlswitch command and other features.
There are three mailing lists for the TclXML project:
There are instructions on SourceForge for subscribing or unsubscribing to any of these mailing lists.
Discussion also takes place on the comp.lang.tcl USENET newsgroup.