From: Andreas K. <and...@ac...> - 2010-06-17 18:55:27
|
Lars Hellström wrote: > Lately, a lot of the projects I've been working on have involved (i) > generating Tcl data structures that could be viewed as a particular > encoding of part of an XML document and (ii) converting said data > structures to XML on output. > > While (i) is always rather specific, the (ii) part tends to be very > generic, and while it's code-wise very short, it kind of worries me > that I'm copying the same procedures from project to project, so I've > been thinking "maybe this should go into tcllib?" As a matter of fact, > I've been somewhat surprised to not already find something along these > lines in there, but maybe it's too elementary to make a package for... > The intent is not to provide industrial capacity XML handling (there > are well-known compiled extensions for that), but rather to provide a > cheap package that you can put into your script when you just want to > add XML as another output format. > > The latest version of my command is TDLtoXML::xml_from_trees (but never > mind the namespace) on http://wiki.tcl.tk/25681#pagetocbc2b8a8c. This > coverts from a tdom list format to XML (cf. http://wiki.tcl.tk/26156), > and that is perhaps something that should be scrutinised, since putting > something like this in tcllib is an act of blessing its data format. "The trick is to parse TDL data by evaluating it in an empty slave interpreter." Are you limited to Tcl 8.4 ? If not, i.e. 8.5 is viable, then usage of a namespace and 'namespace unknown' may allow us to forego the empty slave. What I am missing is some explanation on how you envision the dnyamic creation of TDL structures. Plain [list] commands ? Right now I only see static structures on the page, and their conversion to other formats (data tress, pretty printing, ...) Having read this I now also see that the _xml.tcl I mentioned in my first mail is more of a low level generator which would be driven by such data structures. Assembler in essence, versus your HLL. The xmlgen/htmlgen refeenced on your pages are much more comparable to the _xml.tcl -- Andreas Kupries Senior Tcl Developer ActiveState, The Dynamic Language Experts P: 778.786.1122 F: 778.786.1133 and...@ac... http://www.activestate.com Get insights on Open Source and Dynamic Languages at www.activestate.com/blog |