[[ [CL] means by this "display formatting".]]
[[Explain what's available in [TclDOM] and [tdom].]]
For TclDOM, just use the -indent option. For example,
dom::serialize $dom -indent yes
The man page [http://tclxml.sf.net/tcldom/2.3/tcldom-man.html] explains
the use of -indent and -indentspec.
[[Explain pretty_print package--application, why not at SF, plans, ...]]
[[License, too.]]
[[Last one CL packaged was
http://www.phaseit.net/claird/comp.lang.tcl/dom_pretty_print/dom_pretty_print-0.2.tar.Z ]]
----
[RS] can't resist to contribute a quite pretty one-liner proc:
package require tdom
proc xmlpretty xml {[[dom parse $xml] documentElement] asXML}
% xmlpretty "grill"
grill
Nicely functional (indenting is default in the ''asXML'' method), it's just that it leaks memory: the document object is never freed. So here is a cleaner, but not so compact version:
proc xmlpretty xml {
dom parse $xml mydom
set res [[$mydom documentElement] asXML]
$mydom delete
set res
} ;# RS
2004-03-13: Revisiting this page, I see that this is of course yet another use case for the [K] combinator:
proc xmlpretty xml {
dom parse $xml mydom
K [[$mydom documentElement] asXML] [$mydom delete]
}
proc K {a b} {set a}
[NEM] notes that this can return to a one liner:
proc xmlpretty xml { [[dom parse $xml doc] documentElement] asXML }
This takes advantage of the simple garbage-collection scheme built in to tDOM. When you use the syntax:
dom parse $xml varName
tdom puts a trace on the varName, so that when it goes out of scope, the associated dom tree is deleted.
----
Also see [XML] and
http://software.decisionsoft.com/software/xmlpp.pl
----
[[
[Category Application] |
[Category XML] |
]]