Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "Expat 3" | |
132 | .TH Expat 3 "2003-08-18" "perl v5.8.8" "User Contributed Perl Documentation" | |
133 | .SH "NAME" | |
134 | XML::Parser::Expat \- Lowlevel access to James Clark's expat XML parser | |
135 | .SH "SYNOPSIS" | |
136 | .IX Header "SYNOPSIS" | |
137 | .Vb 1 | |
138 | \& use XML::Parser::Expat; | |
139 | .Ve | |
140 | .PP | |
141 | .Vb 8 | |
142 | \& $parser = new XML::Parser::Expat; | |
143 | \& $parser->setHandlers('Start' => \e&sh, | |
144 | \& 'End' => \e&eh, | |
145 | \& 'Char' => \e&ch); | |
146 | \& open(FOO, 'info.xml') or die "Couldn't open"; | |
147 | \& $parser->parse(*FOO); | |
148 | \& close(FOO); | |
149 | \& # $parser->parse('<foo id="me"> here <em>we</em> go </foo>'); | |
150 | .Ve | |
151 | .PP | |
152 | .Vb 7 | |
153 | \& sub sh | |
154 | \& { | |
155 | \& my ($p, $el, %atts) = @_; | |
156 | \& $p->setHandlers('Char' => \e&spec) | |
157 | \& if ($el eq 'special'); | |
158 | \& ... | |
159 | \& } | |
160 | .Ve | |
161 | .PP | |
162 | .Vb 7 | |
163 | \& sub eh | |
164 | \& { | |
165 | \& my ($p, $el) = @_; | |
166 | \& $p->setHandlers('Char' => \e&ch) # Special elements won't contain | |
167 | \& if ($el eq 'special'); # other special elements | |
168 | \& ... | |
169 | \& } | |
170 | .Ve | |
171 | .SH "DESCRIPTION" | |
172 | .IX Header "DESCRIPTION" | |
173 | This module provides an interface to James Clark's \s-1XML\s0 parser, expat. As in | |
174 | expat, a single instance of the parser can only parse one document. Calls | |
175 | to parsestring after the first for a given instance will die. | |
176 | .PP | |
177 | Expat (and XML::Parser::Expat) are event based. As the parser recognizes | |
178 | parts of the document (say the start or end of an \s-1XML\s0 element), then any | |
179 | handlers registered for that type of an event are called with suitable | |
180 | parameters. | |
181 | .SH "METHODS" | |
182 | .IX Header "METHODS" | |
183 | .IP "new" 4 | |
184 | .IX Item "new" | |
185 | This is a class method, the constructor for XML::Parser::Expat. Options are | |
186 | passed as keyword value pairs. The recognized options are: | |
187 | .RS 4 | |
188 | .IP "* ProtocolEncoding" 4 | |
189 | .IX Item "ProtocolEncoding" | |
190 | The protocol encoding name. The default is none. The expat built-in | |
191 | 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 \f(CW\*(C`US\-ASCII\*(C'\fR. | |
192 | Other encodings may be used if they have encoding maps in one of the | |
193 | directories in the \f(CW@Encoding_Path\fR list. Setting the protocol encoding | |
194 | overrides any encoding in the \s-1XML\s0 declaration. | |
195 | .IP "* Namespaces" 4 | |
196 | .IX Item "Namespaces" | |
197 | When this option is given with a true value, then the parser does namespace | |
198 | processing. By default, namespace processing is turned off. When it is | |
199 | turned on, the parser consumes \fIxmlns\fR attributes and strips off prefixes | |
200 | from element and attributes names where those prefixes have a defined | |
201 | namespace. A name's namespace can be found using the \*(L"namespace\*(R" method | |
202 | and two names can be checked for absolute equality with the \*(L"eq_name\*(R" | |
203 | method. | |
204 | .IP "* NoExpand" 4 | |
205 | .IX Item "NoExpand" | |
206 | Normally, the parser will try to expand references to entities defined in | |
207 | the internal subset. If this option is set to a true value, and a default | |
208 | handler is also set, then the default handler will be called when an | |
209 | entity reference is seen in text. This has no effect if a default handler | |
210 | has not been registered, and it has no effect on the expansion of entity | |
211 | references inside attribute values. | |
212 | .IP "* Stream_Delimiter" 4 | |
213 | .IX Item "Stream_Delimiter" | |
214 | This option takes a string value. When this string is found alone on a line | |
215 | while parsing from a stream, then the parse is ended as if it saw an end of | |
216 | file. The intended use is with a stream of xml documents in a \s-1MIME\s0 multipart | |
217 | format. The string should not contain a trailing newline. | |
218 | .IP "* ErrorContext" 4 | |
219 | .IX Item "ErrorContext" | |
220 | When this option is defined, errors are reported in context. The value | |
221 | of ErrorContext should be the number of lines to show on either side of | |
222 | the line in which the error occurred. | |
223 | .IP "* ParseParamEnt" 4 | |
224 | .IX Item "ParseParamEnt" | |
225 | Unless standalone is set to \*(L"yes\*(R" in the \s-1XML\s0 declaration, setting this to | |
226 | a true value allows the external \s-1DTD\s0 to be read, and parameter entities | |
227 | to be parsed and expanded. | |
228 | .IP "* Base" 4 | |
229 | .IX Item "Base" | |
230 | The base to use for relative pathnames or URLs. This can also be done by | |
231 | using the base method. | |
232 | .RE | |
233 | .RS 4 | |
234 | .RE | |
235 | .IP "setHandlers(\s-1TYPE\s0, \s-1HANDLER\s0 [, \s-1TYPE\s0, \s-1HANDLER\s0 [...]])" 4 | |
236 | .IX Item "setHandlers(TYPE, HANDLER [, TYPE, HANDLER [...]])" | |
237 | This method registers handlers for the various events. If no handlers are | |
238 | registered, then a call to parsestring or parsefile will only determine if | |
239 | the corresponding \s-1XML\s0 document is well formed (by returning without error.) | |
240 | This may be called from within a handler, after the parse has started. | |
241 | .Sp | |
242 | Setting a handler to something that evaluates to false unsets that | |
243 | handler. | |
244 | .Sp | |
245 | This method returns a list of type, handler pairs corresponding to the | |
246 | input. The handlers returned are the ones that were in effect before the | |
247 | call to setHandlers. | |
248 | .Sp | |
249 | The recognized events and the parameters passed to the corresponding | |
250 | handlers are: | |
251 | .RS 4 | |
252 | .IP "* Start (Parser, Element [, Attr, Val [,...]])" 4 | |
253 | .IX Item "Start (Parser, Element [, Attr, Val [,...]])" | |
254 | This event is generated when an \s-1XML\s0 start tag is recognized. Parser is | |
255 | an XML::Parser::Expat instance. Element is the name of the \s-1XML\s0 element that | |
256 | is opened with the start tag. The Attr & Val pairs are generated for each | |
257 | attribute in the start tag. | |
258 | .IP "* End (Parser, Element)" 4 | |
259 | .IX Item "End (Parser, Element)" | |
260 | This event is generated when an \s-1XML\s0 end tag is recognized. Note that | |
261 | an \s-1XML\s0 empty tag (<foo/>) generates both a start and an end event. | |
262 | .Sp | |
263 | There is always a lower level start and end handler installed that wrap | |
264 | the corresponding callbacks. This is to handle the context mechanism. | |
265 | A consequence of this is that the default handler (see below) will not | |
266 | see a start tag or end tag unless the default_current method is called. | |
267 | .IP "* Char (Parser, String)" 4 | |
268 | .IX Item "Char (Parser, String)" | |
269 | This event is generated when non-markup is recognized. The non-markup | |
270 | sequence of characters is in String. A single non-markup sequence of | |
271 | characters may generate multiple calls to this handler. Whatever the | |
272 | encoding of the string in the original document, this is given to the | |
273 | handler in \s-1UTF\-8\s0. | |
274 | .IP "* Proc (Parser, Target, Data)" 4 | |
275 | .IX Item "Proc (Parser, Target, Data)" | |
276 | This event is generated when a processing instruction is recognized. | |
277 | .IP "* Comment (Parser, String)" 4 | |
278 | .IX Item "Comment (Parser, String)" | |
279 | This event is generated when a comment is recognized. | |
280 | .IP "* CdataStart (Parser)" 4 | |
281 | .IX Item "CdataStart (Parser)" | |
282 | This is called at the start of a \s-1CDATA\s0 section. | |
283 | .IP "* CdataEnd (Parser)" 4 | |
284 | .IX Item "CdataEnd (Parser)" | |
285 | This is called at the end of a \s-1CDATA\s0 section. | |
286 | .IP "* Default (Parser, String)" 4 | |
287 | .IX Item "Default (Parser, String)" | |
288 | This is called for any characters that don't have a registered handler. | |
289 | This includes both characters that are part of markup for which no | |
290 | events are generated (markup declarations) and characters that | |
291 | could generate events, but for which no handler has been registered. | |
292 | .Sp | |
293 | Whatever the encoding in the original document, the string is returned to | |
294 | the handler in \s-1UTF\-8\s0. | |
295 | .IP "* Unparsed (Parser, Entity, Base, Sysid, Pubid, Notation)" 4 | |
296 | .IX Item "Unparsed (Parser, Entity, Base, Sysid, Pubid, Notation)" | |
297 | This is called for a declaration of an unparsed entity. Entity is the name | |
298 | of the entity. Base is the base to be used for resolving a relative \s-1URI\s0. | |
299 | Sysid is the system id. Pubid is the public id. Notation is the notation | |
300 | name. Base and Pubid may be undefined. | |
301 | .IP "* Notation (Parser, Notation, Base, Sysid, Pubid)" 4 | |
302 | .IX Item "Notation (Parser, Notation, Base, Sysid, Pubid)" | |
303 | This is called for a declaration of notation. Notation is the notation name. | |
304 | Base is the base to be used for resolving a relative \s-1URI\s0. Sysid is the system | |
305 | id. Pubid is the public id. Base, Sysid, and Pubid may all be undefined. | |
306 | .IP "* ExternEnt (Parser, Base, Sysid, Pubid)" 4 | |
307 | .IX Item "ExternEnt (Parser, Base, Sysid, Pubid)" | |
308 | This is called when an external entity is referenced. Base is the base to be | |
309 | used for resolving a relative \s-1URI\s0. Sysid is the system id. Pubid is the public | |
310 | id. Base, and Pubid may be undefined. | |
311 | .Sp | |
312 | This handler should either return a string, which represents the contents of | |
313 | the external entity, or return an open filehandle that can be read to obtain | |
314 | the contents of the external entity, or return undef, which indicates the | |
315 | external entity couldn't be found and will generate a parse error. | |
316 | .Sp | |
317 | If an open filehandle is returned, it must be returned as either a glob | |
318 | (*FOO) or as a reference to a glob (e.g. an instance of IO::Handle). | |
319 | .IP "* ExternEntFin (Parser)" 4 | |
320 | .IX Item "ExternEntFin (Parser)" | |
321 | This is called after an external entity has been parsed. It allows | |
322 | applications to perform cleanup on actions performed in the above | |
323 | ExternEnt handler. | |
324 | .IP "* Entity (Parser, Name, Val, Sysid, Pubid, Ndata, IsParam)" 4 | |
325 | .IX Item "Entity (Parser, Name, Val, Sysid, Pubid, Ndata, IsParam)" | |
326 | This is called when an entity is declared. For internal entities, the Val | |
327 | parameter will contain the value and the remaining three parameters will | |
328 | be undefined. For external entities, the Val parameter | |
329 | will be undefined, the Sysid parameter will have the system id, the Pubid | |
330 | parameter will have the public id if it was provided (it will be undefined | |
331 | otherwise), the Ndata parameter will contain the notation for unparsed | |
332 | entities. If this is a parameter entity declaration, then the IsParam | |
333 | parameter is true. | |
334 | .Sp | |
335 | Note that this handler and the Unparsed handler above overlap. If both are | |
336 | set, then this handler will not be called for unparsed entities. | |
337 | .IP "* Element (Parser, Name, Model)" 4 | |
338 | .IX Item "Element (Parser, Name, Model)" | |
339 | The element handler is called when an element declaration is found. Name is | |
340 | the element name, and Model is the content model as an | |
341 | XML::Parser::ContentModel object. See \*(L"XML::Parser::ContentModel Methods\*(R" | |
342 | for methods available for this class. | |
343 | .IP "* Attlist (Parser, Elname, Attname, Type, Default, Fixed)" 4 | |
344 | .IX Item "Attlist (Parser, Elname, Attname, Type, Default, Fixed)" | |
345 | This handler is called for each attribute in an \s-1ATTLIST\s0 declaration. | |
346 | So an \s-1ATTLIST\s0 declaration that has multiple attributes | |
347 | will generate multiple calls to this handler. The Elname parameter is the | |
348 | name of the element with which the attribute is being associated. The Attname | |
349 | parameter is the name of the attribute. Type is the attribute type, given as | |
350 | a string. Default is the default value, which will either be \*(L"#REQUIRED\*(R", | |
351 | \&\*(L"#IMPLIED\*(R" or a quoted string (i.e. the returned string will begin and end | |
352 | with a quote character). If Fixed is true, then this is a fixed attribute. | |
353 | .IP "* Doctype (Parser, Name, Sysid, Pubid, Internal)" 4 | |
354 | .IX Item "Doctype (Parser, Name, Sysid, Pubid, Internal)" | |
355 | This handler is called for \s-1DOCTYPE\s0 declarations. Name is the document type | |
356 | name. Sysid is the system id of the document type, if it was provided, | |
357 | otherwise it's undefined. Pubid is the public id of the document type, | |
358 | which will be undefined if no public id was given. Internal will be | |
359 | true or false, indicating whether or not the doctype declaration contains | |
360 | an internal subset. | |
361 | .IP "* DoctypeFin (Parser)" 4 | |
362 | .IX Item "DoctypeFin (Parser)" | |
363 | This handler is called after parsing of the \s-1DOCTYPE\s0 declaration has finished, | |
364 | including any internal or external \s-1DTD\s0 declarations. | |
365 | .IP "* XMLDecl (Parser, Version, Encoding, Standalone)" 4 | |
366 | .IX Item "XMLDecl (Parser, Version, Encoding, Standalone)" | |
367 | This handler is called for \s-1XML\s0 declarations. Version is a string containg | |
368 | the version. Encoding is either undefined or contains an encoding string. | |
369 | Standalone is either undefined, or true or false. Undefined indicates | |
370 | that no standalone parameter was given in the \s-1XML\s0 declaration. True or | |
371 | false indicates \*(L"yes\*(R" or \*(L"no\*(R" respectively. | |
372 | .RE | |
373 | .RS 4 | |
374 | .RE | |
375 | .IP "namespace(name)" 4 | |
376 | .IX Item "namespace(name)" | |
377 | Return the \s-1URI\s0 of the namespace that the name belongs to. If the name doesn't | |
378 | belong to any namespace, an undef is returned. This is only valid on names | |
379 | received through the Start or End handlers from a single document, or through | |
380 | a call to the generate_ns_name method. In other words, don't use names | |
381 | generated from one instance of XML::Parser::Expat with other instances. | |
382 | .IP "eq_name(name1, name2)" 4 | |
383 | .IX Item "eq_name(name1, name2)" | |
384 | Return true if name1 and name2 are identical (i.e. same name and from | |
385 | the same namespace.) This is only meaningful if both names were obtained | |
386 | through the Start or End handlers from a single document, or through | |
387 | a call to the generate_ns_name method. | |
388 | .IP "generate_ns_name(name, namespace)" 4 | |
389 | .IX Item "generate_ns_name(name, namespace)" | |
390 | Return a name, associated with a given namespace, good for using with the | |
391 | above 2 methods. The namespace argument should be the namespace \s-1URI\s0, not | |
392 | a prefix. | |
393 | .IP "new_ns_prefixes" 4 | |
394 | .IX Item "new_ns_prefixes" | |
395 | When called from a start tag handler, returns namespace prefixes declared | |
396 | with this start tag. If called elsewere (or if there were no namespace | |
397 | prefixes declared), it returns an empty list. Setting of the default | |
398 | namespace is indicated with '#default' as a prefix. | |
399 | .IP "expand_ns_prefix(prefix)" 4 | |
400 | .IX Item "expand_ns_prefix(prefix)" | |
401 | Return the uri to which the given prefix is currently bound. Returns | |
402 | undef if the prefix isn't currently bound. Use '#default' to find the | |
403 | current binding of the default namespace (if any). | |
404 | .IP "current_ns_prefixes" 4 | |
405 | .IX Item "current_ns_prefixes" | |
406 | Return a list of currently bound namespace prefixes. The order of the | |
407 | the prefixes in the list has no meaning. If the default namespace is | |
408 | currently bound, '#default' appears in the list. | |
409 | .IP "recognized_string" 4 | |
410 | .IX Item "recognized_string" | |
411 | Returns the string from the document that was recognized in order to call | |
412 | the current handler. For instance, when called from a start handler, it | |
413 | will give us the the start-tag string. The string is encoded in \s-1UTF\-8\s0. | |
414 | This method doesn't return a meaningful string inside declaration handlers. | |
415 | .IP "original_string" 4 | |
416 | .IX Item "original_string" | |
417 | Returns the verbatim string from the document that was recognized in | |
418 | order to call the current handler. The string is in the original document | |
419 | encoding. This method doesn't return a meaningful string inside declaration | |
420 | handlers. | |
421 | .IP "default_current" 4 | |
422 | .IX Item "default_current" | |
423 | When called from a handler, causes the sequence of characters that generated | |
424 | the corresponding event to be sent to the default handler (if one is | |
425 | registered). Use of this method is deprecated in favor the recognized_string | |
426 | method, which you can use without installing a default handler. This | |
427 | method doesn't deliver a meaningful string to the default handler when | |
428 | called from inside declaration handlers. | |
429 | .IP "xpcroak(message)" 4 | |
430 | .IX Item "xpcroak(message)" | |
431 | Concatenate onto the given message the current line number within the | |
432 | \&\s-1XML\s0 document plus the message implied by ErrorContext. Then croak with | |
433 | the formed message. | |
434 | .IP "xpcarp(message)" 4 | |
435 | .IX Item "xpcarp(message)" | |
436 | Concatenate onto the given message the current line number within the | |
437 | \&\s-1XML\s0 document plus the message implied by ErrorContext. Then carp with | |
438 | the formed message. | |
439 | .IP "current_line" 4 | |
440 | .IX Item "current_line" | |
441 | Returns the line number of the current position of the parse. | |
442 | .IP "current_column" 4 | |
443 | .IX Item "current_column" | |
444 | Returns the column number of the current position of the parse. | |
445 | .IP "current_byte" 4 | |
446 | .IX Item "current_byte" | |
447 | Returns the current position of the parse. | |
448 | .IP "base([\s-1NEWBASE\s0]);" 4 | |
449 | .IX Item "base([NEWBASE]);" | |
450 | Returns the current value of the base for resolving relative URIs. If | |
451 | \&\s-1NEWBASE\s0 is supplied, changes the base to that value. | |
452 | .IP "context" 4 | |
453 | .IX Item "context" | |
454 | Returns a list of element names that represent open elements, with the | |
455 | last one being the innermost. Inside start and end tag handlers, this | |
456 | will be the tag of the parent element. | |
457 | .IP "current_element" 4 | |
458 | .IX Item "current_element" | |
459 | Returns the name of the innermost currently opened element. Inside | |
460 | start or end handlers, returns the parent of the element associated | |
461 | with those tags. | |
462 | .IP "in_element(\s-1NAME\s0)" 4 | |
463 | .IX Item "in_element(NAME)" | |
464 | Returns true if \s-1NAME\s0 is equal to the name of the innermost currently opened | |
465 | element. If namespace processing is being used and you want to check | |
466 | against a name that may be in a namespace, then use the generate_ns_name | |
467 | method to create the \s-1NAME\s0 argument. | |
468 | .IP "within_element(\s-1NAME\s0)" 4 | |
469 | .IX Item "within_element(NAME)" | |
470 | Returns the number of times the given name appears in the context list. | |
471 | If namespace processing is being used and you want to check | |
472 | against a name that may be in a namespace, then use the generate_ns_name | |
473 | method to create the \s-1NAME\s0 argument. | |
474 | .IP "depth" 4 | |
475 | .IX Item "depth" | |
476 | Returns the size of the context list. | |
477 | .IP "element_index" 4 | |
478 | .IX Item "element_index" | |
479 | Returns an integer that is the depth-first visit order of the current | |
480 | element. This will be zero outside of the root element. For example, | |
481 | this will return 1 when called from the start handler for the root element | |
482 | start tag. | |
483 | .IP "skip_until(\s-1INDEX\s0)" 4 | |
484 | .IX Item "skip_until(INDEX)" | |
485 | \&\s-1INDEX\s0 is an integer that represents an element index. When this method | |
486 | is called, all handlers are suspended until the start tag for an element | |
487 | that has an index number equal to \s-1INDEX\s0 is seen. If a start handler has | |
488 | been set, then this is the first tag that the start handler will see | |
489 | after skip_until has been called. | |
490 | .IP "position_in_context(\s-1LINES\s0)" 4 | |
491 | .IX Item "position_in_context(LINES)" | |
492 | Returns a string that shows the current parse position. \s-1LINES\s0 should be | |
493 | an integer >= 0 that represents the number of lines on either side of the | |
494 | current parse line to place into the returned string. | |
495 | .IP "xml_escape(\s-1TEXT\s0 [, \s-1CHAR\s0 [, \s-1CHAR\s0 ...]])" 4 | |
496 | .IX Item "xml_escape(TEXT [, CHAR [, CHAR ...]])" | |
497 | Returns \s-1TEXT\s0 with markup characters turned into character entities. Any | |
498 | additional characters provided as arguments are also turned into character | |
499 | references where found in \s-1TEXT\s0. | |
500 | .IP "parse (\s-1SOURCE\s0)" 4 | |
501 | .IX Item "parse (SOURCE)" | |
502 | The \s-1SOURCE\s0 parameter should either be a string containing the whole \s-1XML\s0 | |
503 | document, or it should be an open IO::Handle. Only a single document | |
504 | may be parsed for a given instance of XML::Parser::Expat, so this will croak | |
505 | if it's been called previously for this instance. | |
506 | .IP "parsestring(\s-1XML_DOC_STRING\s0)" 4 | |
507 | .IX Item "parsestring(XML_DOC_STRING)" | |
508 | Parses the given string as an \s-1XML\s0 document. Only a single document may be | |
509 | parsed for a given instance of XML::Parser::Expat, so this will die if either | |
510 | parsestring or parsefile has been called for this instance previously. | |
511 | .Sp | |
512 | This method is deprecated in favor of the parse method. | |
513 | .IP "parsefile(\s-1FILENAME\s0)" 4 | |
514 | .IX Item "parsefile(FILENAME)" | |
515 | Parses the \s-1XML\s0 document in the given file. Will die if parsestring or | |
516 | parsefile has been called previously for this instance. | |
517 | .IP "is_defaulted(\s-1ATTNAME\s0)" 4 | |
518 | .IX Item "is_defaulted(ATTNAME)" | |
519 | \&\s-1NO\s0 \s-1LONGER\s0 \s-1WORKS\s0. To find out if an attribute is defaulted please use | |
520 | the specified_attr method. | |
521 | .IP "specified_attr" 4 | |
522 | .IX Item "specified_attr" | |
523 | When the start handler receives lists of attributes and values, the | |
524 | non-defaulted (i.e. explicitly specified) attributes occur in the list | |
525 | first. This method returns the number of specified items in the list. | |
526 | So if this number is equal to the length of the list, there were no | |
527 | defaulted values. Otherwise the number points to the index of the | |
528 | first defaulted attribute name. | |
529 | .IP "finish" 4 | |
530 | .IX Item "finish" | |
531 | Unsets all handlers (including internal ones that set context), but expat | |
532 | continues parsing to the end of the document or until it finds an error. | |
533 | It should finish up a lot faster than with the handlers set. | |
534 | .IP "release" 4 | |
535 | .IX Item "release" | |
536 | There are data structures used by XML::Parser::Expat that have circular | |
537 | references. This means that these structures will never be garbage | |
538 | collected unless these references are explicitly broken. Calling this | |
539 | method breaks those references (and makes the instance unusable.) | |
540 | .Sp | |
541 | Normally, higher level calls handle this for you, but if you are using | |
542 | XML::Parser::Expat directly, then it's your responsibility to call it. | |
543 | .Sh "XML::Parser::ContentModel Methods" | |
544 | .IX Subsection "XML::Parser::ContentModel Methods" | |
545 | The element declaration handlers are passed objects of this class as the | |
546 | content model of the element declaration. They also represent content | |
547 | particles, components of a content model. | |
548 | .PP | |
549 | When referred to as a string, these objects are automagicly converted to a | |
550 | string representation of the model (or content particle). | |
551 | .IP "isempty" 4 | |
552 | .IX Item "isempty" | |
553 | This method returns true if the object is \*(L"\s-1EMPTY\s0\*(R", false otherwise. | |
554 | .IP "isany" 4 | |
555 | .IX Item "isany" | |
556 | This method returns true if the object is \*(L"\s-1ANY\s0\*(R", false otherwise. | |
557 | .IP "ismixed" 4 | |
558 | .IX Item "ismixed" | |
559 | This method returns true if the object is \*(L"(#PCDATA)\*(R" or \*(L"(#PCDATA|...)*\*(R", | |
560 | false otherwise. | |
561 | .IP "isname" 4 | |
562 | .IX Item "isname" | |
563 | This method returns if the object is an element name. | |
564 | .IP "ischoice" 4 | |
565 | .IX Item "ischoice" | |
566 | This method returns true if the object is a choice of content particles. | |
567 | .IP "isseq" 4 | |
568 | .IX Item "isseq" | |
569 | This method returns true if the object is a sequence of content particles. | |
570 | .IP "quant" 4 | |
571 | .IX Item "quant" | |
572 | This method returns undef or a string representing the quantifier | |
573 | ('?', '*', '+') associated with the model or particle. | |
574 | .IP "children" 4 | |
575 | .IX Item "children" | |
576 | This method returns undef or (for mixed, choice, and sequence types) | |
577 | an array of component content particles. There will always be at least | |
578 | one component for choices and sequences, but for a mixed content model | |
579 | of pure \s-1PCDATA\s0, \*(L"(#PCDATA)\*(R", then an undef is returned. | |
580 | .Sh "XML::Parser::ExpatNB Methods" | |
581 | .IX Subsection "XML::Parser::ExpatNB Methods" | |
582 | The class XML::Parser::ExpatNB is a subclass of XML::Parser::Expat used | |
583 | for non-blocking access to the expat library. It does not support the parse, | |
584 | parsestring, or parsefile methods, but it does have these additional methods: | |
585 | .IP "parse_more(\s-1DATA\s0)" 4 | |
586 | .IX Item "parse_more(DATA)" | |
587 | Feed expat more text to munch on. | |
588 | .IP "parse_done" 4 | |
589 | .IX Item "parse_done" | |
590 | Tell expat that it's gotten the whole document. | |
591 | .SH "FUNCTIONS" | |
592 | .IX Header "FUNCTIONS" | |
593 | .IP "XML::Parser::Expat::load_encoding(\s-1ENCODING\s0)" 4 | |
594 | .IX Item "XML::Parser::Expat::load_encoding(ENCODING)" | |
595 | Load an external encoding. \s-1ENCODING\s0 is either the name of an encoding or | |
596 | the name of a file. The basename is converted to lowercase and a '.enc' | |
597 | extension is appended unless there's one already there. Then, unless | |
598 | it's an absolute pathname (i.e. begins with '/'), the first file by that | |
599 | name discovered in the \f(CW@Encoding_Path\fR path list is used. | |
600 | .Sp | |
601 | The encoding in the file is loaded and kept in the \f(CW%Encoding_Table\fR | |
602 | table. Earlier encodings of the same name are replaced. | |
603 | .Sp | |
604 | This function is automaticly called by expat when it encounters an encoding | |
605 | it doesn't know about. Expat shouldn't call this twice for the same | |
606 | encoding name. The only reason users should use this function is to | |
607 | explicitly load an encoding not contained in the \f(CW@Encoding_Path\fR list. | |
608 | .SH "AUTHORS" | |
609 | .IX Header "AUTHORS" | |
610 | Larry Wall <\fIlarry@wall.org\fR> wrote version 1.0. | |
611 | .PP | |
612 | Clark Cooper <\fIcoopercc@netheaven.com\fR> picked up support, changed the \s-1API\s0 | |
613 | for this version (2.x), provided documentation, and added some standard | |
614 | package features. |