Debian Codegraph @

homepage/script-list.html

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <html>
3 <head>
4 <title>Stag Script Index</title>
5 <link rel="stylesheet" type="text/css" href="./stylesheet.css">
6 </link>
7 </head>
8 <body>
9 <h1>Stag Scripts</h1>
10 <div class="intro">
11 <p>These scripts come with the stag and dbstag distributions</p>
12 </div>
13 <h2>Data::Stag Script List</h2>
14 <hr></hr>
15 <h3>
16 <a href="script-docs/stag-autoschema.html">stag-autoschema.pl</a>
17 </h3>
18 <div class="summary">writes the implicit stag-schema for a stag file</div>
19 <div class="codeblock">
20 <pre>
21 stag-autoschema.pl -w sxpr sample-data.xml</pre>
22 </div>
23 <div class="scriptdesc">
24 <pre>Takes a stag compatible file (xml, sxpr, itext), or a file in any
25 format plus a parser, and writes out the implicit underlying stag-schema
26
27 stag-schema should look relatively self-explanatory.
28
29 Here is an example stag-schema, shown in sxpr syntax:
30 (db
31 (person*
32 (name "s"
33 (address+
34 (address_type "s")
35 (street "s")
36 (street2? "s")
37 (city "s")
38 (zip? "s")))))
39
40 The database db contains zero or more persons, each person has a
41 mandatory name and at least one address.
42
43 The cardinality mnemonics are as follows:</pre>
44 </div>
45 <hr></hr>
46 <h3>
47 <a href="script-docs/stag-db.html">stag-db.pl</a>
48 </h3>
49 <div class="summary">persistent storage and retrieval for stag data (xml, sxpr, itext)</div>
50 <div class="codeblock">
51 <pre>
52 stag-db.pl -r person -k social_security_no -i ./person-idx myrecords.xml
53 stag-db.pl -i ./person-idx -q 999-9999-9999 -q 888-8888-8888</pre>
54 </div>
55 <div class="scriptdesc">
56 <pre>Builds a simple file-based database for persistent storage and
57 retrieval of nodes from a stag compatible document.
58
59 Imagine you have a very large file of data, in a stag compatible
60 format such as XML. You want to index all the elements of type
61 B&lt;person&gt;; each person can be uniquely identified by
62 B&lt;social_security_no&gt;, which is a direct subnode of B&lt;person&gt;
63
64 The first thing to do is to build an index file, which will be stored
65 in your current directory:
66 stag-db.pl -r person -k social_security_no -i ./person-idx myrecords.xml
67
68 You can then use the index "person-idx" to retrieve B&lt;person&gt; nodes by
69 their social security number
70
71 stag-db.pl -i ./person-idx -q 999-9999-9999 &gt; some-person.xml
72
73 You can export using different stag formats
74
75 stag-db.pl -i ./person-idx -q 999-9999-9999 -w sxpr &gt; some-person.xml
76
77 You can retrieve multiple nodes (although these need to be rooted to
78 make a valid file)
79
80 stag-db.pl -i ./person-idx -q 999-9999-9999 -q 888-8888-8888 -top personset
81
82 Or you can use a list of IDs from a file (newline delimited)
83
84 stag-db.pl -i ./person-idx -qf my_ss_nmbrs.txt -top personset</pre>
85 </div>
86 <hr></hr>
87 <h3>
88 <a href="script-docs/stag-diff.html">stag-diff.pl</a>
89 </h3>
90 <div class="summary">finds the difference between two stag files</div>
91 <div class="codeblock">
92 <pre>
93 stag-diff.pl -ignore foo-id -ignore bar-id file1.xml file2.xml</pre>
94 </div>
95 <div class="scriptdesc">
96 <pre>Compares two data trees and reports whether they match. If they do not
97 match, the mismatch is reported.</pre>
98 </div>
99 <hr></hr>
100 <h3>
101 <a href="script-docs/stag-drawtree.html">stag-drawtree.pl</a>
102 </h3>
103 <div class="summary">draws a stag file (xml, itext, sxpr) as a PNG diagram</div>
104 <div class="codeblock">
105 <pre>
106 stag-drawtree.pl -o my.png myfile.xml
107
108 stag-drawtree.pl -p My::MyFormatParser -o my.png myfile.myfmt</pre>
109 </div>
110 <div class="scriptdesc">
111 <pre>requires GD library and GD perl module</pre>
112 </div>
113 <hr></hr>
114 <h3>
115 <a href="script-docs/stag-eval.html">stag-eval.pl</a>
116 </h3>
117 <div class="summary"></div>
118 <div class="codeblock">
119 <pre>
120 stag-eval.pl '' file2.xml</pre>
121 </div>
122 <div class="scriptdesc">
123 <pre></pre>
124 </div>
125 <hr></hr>
126 <h3>
127 <a href="script-docs/stag-filter.html">stag-filter.pl</a>
128 </h3>
129 <div class="summary">filters a stag file (xml, itext, sxpr) for nodes of interest</div>
130 <div class="codeblock">
131 <pre>
132 stag-filter.pl person -q name=fred file1.xml
133
134 stag-filter.pl person 'sub {shift-&gt;get_name =~ /^A*/}' file1.xml
135
136 stag-filter.pl -p My::Foo -w sxpr record 'sub{..}' file2</pre>
137 </div>
138 <div class="scriptdesc">
139 <pre>parsers an input file using the specified parser (which may be a built
140 in stag parser, such as xml) and filters the resulting stag tree
141 according to a user-supplied subroutine, writing out only the
142 nodes/elements that pass the test.
143
144 the parser is event based, so it should be able to handle large files
145 (although if the node you parse is large, it will take up more memory)</pre>
146 </div>
147 <hr></hr>
148 <h3>
149 <a href="script-docs/stag-findsubtree.html">stag-findsubtree.pl</a>
150 </h3>
151 <div class="summary">finds nodes in a stag file</div>
152 <div class="codeblock">
153 <pre>
154 stag-findsubtree.pl 'person/name' file.xml</pre>
155 </div>
156 <div class="scriptdesc">
157 <pre>parses in an input file and writes out subnodes</pre>
158 </div>
159 <hr></hr>
160 <h3>
161 <a href="script-docs/stag-flatten.html">stag-flatten.pl</a>
162 </h3>
163 <div class="summary">turns stag data into a flat table</div>
164 <div class="codeblock">
165 <pre>
166 stag-flatten.pl MyFile.xml dept/name dept/person/name</pre>
167 </div>
168 <div class="scriptdesc">
169 <pre>reads in a file in a stag format, and 'flattens' it to a tab-delimited
170 table format. given this data:
171 (company
172 (dept
173 (name "special-operations")
174 (person
175 (name "james-bond"))
176 (person
177 (name "fred"))))
178
179 the above command will return a two column table
180
181 special-operations james-bond
182 special-operations fred</pre>
183 </div>
184 <hr></hr>
185 <h3>
186 <a href="script-docs/stag-grep.html">stag-grep.pl</a>
187 </h3>
188 <div class="summary">filters a stag file (xml, itext, sxpr) for nodes of interest</div>
189 <div class="codeblock">
190 <pre>
191 stag-grep.pl person -q name=fred file1.xml
192
193 stag-grep.pl person 'sub {shift-&gt;get_name =~ /^A*/}' file1.xml
194
195 stag-grep.pl -p My::Foo -w sxpr record 'sub{..}' file2</pre>
196 </div>
197 <div class="scriptdesc">
198 <pre>parsers an input file using the specified parser (which may be a built
199 in stag parser, such as xml) and filters the resulting stag tree
200 according to a user-supplied subroutine, writing out only the
201 nodes/elements that pass the test.
202
203 the parser is event based, so it should be able to handle large files
204 (although if the node you parse is large, it will take up more memory)</pre>
205 </div>
206 <hr></hr>
207 <h3>
208 <a href="script-docs/stag-handle.html">stag-handle.pl</a>
209 </h3>
210 <div class="summary">streams a stag file through a handler into a writer</div>
211 <div class="codeblock">
212 <pre>
213 stag-handle.pl -w itext -c my-handler.pl myfile.xml &gt; processed.itext
214 stag-handle.pl -w itext -p My::Parser -m My::Handler myfile.xml &gt; processed.itext</pre>
215 </div>
216 <div class="scriptdesc">
217 <pre>will take a Stag compatible format (xml, sxpr or itext), turn the data
218 into an event stream passing it through my-handler.pl</pre>
219 </div>
220 <hr></hr>
221 <h3>
222 <a href="script-docs/stag-join.html">stag-join.pl</a>
223 </h3>
224 <div class="summary">joins two stag files together based around common key</div>
225 <div class="codeblock">
226 <pre>
227 stag-join.pl -w xml country/city_id=capital/capital_id countries.xml capitals.xml
228
229 stag-join.pl -w itext gene/tax_id=species/tax_id genedb.itext speciesdb.itext</pre>
230 </div>
231 <div class="scriptdesc">
232 <pre>Performs a relational-style INNER JOIN between two stag trees; this
233 effectively merges two files together, based on some kind of ID in the
234 file</pre>
235 </div>
236 <hr></hr>
237 <h3>
238 <a href="script-docs/stag-merge.html">stag-merge.pl</a>
239 </h3>
240 <div class="summary"></div>
241 <div class="codeblock">
242 <pre>
243 stag-merge.pl -xml file1.xml file2.xml</pre>
244 </div>
245 <div class="scriptdesc">
246 <pre>script wrapper for the Data::Stag modules</pre>
247 </div>
248 <hr></hr>
249 <h3>
250 <a href="script-docs/stag-mogrify.html">stag-mogrify.pl </a>
251 </h3>
252 <div class="summary">mangle stag files</div>
253 <div class="codeblock">
254 <pre>
255 stag-mogrify.pl -w itext file1.xml file2.xml</pre>
256 </div>
257 <div class="scriptdesc">
258 <pre>script wrapper for the Data::Stag modules
259
260 feeds in files into a parser object that generates nestarray events,
261 and feeds the events into a handler/writer class</pre>
262 </div>
263 <hr></hr>
264 <h3>
265 <a href="script-docs/stag-parse.html">stag-parse.pl</a>
266 </h3>
267 <div class="summary">parses a file and fires events (e.g. sxpr to xml)</div>
268 <div class="codeblock">
269 <pre>
270 # convert XML to IText
271 stag-parse.pl -p xml -w itext file1.xml file2.xml
272
273 # use a custom parser/generator and a custom writer/generator
274 stag-parse.pl -p MyMod::MyParser -w MyMod::MyWriter file.txt</pre>
275 </div>
276 <div class="scriptdesc">
277 <pre>script wrapper for the Data::Stag modules
278
279 feeds in files into a parser object that generates nestarray events,
280 and feeds the events into a handler/writer class</pre>
281 </div>
282 <hr></hr>
283 <h3>
284 <a href="script-docs/stag-query.html">stag-query.pl</a>
285 </h3>
286 <div class="summary">aggregare queries</div>
287 <div class="codeblock">
288 <pre>
289 stag-query.pl avg person/age file.xml
290
291 stag-query.pl sum person/salary file.xml
292
293 stag-query.pl 'sub { $agg .= ", ".shift }' person/name file.xml</pre>
294 </div>
295 <div class="scriptdesc">
296 <pre>Performs aggregate queries</pre>
297 </div>
298 <hr></hr>
299 <h3>
300 <a href="script-docs/stag-splitter.html">stag-splitter.pl</a>
301 </h3>
302 <div class="summary">splits a stag file into multiple files</div>
303 <div class="codeblock">
304 <pre>
305 stag-splitter.pl -split person -name social_security_no file.xml</pre>
306 </div>
307 <div class="scriptdesc">
308 <pre>Splits a file using a user specified parser (default xml) around a
309 specified split node, naming each file according to the name argument
310
311 the files will be named anonymously, unless the '-name' switch is specified; this will use the value of the specified element as the filename
312
313 eg; if we have
314 &lt;top&gt;
315 &lt;a&gt;
316 &lt;b&gt;foo&lt;/b&gt;
317 &lt;c&gt;yah&lt;/c&gt;
318 &lt;d&gt;
319 &lt;e&gt;xxx&lt;/e&gt;
320 &lt;/d&gt;
321 &lt;/a&gt;
322 &lt;a&gt;
323 &lt;b&gt;bar&lt;/b&gt;
324 &lt;d&gt;
325 &lt;e&gt;wibble&lt;/e&gt;
326 &lt;/d&gt;
327 &lt;/a&gt;
328 &lt;/top&gt;
329
330 if we run
331
332 stag-splitter.pl -split a -name b
333
334 it will generate two files, "foo.xml" and "bar.xml"
335
336 input format can be 'xml', 'sxpr' or 'itext' - if this is left blank
337 the format will be guessed from the file suffix
338
339 the output format defaults to the same as the input format, but
340 another can be chosen.
341
342 files go in the current directory, but this can be overridden with the
343 '-dir' switch</pre>
344 </div>
345 <hr></hr>
346 <h3>
347 <a href="script-docs/stag-view.html">stag-view.pl</a>
348 </h3>
349 <div class="summary">draws an expandable Tk tree diagram showing stag data</div>
350 <div class="codeblock">
351 <pre>
352 stag-view.pl file1.xml</pre>
353 </div>
354 <div class="scriptdesc">
355 <pre>Draws a Tk tree, with expandable/convertable nodes</pre>
356 </div>
357 <h2>DBIx::DBStag Script List</h2>
358 <hr></hr>
359 <h3>
360 <a href="script-docs/selectall_html.html">selectall_html.pl</a>
361 </h3>
362 <div class="summary"></div>
363 <div class="codeblock">
364 <pre>
365 selectall_html.pl -d "dbi:Pg:dbname=mydb;host=localhost" "SELECT * FROM a NATURAL JOIN b"</pre>
366 </div>
367 <div class="scriptdesc">
368 <pre></pre>
369 </div>
370 <hr></hr>
371 <h3>
372 <a href="script-docs/selectall_xml.html">selectall_xml.pl</a>
373 </h3>
374 <div class="summary"></div>
375 <div class="codeblock">
376 <pre>
377 selectall_xml.pl [-d &lt;dbi&gt;] [-f file of sql] [-nesting|n &lt;nesting&gt;] SQL</pre>
378 </div>
379 <div class="scriptdesc">
380 <pre>This script will query a database using either SQL provided by the
381 script user, or using an SQL templates; the query results will be
382 turned into XML using the L&lt;DBIx::DBStag&gt; module. The nesting of the
383 XML can be controlled by the DBStag SQL extension "USE NESTING..."</pre>
384 </div>
385 <hr></hr>
386 <h3>
387 <a href="script-docs/stag-autoddl.html">stag-autoddl.pl</a>
388 </h3>
389 <div class="summary"></div>
390 <div class="codeblock">
391 <pre>
392 stag-autoddl.pl -parser XMLAutoddl -handler ITextWriter file1.txt file2.txt
393
394 stag-autoddl.pl -parser MyMod::MyParser -handler MyMod::MyWriter file.txt</pre>
395 </div>
396 <div class="scriptdesc">
397 <pre>script wrapper for the Data::Stag modules</pre>
398 </div>
399 <hr></hr>
400 <h3>
401 <a href="script-docs/stag-bulkload.html">stag-bulkload.pl</a>
402 </h3>
403 <div class="summary">creates bulkload SQL for input data</div>
404 <div class="codeblock">
405 <pre>
406 # convert XML to IText
407 stag-bulkload.pl -l person file1.xml file2.xml
408
409 # use a custom parser/generator and a custom writer/generator
410 stag-bulkload.pl -p MyMod::MyParser file.txt</pre>
411 </div>
412 <div class="scriptdesc">
413 <pre>Creates bulkload SQL statements for an input file
414
415 Works only with certain kinds of schemas, where the FK relations make
416 a tree (not a graph); i.e. the only FKs are to the parent
417
418 You do not need a connection to the DB
419
420 It is of no use for incremental loading - it assumes integer surrogate
421 promary keys and starts these from 1</pre>
422 </div>
423 <hr></hr>
424 <h3>
425 <a href="script-docs/stag-ir.html">stag-ir.pl</a>
426 </h3>
427 <div class="summary">information retrieval using a simple relational index</div>
428 <div class="codeblock">
429 <pre>
430 stag-ir.pl -r person -k social_security_no -d Pg:mydb myrecords.xml
431 stag-ir.pl -d Pg:mydb -q 999-9999-9999 -q 888-8888-8888</pre>
432 </div>
433 <div class="scriptdesc">
434 <pre>Indexes stag nodes (XML Elements) in a simple relational db structure
435 - keyed by ID with an XML Blob as a value
436
437 Imagine you have a very large file of data, in a stag compatible
438 format such as XML. You want to index all the elements of type
439 B&lt;person&gt;; each person can be uniquely identified by
440 B&lt;social_security_no&gt;, which is a direct subnode of B&lt;person&gt;
441
442 The first thing to do is to build the index file, which will be stored
443 in the database mydb
444 stag-ir.pl -r person -k social_security_no -d Pg:mydb myrecords.xml
445
446 You can then use the index "person-idx" to retrieve B&lt;person&gt; nodes by
447 their social security number
448
449 stag-ir.pl -d Pg:mydb -q 999-9999-9999 &gt; some-person.xml
450
451 You can export using different stag formats
452
453 stag-ir.pl -d Pg:mydb -q 999-9999-9999 -w sxpr &gt; some-person.xml
454
455 You can retrieve multiple nodes (although these need to be rooted to
456 make a valid file)
457
458 stag-ir.pl -d Pg:mydb -q 999-9999-9999 -q 888-8888-8888 -top personset
459
460 Or you can use a list of IDs from a file (newline delimited)
461
462 stag-ir.pl -d Pg:mydb -qf my_ss_nmbrs.txt -top personset</pre>
463 </div>
464 <hr></hr>
465 <h3>
466 <a href="script-docs/stag-pgslurp.html">stag-pgslurp.pl</a>
467 </h3>
468 <div class="summary"></div>
469 <div class="codeblock">
470 <pre>
471 stag-pgslurp.pl -d "dbi:Pg:dbname=mydb;host=localhost" myfile.xml</pre>
472 </div>
473 <div class="scriptdesc">
474 <pre>This script is for storing data (specified in a nested file format
475 such as XML or S-Expressions) in a database. It assumes a database
476 schema corresponding to the tags in the input data already exists.</pre>
477 </div>
478 <hr></hr>
479 <h3>
480 <a href="script-docs/stag-sl2sql.html">stag-sl2sql.pl</a>
481 </h3>
482 <div class="summary"></div>
483 <div class="codeblock">
484 <pre></pre>
485 </div>
486 <div class="scriptdesc">
487 <pre></pre>
488 </div>
489 <hr></hr>
490 <h3>
491 <a href="script-docs/stag-storenode.html">stag-storenode.pl</a>
492 </h3>
493 <div class="summary"></div>
494 <div class="codeblock">
495 <pre>
496 stag-storenode.pl -d "dbi:Pg:dbname=mydb;host=localhost" myfile.xml</pre>
497 </div>
498 <div class="scriptdesc">
499 <pre>This script is for storing data (specified in a nested file format
500 such as XML or S-Expressions) in a database. It assumes a database
501 schema corresponding to the tags in the input data already exists.</pre>
502 </div>
503 </body>
504 </html>