1STAG-FILTER(1)        User Contributed Perl Documentation       STAG-FILTER(1)
2
3
4

NAME

6       stag-filter - filters a stag file (xml, itext, sxpr) for nodes of
7       interest
8

SYNOPSIS

10         stag-filter person -q name=fred file1.xml
11
12         stag-filter person 'sub {shift->get_name =~ /^A*/}' file1.xml
13
14         stag-filter -p My::Foo -w sxpr record 'sub{..}' file2
15

USAGE

17         stag-filter [-p|parser PARSER] [-w|writer WRITER] NODE -q tag=val FILE
18
19         stag-filter [-p|parser PARSER] [-w|writer WRITER] NODE SUB FILE
20
21         stag-filter [-p|parser PARSER] [-w|writer WRITER]  NODE -f PERLFILE FILE
22

DESCRIPTION

24       parsers an input file using the specified parser (which may be a built
25       in stag parser, such as xml) and filters the resulting stag tree
26       according to a user-supplied subroutine, writing out only the
27       nodes/elements that pass the test.
28
29       the parser is event based, so it should be able to handle large files
30       (although if the node you parse is large, it will take up more memory)
31

ARGUMENTS

33       -p|parser FORMAT
34           FORMAT is one of xml, sxpr or itext, or the name of a perl module
35
36           xml assumed as default
37
38       -w|writer FORMAT
39           FORMAT is one of xml, sxpr or itext, or the name of a perl module
40
41       -c|count
42           prints the number of nodes that pass the test
43
44       -filterfile|f
45           a file containing a perl subroutine (in place of the SUB argument)
46
47       -q|query TAG1=VAL1 -q|query TAG2=VAL2 ...  -q|query TAGN=VALN
48           filters based on the field TAG
49
50           other operators can be used too - eg <, <=, etc
51
52           multiple q arguments can be passed in
53
54           for more complex operations, pass in your own subroutine, see below
55
56       SUB a perl subroutine. this subroutine is evaluated evry time NODE is
57           encountered - the stag object for NODE is passed into the
58           subroutine.
59
60           if the subroutine passes, the node will be passed to the writer for
61           display
62
63       NODE
64           the name of the node/element we are filtering on
65
66       FILE
67           the file to be parser. If no parser option is supplied, this is
68           assumed to a be a stag compatible syntax (xml, sxpr or itext);
69           otherwise you should parse in a parser name or a parser module that
70           throws stag events
71

SEE ALSO

73       Data::Stag
74
75
76
77perl v5.30.1                      2020-01-29                    STAG-FILTER(1)
Impressum