Debian Codegraph @

homepage/script-docs/stag-grep.html

raw
1 <HTML>
2 <HEAD>
3 <TITLE>stag-grep</TITLE>
4 <LINK REV="made" HREF="mailto:[email protected]">
5 </HEAD>
6
7 <BODY>
8
9 <A NAME="__index__"></A>
10 <!-- INDEX BEGIN -->
11
12 <UL>
13
14 <LI><A HREF="#name">NAME</A></LI>
15 <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
16 <LI><A HREF="#usage">USAGE</A></LI>
17 <LI><A HREF="#description">DESCRIPTION</A></LI>
18 <LI><A HREF="#arguments">ARGUMENTS</A></LI>
19 <LI><A HREF="#see also">SEE ALSO</A></LI>
20 </UL>
21 <!-- INDEX END -->
22
23 <HR>
24 <P>
25 <H1><A NAME="name">NAME</A></H1>
26 <P>stag-grep.pl - filters a stag file (xml, itext, sxpr) for nodes of interest</P>
27 <P>
28 <HR>
29 <H1><A NAME="synopsis">SYNOPSIS</A></H1>
30 <PRE>
31 stag-grep.pl person -q name=fred file1.xml</PRE>
32 <PRE>
33 stag-grep.pl person 'sub {shift-&gt;get_name =~ /^A*/}' file1.xml</PRE>
34 <PRE>
35 stag-grep.pl -p My::Foo -w sxpr record 'sub{..}' file2</PRE>
36 <P>
37 <HR>
38 <H1><A NAME="usage">USAGE</A></H1>
39 <PRE>
40 stag-grep.pl [-p|parser PARSER] [-w|writer WRITER] NODE -q tag=val FILE</PRE>
41 <PRE>
42 stag-grep.pl [-p|parser PARSER] [-w|writer WRITER] NODE SUB FILE</PRE>
43 <PRE>
44 stag-grep.pl [-p|parser PARSER] [-w|writer WRITER] NODE -f PERLFILE FILE</PRE>
45 <P>
46 <HR>
47 <H1><A NAME="description">DESCRIPTION</A></H1>
48 <P>parsers an input file using the specified parser (which may be a built
49 in stag parser, such as xml) and filters the resulting stag tree
50 according to a user-supplied subroutine, writing out only the
51 nodes/elements that pass the test.</P>
52 <P>the parser is event based, so it should be able to handle large files
53 (although if the node you parse is large, it will take up more memory)</P>
54 <P>
55 <HR>
56 <H1><A NAME="arguments">ARGUMENTS</A></H1>
57 <DL>
58 <DT><STRONG><A NAME="item_%2Dp%7Cparser_FORMAT">-p|parser FORMAT</A></STRONG><BR>
59 <DD>
60 FORMAT is one of xml, sxpr or itext, or the name of a perl module
61 <P>xml assumed as default</P>
62 <P></P>
63 <DT><STRONG><A NAME="item_%2Dw%7Cwriter_FORMAT">-w|writer FORMAT</A></STRONG><BR>
64 <DD>
65 FORMAT is one of xml, sxpr or itext, or the name of a perl module
66 <P></P>
67 <DT><STRONG><A NAME="item_%2Dc%7Ccount">-c|count</A></STRONG><BR>
68 <DD>
69 prints the number of nodes that pass the test
70 <P></P>
71 <DT><STRONG><A NAME="item_%2Dfilterfile%7Cf">-filterfile|f</A></STRONG><BR>
72 <DD>
73 a file containing a perl subroutine (in place of the SUB argument)
74 <P></P>
75 <DT><STRONG><A NAME="item_%2Dq%7Cquery_TAG1%3DVAL1_%2Dq%7Cquery_TAG2%3DVAL2_">-q|query TAG1=VAL1 -q|query TAG2=VAL2 ... -q|query TAGN=VALN</A></STRONG><BR>
76 <DD>
77 filters based on the field TAG
78 <P>other operators can be used too - eg &lt;, &lt;=, etc</P>
79 <P>multiple q arguments can be passed in</P>
80 <P>for more complex operations, pass in your own subroutine, see below</P>
81 <P></P>
82 <DT><STRONG><A NAME="item_SUB">SUB</A></STRONG><BR>
83 <DD>
84 a perl subroutine. this subroutine is evaluated evry time NODE is
85 encountered - the stag object for NODE is passed into the subroutine.
86 <P>if the subroutine passes, the node will be passed to the writer for
87 display</P>
88 <P></P>
89 <DT><STRONG><A NAME="item_NODE">NODE</A></STRONG><BR>
90 <DD>
91 the name of the node/element we are filtering on
92 <P></P>
93 <DT><STRONG><A NAME="item_FILE">FILE</A></STRONG><BR>
94 <DD>
95 the file to be parser. If no parser option is supplied, this is
96 assumed to a be a stag compatible syntax (xml, sxpr or itext);
97 otherwise you should parse in a parser name or a parser module that
98 throws stag events
99 <P></P></DL>
100 <P>
101 <HR>
102 <H1><A NAME="see also">SEE ALSO</A></H1>
103 <P><A HREF="./Data/Stag.html">the Data::Stag manpage</A></P>
104
105 </BODY>
106
107 </HTML>