File: treeql.xml

package info (click to toggle)
tcllib 1.20%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 68,064 kB
  • sloc: tcl: 216,842; ansic: 14,250; sh: 2,846; xml: 1,766; yacc: 1,145; pascal: 881; makefile: 107; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (376 lines) | stat: -rw-r--r-- 10,534 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<?xml version="1.0" ?>
<?xml-stylesheet href="api.css" type="text/css" ?>
<!DOCTYPE api SYSTEM "api.dtd" [
]>
  <api>
  <title>Treeql API</title>
  <header>
    <p>Treeql is a fairly thin query facility over tree-structured data types.  It implements an ordered set of nodes (really a list) which are generated and filtered by application of the treeql query language to each node in turn.</p>
  </header>

  <group>
    <name>TreeQL Object Interface</name>
    <header>
      <p>TreeQL is a Snit type which implements the treeql query language.</p>
      <p>This group of methods provides the tcl interface to the treeql language.</p>
    </header>

    <function>
      <name>TreeQL</name>
      <args>
	<arg>name</arg>
	-tree <arg>tree</arg>
	?-query <arg>query</arg>?
	?-nodes <arg>nodes</arg>?
	<arg>args</arg>
      </args>
      <result>a new query object</result>
      <detail>
	<p><arg>name</arg> names the object to be constructed</p>
	<p>-query specifies a parent query</p>
	<p>-nodes specifies an initial node list</p>
	<p>-tree specifies the underlying tree over which this </p>
	<p><arg>args</arg> are the query operations to be performed</p>
      </detail>
      <detail></detail>
    </function>

    <method>
      <object><arg>query</arg></object>
      <name>query</name>
      <args><arg>args</arg></args>
      <result>perform the new query <arg>args</arg></result>
    </method>
    
    <method>
      <object><arg>query</arg></object>
      <name>result</name>
      <args></args>
      <result>return the node set as a list</result>
    </method>
    
    <method>
      <object><arg>query</arg></object>
      <name>discard</name>
      <args></args>
      <result>returns result, and destroys this query</result>
      <detail>(useful in constructing a sub-query)</detail>
    </method>

  </group>

  <group>
    <name>Structural generators</name>

    <header>These tree-structural operations add nodes to the node set</header>

    <function>
      <name>ancestors</name>
      <args></args>
      <result>all nodes on the path from node to root</result>
    </function>
    
    <function>
      <name>rootpath</name>
      <args></args>
      <result>all nodes on the path from root to node</result>
    </function>
    
    <function>
      <name>parent</name>
      <args></args>
      <result>node parent</result>
    </function>
    
    <function>
      <name>children</name>
      <args></args>
      <result>node children</result>
    </function>
    
    <function>
      <name>left</name>
      <args></args>
      <result>previous sibling</result>
    </function>
    
    <function>
      <name>right</name>
      <args></args>
      <result>next sibling</result>
    </function>
    
    <function>
      <name>prev</name>
      <args></args>
      <result>previous siblings in reverse order</result>
    </function>
    
    <function>
      <name>esib</name>
      <args></args>
      <result>previous siblings in tree order</result>
    </function>
    
    <function>
      <name>next</name>
      <args></args>
      <result>next siblings in tree order</result>
    </function>
    
    <function>
      <name>root</name>
      <args></args>
      <result>the tree root</result>
    </function>
    
    <function>
      <name>tree</name>
      <args></args>
      <result>all nodes in the tree</result>
    </function>
    
    <function>
      <name>descendants</name>
      <args></args>
      <result>all subtrees rooted at node</result>
    </function>
    
    <function>
      <name>forward</name>
      <args></args>
      <result>flattened next subtrees</result>
    </function>
    
    <function>
      <name>backward</name>
      <args></args>
      <result>flattened previous subtrees in reverse tree order</result>
    </function>
    
    <function>
      <name>later</name>
      <args></args>
      <result>flattened next subtrees</result>
      <detail>Synonym for [forward]</detail>
    </function>
    
    <function>
      <name>earlier</name>
      <args></args>
      <result>flattened previous subtrees in tree order</result>
    </function>
    
  </group>

  <group>
    <name>Attribute Filters</name>
    <header>These operations filter the node set by reference to attributes</header>
    <function>
      <name>hasatt</name>
      <args><arg>attr</arg></args>
      <result>Reduce to nodes with attribute <arg>attr</arg> (can be a glob)</result>
    </function>
    
    <function>
      <name>withatt</name>
      <args><arg>attr</arg> <arg>value</arg></args>
      <result>Reduce to nodes with attribute <arg>attr</arg> of <arg>value</arg></result>
    </function>
    
    <function>
      <name>withatt!</name>
      <args><arg>attr</arg> <arg>val</arg></args>
      <result>Reduce to nodes with attribute <arg>attr</arg> of <arg>value</arg></result>
      <detail><arg>attr</arg> must exist in each node of node set</detail>
    </function>
    
    <function>
      <name>attof</name>
      <args><arg>attr</arg> <arg>vals</arg></args>
      <result>Reduce to nodes with attribute <arg>attr</arg> value one of list of <arg>vals</arg></result>
    </function>
    
    <function>
      <name>attmatch</name>
      <args><arg>attr</arg> <arg>match</arg></args>
      <result>Reduce to nodes whose attribute <arg>attr</arg> [string match]es <arg>match</arg></result>
    </function>
    
  </group>

  <group>
    <name>Attribute Mutators</name>
    <header>These operators change node attributes within the underlying tree.</header>
    <function>
      <name>string</name>
      <args><arg>op</arg> <arg>attr</arg></args>
      <result>apply string operation <arg>op</arg> to attribute <arg>attr</arg> on each node</result>
    </function>

    <function>
      <name>set</name>
      <args><arg>attr</arg> <arg>val</arg></args>
      <result>Side Effect: set attribute <arg>attr</arg> to <arg>val</arg></result>
    </function>
    
    <function>
      <name>unset</name>
      <args><arg>attr</arg></args>
      <result>Side Effect: unset attribute <arg>attr</arg></result>
    </function>
  </group>
  
  <group>
    <name>Attribute String Accessors</name>
    <header>
      <p>These operators change node attributes within the underlying tree.</p>
      <p>Their results are stored in the node set, but are not actually nodes.</p>
    </header>

    <function>
      <name>getvals</name>
      <args><arg>pattern</arg></args>
      <result>returns the list of attribute values of attributes matching <arg>pattern</arg></result>
    </function>
    
    <function>
      <name>get</name>
      <args><arg>attr</arg></args>
      <result>returns the list of attribute values of attributes matching <arg>attr</arg></result>
    </function>
    
    <function>
      <name>attlist</name>
      <args></args>
      <result>returns list of attribute values of the current node, in an unspecified order.</result>
    </function>
    
    <function>
      <name>attrs</name>
      <args><arg>glob</arg></args>
      <result>returns list of lists of attributes of each node</result>
    </function>
    
    <function>
      <name>attval</name>
      <args><arg>attname</arg></args>
      <result>returns values of attribute attname</result>
    </function>
    
  </group>

  <group>
    <name>SubQueries</name>
    <header>SubQueries yield node sets which can augment, reduce or replace the current node set</header>
    <function>
      <name>andq</name>
      <args><arg>query</arg></args>
      <result>Replace node set with the set-intersection of the subquery <arg>query</arg></result>
    </function>
    
    <function>
      <name>orq</name>
      <args><arg>query</arg></args>
      <result>Replace node set with the set-union of the subquery <arg>query</arg></result>
    </function>
    
    <function>
      <name>notq</name>
      <args><arg>query</arg></args>
      <result>Replace node set with the set of nodes from subquery <arg>query</arg> which are not in the current node set</result>
    </function>
    
  </group>

  <group>
    <name>Node Set Operations</name>
    <function>
      <name>unique</name>
      <args></args>
      <result>remove duplicate nodes, preserving order</result>
    </function>
    
    <function>
      <name>select</name>
      <args></args>
      <result>select the first node of the node set</result>
    </function>
    
    <function>
      <name>transform</name>
      <args><arg>var</arg> <arg>query</arg> <arg>body</arg></args>
      <result>replace the node set with result of the subquery</result>
    </function>
    
    <function>
      <name>quote</name>
      <args><arg>val</arg></args>
      <result>append the literal <arg>val</arg> to node set</result>
    </function>
    
    <function>
      <name>replace</name>
      <args><arg>val</arg></args>
      <result>replace the node set with the literal</result>
    </function>
    
  </group>

  <group>
    <name>Node Set Iterators</name>
    <function>
      <name>foreach</name>
      <args><arg>var</arg> <arg>query</arg> <arg>body</arg></args>
      <result>perform a subquery <arg>query</arg> then map <arg>body</arg> over results</result>
    </function>
    
    <function>
      <name>with</name>
      <args><arg>query</arg> <arg>body</arg></args>
      <result>perform a query, then evaluate <arg>body</arg></result>
    </function>

    <function>
      <name>over</name>
      <args><arg>var</arg><arg>body</arg></args>
      <result>map <arg>body</arg> over node set</result>
    </function>

    <function>
      <name>delete</name>
      <args></args>
      <result>delete all nodes in node set</result>
    </function>
    
  </group>

  <group>
    <name>Typed node support</name>
    <header>These filters and accessors assume the existence of an attribute called '@type', and are short-hand forms useful for cost-like tree query, html tree editing, and so on.</header>
    <function>
      <name>nodetype</name>
      <args></args>
      <result>returns the node type of nodes</result>
    </function>
    
    <function>
      <name>oftype</name>
      <args><arg>t</arg></args>
      <result>Reduce to nodes of type <arg>t</arg></result>
    </function>
    
    <function>
      <name>nottype</name>
      <args><arg>t</arg></args>
      <result>Reduce to nodes not of type <arg>t</arg></result>
    </function>
    
    <function>
      <name>oftypes</name>
      <args><arg>attrs</arg></args>
      <result> Reduce to nodes whose @type is one of <arg>attrs</arg></result>
    </function>
  </group>

</api>