http://tcllib.sourceforge.net/doc/treeql.html
----
TreeQL is a [cost]-like [tree] editing and query language.
The fundamental idea is to require of a tree-like object a simple API [http://sharedtech.dyndns.org/~colin/treecl/docs/treeapi.xml] and to use that to generate and filter a list of tree nodes by using methods which map or apply methods and predicates to the nodes in the node set.
The language form is very tcl-ish and quite free-form, which was entirely inspired by [Cost].
I should point out, in passing, that this approach is quite non-standard, and there are other more standard approaches to the problem of searching and editing trees, such as the excellent [tdom].
20041001 [treeql] is now part of [tcllib]. [AKU] ported it to tcl8.4, and helped a lot with QA.
----
[TreeQL adaptor] has some examples using treeql.
I've put TreeQL docs here [http://sharedtech.dyndns.org/~colin/treecl/docs/] and the current version here: [http://sharedtech.dyndns.org/~colin/treecl.tar.gz] - [CMcC] Updated: 20040820
Included with the library are a couple of adaptors, one to give file systems tree-semantics which gives file systems treecl/cost semantics. Beats the hell out of [[[glob]]] :)
Another adaptor is doc, which uses parsehtml and the shallow xml parser to generate trees for scanning.
I have to point out, however, this is very much a work in progress.
----
'''Some Examples''' from the included doc.tcl
Create a doc given a URL:
doc homepage -url http://sharedtech.dyndns.org/
Create a Costq query over the doc tree:
Costq nh -tree homepage
Print only the PCDATA content of the page:
puts "TEXT: [nh query tree content]"
Print the href attributes of all tags:
puts "A: [nh query tree withtag a attval href]"
Another way to do the same:
puts "A2: [nh query tree hasatt href attval href]"
Print the size of the tree:
puts "SIZE: [homepage size]"
----
[[old discussion removed]
20041006 - [Brian Theado] - Nice work on this package. I pulled the depedencies out of the candidate tcllib 1.7 and made it into a sourceable starkit at http://tkoutline.sourceforge.net/treeql.kit.
Here is one unexpected behavior I found:
source treeql.kit
package require treeql
package require struct::tree
package require tcltest
namespace import tcltest::*
set t [struct::tree]; ::treeql q -tree $t
test get.1 {attributes with special characters} {
$t insert root end n1 n2 n3
$t set n1 title hello
$t set n2 title "hello there"
$t set n3 title {[hello]}
q query root children get title
} [list hello {hello there} {[hello]}]
$t destroy; q destroy
Output:
---- Result was:
hello {{{hello there}}} {{{[hello]}}}
---- Result should have been (exact matching):
hello {hello there} {[hello]}
==== get.1 FAILED
----
<>Package | Tcllib