1Boulder::XML(3)       User Contributed Perl Documentation      Boulder::XML(3)
2
3
4

NAME

6       Boulder::XML - XML format input/output for Boulder streams
7

SYNOPSIS

9          use Boulder::XML;
10
11          $stream = Boulder::XML->newFh;
12
13          while ($stone = <$stream>) {
14               print $stream $stone;
15          }
16

DESCRIPTION

18       Boulder::XML generates BoulderIO streams from XML files and/or streams.
19       It is also able to output Boulder Stones in XML format.  Its semantics
20       are similar to those of Boulder::Stream, except that there is never any
21       pass-through behavior.
22
23       Because XML was not designed for streaming, some care must be taken
24       when reading an XML document into a series of Stones.  Consider this
25       XML document:
26
27        <?xml version="1.0" standalone="yes"?>
28
29        <Paper>
30          <Author>Lincoln Stein</Author>
31          <Author>Jean Siao</Author>
32          <Date>September 29, 1999</Date>
33          <Copyright copyrighted="yes">1999 Lincoln Stein</Copright>
34          <Abstract>
35              This is the abstract.  It is not anything very fancy,
36              but it will do.
37          </Abstract>
38          <Citation>
39               <Author>Fitchberg J</Author>
40               <Journal>Journal of Irreproducible Results</Journal>
41               <Volume>23</Volume>
42               <Year>1998</Volume>
43          </Citation>
44          <Citation>
45               <Author>Clemenson V</Author>
46               <Journal>Ecumenica</Journal>
47               <Volume>10</Volume>
48               <Year>1968</Volume>
49          </Citation>
50          <Citation>
51               <Author>Ruggles M</Author>
52               <Journal>Journal of Aesthetic Surgery</Journal>
53               <Volume>10</Volume>
54               <Year>1999</Volume>
55          </Citation>
56        </Paper>
57
58       Ordinarily the document will be construed as a single Paper tag con‐
59       taining subtags Author, Date, Copyright, Abstract, and so on.  However
60       it might be desirable to fetch out just the citation tags as a series
61       of Stones.  In this case, you can declare Citation to be the top level
62       tag by passing the -tag argument to new(). Now calling get() will
63       return each of the three Citation sections in turn.  If no tag is
64       explicitly declared to be the top level tag, then Boulder::XML will
65       take the first tag it sees in the document.
66
67       It is possible to stream XML files.  You can either separate them into
68       separate documents and use the automatic ARGV processing features of
69       the BoulderIO library, or separate the XML documents using a delimiter
70       string similar to the delimiters used in MIME multipart documents.  By
71       default, BoulderIO uses a delimiter of <!--Boulder::XML-->.
72
73       This is not a general XML parsing engine! Instead, it is a way to rep‐
74       resent BoulderIO tag/value streams in XML format.  The module uses
75       XML::Parser to parse the XML streams, and therefore any syntactic error
76       in the stream can cause the XML parser to quit with an error.  Another
77       thing to be aware of is that there are certain XML constructions that
78       will not translate into BoulderIO format, specifically free text that
79       contains embedded tags.  This is OK:
80
81         <Author>Jean Siao</Author>
82
83       but this is not:
84
85         <Author>The <Emphatic>extremely illustrious</Emphatic> Jean Siao</Author>
86
87       In BoulderIO format, tags can contain other tags or text, but cannot
88       contain a mixture of tags and text.
89
90       CONSTRUCTORS
91
92       $stream = Boulder::XML->new(*IN,*OUT);
93       $stream = Boul‐
94       der::XML->new(-in=>*IN,-out=>*OUT,-tag=>$tag,-delim=>$delim,-strip=>$strip)
95           new() creates a new Boulder::XML stream that can be read from or
96           written to.  All arguments are optional.
97
98            -in    Filehandle to read from.
99                   If a file name is provided, will open the file.
100                   Defaults to the magic <> filehandle.
101
102            -out   Filehandle to write to.
103                   If a file name is provided, will open the file for writing.
104                   Defaults to STDOUT
105
106            -tag   The top-level XML tag to consider as the Stone record.  Defaults
107                   to the first tag seen when reading from an XML file, or to
108                   E<lt>StoneE<gt> when writing to an output stream without
109                   previously having read.
110
111            -delim Delimiter to use for delimiting multiple Stone objects in an
112                   XML stream.
113
114            -strip If true, automatically strips leading and trailing whitespace
115                   from text contained within tags.
116
117       $fh = Boulder::XML->newFh(*IN,*OUT);
118       $fh = Boul‐
119       der::XML->newFh(-in=>*IN,-out=>*OUT,-tag=>$tag,-delim=>$delim,-strip=>$strip)
120           The newFh() constructor creates a tied filehandle that can read and
121           write Boulder::XML streams.  Invoking <> on the filehandle will
122           perform a get(), returning a Stone object.  Calling print() on the
123           filehandle will perform a put(), writing a Stone object to output
124           in XML format.
125
126       METHODS
127
128       $stone = $stream->get()
129       $stream->put($stone)
130       $done = $stream->done
131           All these methods have the same semantics as the similar methods in
132           Boulder::Stream, except that pass-through behavior doesn't apply.
133

AUTHOR

135       Lincoln D. Stein <lstein@cshl.org>, Cold Spring Harbor Laboratory, Cold
136       Spring Harbor, NY.  This module can be used and distributed on the same
137       terms as Perl itself.
138

SEE ALSO

140       Boulder, Boulder::Stream, Stone
141
142
143
144perl v5.8.8                       2000-06-08                   Boulder::XML(3)
Impressum