Using XML in Tcl

I used to do quite a bit of Tcl programming back in the mid to late 1990s. I've since largely dropped it, but Tcl still is used quite a bit in specialized use cases.

To use Tcl with XML, it seems like the most popular solution is the TclXML package :
http://tclxml.sourceforge.net

From what I can tell, it's the best / only package for XML in Tcl, although here's a 11-year old article by Steve Ball which seems to reference other approaches :
http://www.usenix.org/events/tcl98/tcl98/full_papers/ball/ball.pdf

Here's one reference which alludes to concerns about generating XML and a few solutions :
http://wiki.tcl.tk/1740

Steve Ball succinctly advised, "When creating XML, I generally use TclDOM. Create a DOM tree in memory, and then use 'dom::DOMImplementation serialize $doc' to generate the XML. The TclDOM package will make sure that the generated XML is well-formed.

It looks like Steve Ball is the author of TclXML, TclDOM and TclXSLT, so his home-cooked solution is expected.

I ran across another code fragment from the same Steve Ball here (http://www.ra.ethz.ch/CDstore/www7/1869/com1869.htm) which I like because it apparently works off a DTD so it provides a higher level of document validity.

xml::generate [xml::parseDTD $dtd] set xmlDocument [MEMO priority Important { TO {xml::text "All WWW7 Attendees"} FROM {xml::text "Steve Ball"} MESSAGE {xml::text "XML is terrific!"} }]

Finally, I also ran across this paper from, again, Steve Ball. It's at least written in this millennium :

http://aspn.activestate.com/ASPN/Tcl/TclConferencePapers2002/Tcl2002pape...

Categories: