Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / XML::Parser.3pm
1 .\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.10)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 'br\}
42 .\"
43 .\" Escape single quotes in literal strings from groff's Unicode transform.
44 .ie \n(.g .ds Aq \(aq
45 .el       .ds Aq '
46 .\"
47 .\" If the F register is turned on, we'll generate index entries on stderr for
48 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
49 .\" entries marked with X<> in POD.  Of course, you'll have to process the
50 .\" output yourself in some meaningful fashion.
51 .ie \nF \{\
52 .    de IX
53 .    tm Index:\\$1\t\\n%\t"\\$2"
54 ..
55 .    nr % 0
56 .    rr F
57 .\}
58 .el \{\
59 .    de IX
60 ..
61 .\}
62 .\"
63 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
64 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
65 .    \" fudge factors for nroff and troff
66 .if n \{\
67 .    ds #H 0
68 .    ds #V .8m
69 .    ds #F .3m
70 .    ds #[ \f1
71 .    ds #] \fP
72 .\}
73 .if t \{\
74 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
75 .    ds #V .6m
76 .    ds #F 0
77 .    ds #[ \&
78 .    ds #] \&
79 .\}
80 .    \" simple accents for nroff and troff
81 .if n \{\
82 .    ds ' \&
83 .    ds ` \&
84 .    ds ^ \&
85 .    ds , \&
86 .    ds ~ ~
87 .    ds /
88 .\}
89 .if t \{\
90 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
91 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
92 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
93 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
94 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
95 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
96 .\}
97 .    \" troff and (daisy-wheel) nroff accents
98 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
99 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
100 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
101 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
102 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
103 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
104 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
105 .ds ae a\h'-(\w'a'u*4/10)'e
106 .ds Ae A\h'-(\w'A'u*4/10)'E
107 .    \" corrections for vroff
108 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
109 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
110 .    \" for low resolution devices (crt and lpr)
111 .if \n(.H>23 .if \n(.V>19 \
112 \{\
113 .    ds : e
114 .    ds 8 ss
115 .    ds o a
116 .    ds d- d\h'-1'\(ga
117 .    ds D- D\h'-1'\(hy
118 .    ds th \o'bp'
119 .    ds Th \o'LP'
120 .    ds ae ae
121 .    ds Ae AE
122 .\}
123 .rm #[ #] #H #V #F C
124 .\" ========================================================================
125 .\"
126 .IX Title "Parser 3"
127 .TH Parser 3 "2007-11-20" "perl v5.8.7" "User Contributed Perl Documentation"
128 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
129 .\" way too many mistakes in technical documents.
130 .if n .ad l
131 .nh
132 .SH "NAME"
133 XML::Parser \- A perl module for parsing XML documents
134 .SH "SYNOPSIS"
135 .IX Header "SYNOPSIS"
136 .Vb 1
137 \&  use XML::Parser;
138 \&  
139 \&  $p1 = new XML::Parser(Style => \*(AqDebug\*(Aq);
140 \&  $p1\->parsefile(\*(AqREC\-xml\-19980210.xml\*(Aq);
141 \&  $p1\->parse(\*(Aq<foo id="me">Hello World</foo>\*(Aq);
142 \&
143 \&  # Alternative
144 \&  $p2 = new XML::Parser(Handlers => {Start => \e&handle_start,
145 \&                                     End   => \e&handle_end,
146 \&                                     Char  => \e&handle_char});
147 \&  $p2\->parse($socket);
148 \&
149 \&  # Another alternative
150 \&  $p3 = new XML::Parser(ErrorContext => 2);
151 \&
152 \&  $p3\->setHandlers(Char    => \e&text,
153 \&                   Default => \e&other);
154 \&
155 \&  open(FOO, \*(Aqxmlgenerator |\*(Aq);
156 \&  $p3\->parse(*FOO, ProtocolEncoding => \*(AqISO\-8859\-1\*(Aq);
157 \&  close(FOO);
158 \&
159 \&  $p3\->parsefile(\*(Aqjunk.xml\*(Aq, ErrorContext => 3);
160 .Ve
161 .SH "DESCRIPTION"
162 .IX Header "DESCRIPTION"
163 This module provides ways to parse \s-1XML\s0 documents. It is built on top of
164 XML::Parser::Expat, which is a lower level interface to James Clark's
165 expat library. Each call to one of the parsing methods creates a new
166 instance of XML::Parser::Expat which is then used to parse the document.
167 Expat options may be provided when the XML::Parser object is created.
168 These options are then passed on to the Expat object on each parse call.
169 They can also be given as extra arguments to the parse methods, in which
170 case they override options given at XML::Parser creation time.
171 .PP
172 The behavior of the parser is controlled either by \f(CW"Style"\fR and/or
173 \&\f(CW"Handlers"\fR options, or by \*(L"setHandlers\*(R" method. These all provide
174 mechanisms for XML::Parser to set the handlers needed by XML::Parser::Expat.
175 If neither \f(CW\*(C`Style\*(C'\fR nor \f(CW\*(C`Handlers\*(C'\fR are specified, then parsing just
176 checks the document for being well-formed.
177 .PP
178 When underlying handlers get called, they receive as their first parameter
179 the \fIExpat\fR object, not the Parser object.
180 .SH "METHODS"
181 .IX Header "METHODS"
182 .IP "new" 4
183 .IX Item "new"
184 This is a class method, the constructor for XML::Parser. Options are passed
185 as keyword value pairs. Recognized options are:
186 .RS 4
187 .IP "\(bu" 4
188 Style
189 .Sp
190 This option provides an easy way to create a given style of parser. The
191 built in styles are: \*(L"Debug\*(R", \*(L"Subs\*(R", \*(L"Tree\*(R", \*(L"Objects\*(R",
192 and \*(L"Stream\*(R". These are all defined in separate packages under
193 \&\f(CW\*(C`XML::Parser::Style::*\*(C'\fR, and you can find further documentation for
194 each style both below, and in those packages.
195 .Sp
196 Custom styles can be provided by giving a full package name containing
197 at least one '::'. This package should then have subs defined for each
198 handler it wishes to have installed. See \*(L"\s-1STYLES\s0\*(R" below
199 for a discussion of each built in style.
200 .IP "\(bu" 4
201 Handlers
202 .Sp
203 When provided, this option should be an anonymous hash containing as
204 keys the type of handler and as values a sub reference to handle that
205 type of event. All the handlers get passed as their 1st parameter the
206 instance of expat that is parsing the document. Further details on
207 handlers can be found in \*(L"\s-1HANDLERS\s0\*(R". Any handler set here
208 overrides the corresponding handler set with the Style option.
209 .IP "\(bu" 4
210 Pkg
211 .Sp
212 Some styles will refer to subs defined in this package. If not provided,
213 it defaults to the package which called the constructor.
214 .IP "\(bu" 4
215 ErrorContext
216 .Sp
217 This is an Expat option. When this option is defined, errors are reported
218 in context. The value should be the number of lines to show on either side
219 of the line in which the error occurred.
220 .IP "\(bu" 4
221 ProtocolEncoding
222 .Sp
223 This is an Expat option. This sets the protocol encoding name. It defaults
224 to none. The built-in encodings are: \f(CW\*(C`UTF\-8\*(C'\fR, \f(CW\*(C`ISO\-8859\-1\*(C'\fR, \f(CW\*(C`UTF\-16\*(C'\fR, and
225 \&\f(CW\*(C`US\-ASCII\*(C'\fR. Other encodings may be used if they have encoding maps in one
226 of the directories in the \f(CW@Encoding_Path\fR list. Check \*(L"\s-1ENCODINGS\s0\*(R" for
227 more information on encoding maps. Setting the protocol encoding overrides
228 any encoding in the \s-1XML\s0 declaration.
229 .IP "\(bu" 4
230 Namespaces
231 .Sp
232 This is an Expat option. If this is set to a true value, then namespace
233 processing is done during the parse. See \*(L"Namespaces\*(R" in XML::Parser::Expat
234 for further discussion of namespace processing.
235 .IP "\(bu" 4
236 NoExpand
237 .Sp
238 This is an Expat option. Normally, the parser will try to expand references
239 to entities defined in the internal subset. If this option is set to a true
240 value, and a default handler is also set, then the default handler will be
241 called when an entity reference is seen in text. This has no effect if a
242 default handler has not been registered, and it has no effect on the expansion
243 of entity references inside attribute values.
244 .IP "\(bu" 4
245 Stream_Delimiter
246 .Sp
247 This is an Expat option. It takes a string value. When this string is found
248 alone on a line while parsing from a stream, then the parse is ended as if it
249 saw an end of file. The intended use is with a stream of xml documents in a
250 \&\s-1MIME\s0 multipart format. The string should not contain a trailing newline.
251 .IP "\(bu" 4
252 ParseParamEnt
253 .Sp
254 This is an Expat option. Unless standalone is set to \*(L"yes\*(R" in the \s-1XML\s0
255 declaration, setting this to a true value allows the external \s-1DTD\s0 to be read,
256 and parameter entities to be parsed and expanded.
257 .IP "\(bu" 4
258 NoLWP
259 .Sp
260 This option has no effect if the ExternEnt or ExternEntFin handlers are
261 directly set. Otherwise, if true, it forces the use of a file based external
262 entity handler.
263 .IP "\(bu" 4
264 Non-Expat-Options
265 .Sp
266 If provided, this should be an anonymous hash whose keys are options that
267 shouldn't be passed to Expat. This should only be of concern to those
268 subclassing XML::Parser.
269 .RE
270 .RS 4
271 .RE
272 .IP "setHandlers(\s-1TYPE\s0, \s-1HANDLER\s0 [, \s-1TYPE\s0, \s-1HANDLER\s0 [...]])" 4
273 .IX Item "setHandlers(TYPE, HANDLER [, TYPE, HANDLER [...]])"
274 This method registers handlers for various parser events. It overrides any
275 previous handlers registered through the Style or Handler options or through
276 earlier calls to setHandlers. By providing a false or undefined value as
277 the handler, the existing handler can be unset.
278 .Sp
279 This method returns a list of type, handler pairs corresponding to the
280 input. The handlers returned are the ones that were in effect prior to
281 the call.
282 .Sp
283 See a description of the handler types in \*(L"\s-1HANDLERS\s0\*(R".
284 .IP "parse(\s-1SOURCE\s0 [, \s-1OPT\s0 => \s-1OPT_VALUE\s0 [...]])" 4
285 .IX Item "parse(SOURCE [, OPT => OPT_VALUE [...]])"
286 The \s-1SOURCE\s0 parameter should either be a string containing the whole \s-1XML\s0
287 document, or it should be an open IO::Handle. Constructor options to
288 XML::Parser::Expat given as keyword-value pairs may follow the \s-1SOURCE\s0
289 parameter. These override, for this call, any options or attributes passed
290 through from the XML::Parser instance.
291 .Sp
292 A die call is thrown if a parse error occurs. Otherwise it will return 1
293 or whatever is returned from the \fBFinal\fR handler, if one is installed.
294 In other words, what parse may return depends on the style.
295 .IP "parsestring" 4
296 .IX Item "parsestring"
297 This is just an alias for parse for backwards compatibility.
298 .IP "parsefile(\s-1FILE\s0 [, \s-1OPT\s0 => \s-1OPT_VALUE\s0 [...]])" 4
299 .IX Item "parsefile(FILE [, OPT => OPT_VALUE [...]])"
300 Open \s-1FILE\s0 for reading, then call parse with the open handle. The file
301 is closed no matter how parse returns. Returns what parse returns.
302 .IP "parse_start([ \s-1OPT\s0 => \s-1OPT_VALUE\s0 [...]])" 4
303 .IX Item "parse_start([ OPT => OPT_VALUE [...]])"
304 Create and return a new instance of XML::Parser::ExpatNB. Constructor
305 options may be provided. If an init handler has been provided, it is
306 called before returning the ExpatNB object. Documents are parsed by
307 making incremental calls to the parse_more method of this object, which
308 takes a string. A single call to the parse_done method of this object,
309 which takes no arguments, indicates that the document is finished.
310 .Sp
311 If there is a final handler installed, it is executed by the parse_done
312 method before returning and the parse_done method returns whatever is
313 returned by the final handler.
314 .SH "HANDLERS"
315 .IX Header "HANDLERS"
316 Expat is an event based parser. As the parser recognizes parts of the
317 document (say the start or end tag for an \s-1XML\s0 element), then any handlers
318 registered for that type of an event are called with suitable parameters.
319 All handlers receive an instance of XML::Parser::Expat as their first
320 argument. See \*(L"\s-1METHODS\s0\*(R" in XML::Parser::Expat for a discussion of the
321 methods that can be called on this object.
322 .SS "Init                (Expat)"
323 .IX Subsection "Init                (Expat)"
324 This is called just before the parsing of the document starts.
325 .SS "Final                (Expat)"
326 .IX Subsection "Final                (Expat)"
327 This is called just after parsing has finished, but only if no errors
328 occurred during the parse. Parse returns what this returns.
329 .SS "Start                (Expat, Element [, Attr, Val [,...]])"
330 .IX Subsection "Start                (Expat, Element [, Attr, Val [,...]])"
331 This event is generated when an \s-1XML\s0 start tag is recognized. Element is the
332 name of the \s-1XML\s0 element type that is opened with the start tag. The Attr &
333 Val pairs are generated for each attribute in the start tag.
334 .SS "End                (Expat, Element)"
335 .IX Subsection "End                (Expat, Element)"
336 This event is generated when an \s-1XML\s0 end tag is recognized. Note that
337 an \s-1XML\s0 empty tag (<foo/>) generates both a start and an end event.
338 .SS "Char                (Expat, String)"
339 .IX Subsection "Char                (Expat, String)"
340 This event is generated when non-markup is recognized. The non-markup
341 sequence of characters is in String. A single non-markup sequence of
342 characters may generate multiple calls to this handler. Whatever the
343 encoding of the string in the original document, this is given to the
344 handler in \s-1UTF\-8\s0.
345 .SS "Proc                (Expat, Target, Data)"
346 .IX Subsection "Proc                (Expat, Target, Data)"
347 This event is generated when a processing instruction is recognized.
348 .SS "Comment                (Expat, Data)"
349 .IX Subsection "Comment                (Expat, Data)"
350 This event is generated when a comment is recognized.
351 .SS "CdataStart        (Expat)"
352 .IX Subsection "CdataStart        (Expat)"
353 This is called at the start of a \s-1CDATA\s0 section.
354 .SS "CdataEnd                (Expat)"
355 .IX Subsection "CdataEnd                (Expat)"
356 This is called at the end of a \s-1CDATA\s0 section.
357 .SS "Default                (Expat, String)"
358 .IX Subsection "Default                (Expat, String)"
359 This is called for any characters that don't have a registered handler.
360 This includes both characters that are part of markup for which no
361 events are generated (markup declarations) and characters that
362 could generate events, but for which no handler has been registered.
363 .PP
364 Whatever the encoding in the original document, the string is returned to
365 the handler in \s-1UTF\-8\s0.
366 .SS "Unparsed                (Expat, Entity, Base, Sysid, Pubid, Notation)"
367 .IX Subsection "Unparsed                (Expat, Entity, Base, Sysid, Pubid, Notation)"
368 This is called for a declaration of an unparsed entity. Entity is the name
369 of the entity. Base is the base to be used for resolving a relative \s-1URI\s0.
370 Sysid is the system id. Pubid is the public id. Notation is the notation
371 name. Base and Pubid may be undefined.
372 .SS "Notation                (Expat, Notation, Base, Sysid, Pubid)"
373 .IX Subsection "Notation                (Expat, Notation, Base, Sysid, Pubid)"
374 This is called for a declaration of notation. Notation is the notation name.
375 Base is the base to be used for resolving a relative \s-1URI\s0. Sysid is the system
376 id. Pubid is the public id. Base, Sysid, and Pubid may all be undefined.
377 .SS "ExternEnt        (Expat, Base, Sysid, Pubid)"
378 .IX Subsection "ExternEnt        (Expat, Base, Sysid, Pubid)"
379 This is called when an external entity is referenced. Base is the base to be
380 used for resolving a relative \s-1URI\s0. Sysid is the system id. Pubid is the public
381 id. Base, and Pubid may be undefined.
382 .PP
383 This handler should either return a string, which represents the contents of
384 the external entity, or return an open filehandle that can be read to obtain
385 the contents of the external entity, or return undef, which indicates the
386 external entity couldn't be found and will generate a parse error.
387 .PP
388 If an open filehandle is returned, it must be returned as either a glob
389 (*FOO) or as a reference to a glob (e.g. an instance of IO::Handle).
390 .PP
391 A default handler is installed for this event. The default handler is
392 XML::Parser::lwp_ext_ent_handler unless the NoLWP option was provided with
393 a true value, otherwise XML::Parser::file_ext_ent_handler is the default
394 handler for external entities. Even without the NoLWP option, if the
395 \&\s-1URI\s0 or \s-1LWP\s0 modules are missing, the file based handler ends up being used
396 after giving a warning on the first external entity reference.
397 .PP
398 The \s-1LWP\s0 external entity handler will use proxies defined in the environment
399 (http_proxy, ftp_proxy, etc.).
400 .PP
401 Please note that the \s-1LWP\s0 external entity handler reads the entire
402 entity into a string and returns it, where as the file handler opens a
403 filehandle.
404 .PP
405 Also note that the file external entity handler will likely choke on
406 absolute URIs or file names that don't fit the conventions of the local
407 operating system.
408 .PP
409 The expat base method can be used to set a basename for
410 relative pathnames. If no basename is given, or if the basename is itself
411 a relative name, then it is relative to the current working directory.
412 .SS "ExternEntFin        (Expat)"
413 .IX Subsection "ExternEntFin        (Expat)"
414 This is called after parsing an external entity. It's not called unless
415 an ExternEnt handler is also set. There is a default handler installed
416 that pairs with the default ExternEnt handler.
417 .PP
418 If you're going to install your own ExternEnt handler, then you should
419 set (or unset) this handler too.
420 .SS "Entity                (Expat, Name, Val, Sysid, Pubid, Ndata, IsParam)"
421 .IX Subsection "Entity                (Expat, Name, Val, Sysid, Pubid, Ndata, IsParam)"
422 This is called when an entity is declared. For internal entities, the Val
423 parameter will contain the value and the remaining three parameters will be
424 undefined. For external entities, the Val parameter will be undefined, the
425 Sysid parameter will have the system id, the Pubid parameter will have the
426 public id if it was provided (it will be undefined otherwise), the Ndata
427 parameter will contain the notation for unparsed entities. If this is a
428 parameter entity declaration, then the IsParam parameter is true.
429 .PP
430 Note that this handler and the Unparsed handler above overlap. If both are
431 set, then this handler will not be called for unparsed entities.
432 .SS "Element                (Expat, Name, Model)"
433 .IX Subsection "Element                (Expat, Name, Model)"
434 The element handler is called when an element declaration is found. Name
435 is the element name, and Model is the content model as an XML::Parser::Content
436 object. See \*(L"XML::Parser::ContentModel Methods\*(R" in XML::Parser::Expat
437 for methods available for this class.
438 .SS "Attlist                (Expat, Elname, Attname, Type, Default, Fixed)"
439 .IX Subsection "Attlist                (Expat, Elname, Attname, Type, Default, Fixed)"
440 This handler is called for each attribute in an \s-1ATTLIST\s0 declaration.
441 So an \s-1ATTLIST\s0 declaration that has multiple attributes will generate multiple
442 calls to this handler. The Elname parameter is the name of the element with
443 which the attribute is being associated. The Attname parameter is the name
444 of the attribute. Type is the attribute type, given as a string. Default is
445 the default value, which will either be \*(L"#REQUIRED\*(R", \*(L"#IMPLIED\*(R" or a quoted
446 string (i.e. the returned string will begin and end with a quote character).
447 If Fixed is true, then this is a fixed attribute.
448 .SS "Doctype                (Expat, Name, Sysid, Pubid, Internal)"
449 .IX Subsection "Doctype                (Expat, Name, Sysid, Pubid, Internal)"
450 This handler is called for \s-1DOCTYPE\s0 declarations. Name is the document type
451 name. Sysid is the system id of the document type, if it was provided,
452 otherwise it's undefined. Pubid is the public id of the document type,
453 which will be undefined if no public id was given. Internal is the internal
454 subset, given as a string. If there was no internal subset, it will be
455 undefined. Internal will contain all whitespace, comments, processing
456 instructions, and declarations seen in the internal subset. The declarations
457 will be there whether or not they have been processed by another handler
458 (except for unparsed entities processed by the Unparsed handler). However,
459 comments and processing instructions will not appear if they've been processed
460 by their respective handlers.
461 .SS "* DoctypeFin                (Parser)"
462 .IX Subsection "* DoctypeFin                (Parser)"
463 This handler is called after parsing of the \s-1DOCTYPE\s0 declaration has finished,
464 including any internal or external \s-1DTD\s0 declarations.
465 .SS "XMLDecl                (Expat, Version, Encoding, Standalone)"
466 .IX Subsection "XMLDecl                (Expat, Version, Encoding, Standalone)"
467 This handler is called for xml declarations. Version is a string containg
468 the version. Encoding is either undefined or contains an encoding string.
469 Standalone will be either true, false, or undefined if the standalone attribute
470 is yes, no, or not made respectively.
471 .SH "STYLES"
472 .IX Header "STYLES"
473 .SS "Debug"
474 .IX Subsection "Debug"
475 This just prints out the document in outline form. Nothing special is
476 returned by parse.
477 .SS "Subs"
478 .IX Subsection "Subs"
479 Each time an element starts, a sub by that name in the package specified
480 by the Pkg option is called with the same parameters that the Start
481 handler gets called with.
482 .PP
483 Each time an element ends, a sub with that name appended with an underscore
484 (\*(L"_\*(R"), is called with the same parameters that the End handler gets called
485 with.
486 .PP
487 Nothing special is returned by parse.
488 .SS "Tree"
489 .IX Subsection "Tree"
490 Parse will return a parse tree for the document. Each node in the tree
491 takes the form of a tag, content pair. Text nodes are represented with
492 a pseudo-tag of \*(L"0\*(R" and the string that is their content. For elements,
493 the content is an array reference. The first item in the array is a
494 (possibly empty) hash reference containing attributes. The remainder of
495 the array is a sequence of tag-content pairs representing the content
496 of the element.
497 .PP
498 So for example the result of parsing:
499 .PP
500 .Vb 1
501 \&  <foo><head id="a">Hello <em>there</em></head><bar>Howdy<ref/></bar>do</foo>
502 .Ve
503 .PP
504 would be:
505 .PP
506 .Vb 7
507 \&             Tag   Content
508 \&  ==================================================================
509 \&  [foo, [{}, head, [{id => "a"}, 0, "Hello ",  em, [{}, 0, "there"]],
510 \&              bar, [         {}, 0, "Howdy",  ref, [{}]],
511 \&                0, "do"
512 \&        ]
513 \&  ]
514 .Ve
515 .PP
516 The root document \*(L"foo\*(R", has 3 children: a \*(L"head\*(R" element, a \*(L"bar\*(R"
517 element and the text \*(L"do\*(R". After the empty attribute hash, these are
518 represented in it's contents by 3 tag-content pairs.
519 .SS "Objects"
520 .IX Subsection "Objects"
521 This is similar to the Tree style, except that a hash object is created for
522 each element. The corresponding object will be in the class whose name
523 is created by appending \*(L"::\*(R" and the element name to the package set with
524 the Pkg option. Non-markup text will be in the ::Characters class. The
525 contents of the corresponding object will be in an anonymous array that
526 is the value of the Kids property for that object.
527 .SS "Stream"
528 .IX Subsection "Stream"
529 This style also uses the Pkg package. If none of the subs that this
530 style looks for is there, then the effect of parsing with this style is
531 to print a canonical copy of the document without comments or declarations.
532 All the subs receive as their 1st parameter the Expat instance for the
533 document they're parsing.
534 .PP
535 It looks for the following routines:
536 .IP "\(bu" 4
537 StartDocument
538 .Sp
539 Called at the start of the parse .
540 .IP "\(bu" 4
541 StartTag
542 .Sp
543 Called for every start tag with a second parameter of the element type. The \f(CW$_\fR
544 variable will contain a copy of the tag and the \f(CW%_\fR variable will contain
545 attribute values supplied for that element.
546 .IP "\(bu" 4
547 EndTag
548 .Sp
549 Called for every end tag with a second parameter of the element type. The \f(CW$_\fR
550 variable will contain a copy of the end tag.
551 .IP "\(bu" 4
552 Text
553 .Sp
554 Called just before start or end tags with accumulated non-markup text in
555 the \f(CW$_\fR variable.
556 .IP "\(bu" 4
557 \&\s-1PI\s0
558 .Sp
559 Called for processing instructions. The \f(CW$_\fR variable will contain a copy of
560 the \s-1PI\s0 and the target and data are sent as 2nd and 3rd parameters
561 respectively.
562 .IP "\(bu" 4
563 EndDocument
564 .Sp
565 Called at conclusion of the parse.
566 .SH "ENCODINGS"
567 .IX Header "ENCODINGS"
568 \&\s-1XML\s0 documents may be encoded in character sets other than Unicode as
569 long as they may be mapped into the Unicode character set. Expat has
570 further restrictions on encodings. Read the xmlparse.h header file in
571 the expat distribution to see details on these restrictions.
572 .PP
573 Expat has built-in encodings for: \f(CW\*(C`UTF\-8\*(C'\fR, \f(CW\*(C`ISO\-8859\-1\*(C'\fR, \f(CW\*(C`UTF\-16\*(C'\fR, and
574 \&\f(CW\*(C`US\-ASCII\*(C'\fR. Encodings are set either through the \s-1XML\s0 declaration
575 encoding attribute or through the ProtocolEncoding option to XML::Parser
576 or XML::Parser::Expat.
577 .PP
578 For encodings other than the built-ins, expat calls the function
579 load_encoding in the Expat package with the encoding name. This function
580 looks for a file in the path list \f(CW@XML::Parser::Expat::Encoding_Path\fR, that
581 matches the lower-cased name with a '.enc' extension. The first one it
582 finds, it loads.
583 .PP
584 If you wish to build your own encoding maps, check out the XML::Encoding
585 module from \s-1CPAN\s0.
586 .SH "AUTHORS"
587 .IX Header "AUTHORS"
588 Larry Wall <\fIlarry@wall.org\fR> wrote version 1.0.
589 .PP
590 Clark Cooper <\fIcoopercc@netheaven.com\fR> picked up support, changed the \s-1API\s0
591 for this version (2.x), provided documentation,
592 and added some standard package features.
593 .PP
594 Matt Sergeant <\fImatt@sergeant.org\fR> is now maintaining XML::Parser