.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Boulder::XML 3pm" .TH Boulder::XML 3pm "2021-01-05" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Boulder::XML \- XML format input/output for Boulder streams .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Boulder::XML; \& \& $stream = Boulder::XML\->newFh; \& \& while ($stone = <$stream>) { \& print $stream $stone; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Boulder::XML generates BoulderIO streams from \s-1XML\s0 files and/or streams. It is also able to output Boulder Stones in \s-1XML\s0 format. Its semantics are similar to those of Boulder::Stream, except that there is never any pass-through behavior. .PP Because \s-1XML\s0 was not designed for streaming, some care must be taken when reading an \s-1XML\s0 document into a series of Stones. Consider this \&\s-1XML\s0 document: .PP .Vb 1 \& \& \& \& Lincoln Stein \& Jean Siao \& September 29, 1999 \& 1999 Lincoln Stein \& \& This is the abstract. It is not anything very fancy, \& but it will do. \& \& \& Fitchberg J \& Journal of Irreproducible Results \& 23 \& 1998 \& \& \& Clemenson V \& Ecumenica \& 10 \& 1968 \& \& \& Ruggles M \& Journal of Aesthetic Surgery \& 10 \& 1999 \& \& .Ve .PP Ordinarily the document will be construed as a single Paper tag containing subtags Author, Date, Copyright, Abstract, and so on. However it might be desirable to fetch out just the citation tags as a series of Stones. In this case, you can declare Citation to be the top level tag by passing the \fB\-tag\fR argument to \fBnew()\fR. Now calling \&\fBget()\fR will return each of the three Citation sections in turn. If no tag is explicitly declared to be the top level tag, then Boulder::XML will take the first tag it sees in the document. .PP It is possible to stream \s-1XML\s0 files. You can either separate them into separate documents and use the automatic \s-1ARGV\s0 processing features of the BoulderIO library, or separate the \s-1XML\s0 documents using a \&\fBdelimiter\fR string similar to the delimiters used in \s-1MIME\s0 multipart documents. By default, BoulderIO uses a delimiter of . .PP \&\fBThis is not a general \s-1XML\s0 parsing engine!\fR Instead, it is a way to represent BoulderIO tag/value streams in \s-1XML\s0 format. The module uses XML::Parser to parse the \s-1XML\s0 streams, and therefore any syntactic error in the stream can cause the \s-1XML\s0 parser to quit with an error. Another thing to be aware of is that there are certain \s-1XML\s0 constructions that will not translate into BoulderIO format, specifically free text that contains embedded tags. This is \s-1OK:\s0 .PP .Vb 1 \& Jean Siao .Ve .PP but this is not: .PP .Vb 1 \& The extremely illustrious Jean Siao .Ve .PP In BoulderIO format, tags can contain other tags or text, but cannot contain a mixture of tags and text. .SS "\s-1CONSTRUCTORS\s0" .IX Subsection "CONSTRUCTORS" .ie n .IP "$stream = Boulder::XML\->new(*IN,*OUT);" 4 .el .IP "\f(CW$stream\fR = Boulder::XML\->new(*IN,*OUT);" 4 .IX Item "$stream = Boulder::XML->new(*IN,*OUT);" .PD 0 .ie n .IP "$stream = Boulder::XML\->new(\-in=>*IN, \-out=>*OUT, \-tag=>$tag, \-delim=>$delim, \-strip=>$strip)" 4 .el .IP "\f(CW$stream\fR = Boulder::XML\->new(\-in=>*IN, \-out=>*OUT, \-tag=>$tag, \-delim=>$delim, \-strip=>$strip)" 4 .IX Item "$stream = Boulder::XML->new(-in=>*IN, -out=>*OUT, -tag=>$tag, -delim=>$delim, -strip=>$strip)" .PD \&\fBnew()\fR creates a new Boulder::XML stream that can be read from or written to. All arguments are optional. .Sp .Vb 3 \& \-in Filehandle to read from. \& If a file name is provided, will open the file. \& Defaults to the magic <> filehandle. \& \& \-out Filehandle to write to. \& If a file name is provided, will open the file for writing. \& Defaults to STDOUT \& \& \-tag The top\-level XML tag to consider as the Stone record. Defaults \& to the first tag seen when reading from an XML file, or to \& EStoneE when writing to an output stream without \& previously having read. \& \& \-delim Delimiter to use for delimiting multiple Stone objects in an \& XML stream. \& \& \-strip If true, automatically strips leading and trailing whitespace \& from text contained within tags. .Ve .ie n .IP "$fh = Boulder::XML\->newFh(*IN,*OUT);" 4 .el .IP "\f(CW$fh\fR = Boulder::XML\->newFh(*IN,*OUT);" 4 .IX Item "$fh = Boulder::XML->newFh(*IN,*OUT);" .PD 0 .ie n .IP "$fh = Boulder::XML\->newFh(\-in=>*IN, \-out=>*OUT, \-tag=>$tag, \-delim=>$delim, \-strip=>$strip)" 4 .el .IP "\f(CW$fh\fR = Boulder::XML\->newFh(\-in=>*IN, \-out=>*OUT, \-tag=>$tag, \-delim=>$delim, \-strip=>$strip)" 4 .IX Item "$fh = Boulder::XML->newFh(-in=>*IN, -out=>*OUT, -tag=>$tag, -delim=>$delim, -strip=>$strip)" .PD The \fBnewFh()\fR constructor creates a tied filehandle that can read and write Boulder::XML streams. Invoking <> on the filehandle will perform a \fBget()\fR, returning a Stone object. Calling \fBprint()\fR on the filehandle will perform a \fBput()\fR, writing a Stone object to output in \&\s-1XML\s0 format. .SS "\s-1METHODS\s0" .IX Subsection "METHODS" .ie n .IP "$stone = $stream\->\fBget()\fR" 4 .el .IP "\f(CW$stone\fR = \f(CW$stream\fR\->\fBget()\fR" 4 .IX Item "$stone = $stream->get()" .PD 0 .ie n .IP "$stream\->put($stone)" 4 .el .IP "\f(CW$stream\fR\->put($stone)" 4 .IX Item "$stream->put($stone)" .ie n .IP "$done = $stream\->done" 4 .el .IP "\f(CW$done\fR = \f(CW$stream\fR\->done" 4 .IX Item "$done = $stream->done" .PD All these methods have the same semantics as the similar methods in Boulder::Stream, except that pass-through behavior doesn't apply. .SH "AUTHOR" .IX Header "AUTHOR" Lincoln D. Stein , Cold Spring Harbor Laboratory, Cold Spring Harbor, \s-1NY.\s0 This module can be used and distributed on the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" Boulder, Boulder::Stream, Stone