deprecated/buildtools/buildsystemtools/lib/XML/Parser/Expat.pod
author lorewang
Wed, 01 Dec 2010 16:05:36 +0800
changeset 715 e0739b8406dd
parent 655 3f65fd25dfd4
permissions -rw-r--r--
Specify extenal tool with path
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
655
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     1
=head1 WARNING
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     3
This manual page was copied from the XML::Parser distribution (version 2.27)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     4
written by Clark Cooper. You can find newer versions at CPAN.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     5
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     6
=head1 NAME
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     7
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     8
XML::Parser::Expat - Lowlevel access to James Clark's expat XML parser
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     9
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    10
=head1 SYNOPSIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    11
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    12
 use XML::Parser::Expat;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    13
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    14
 $parser = new XML::Parser::Expat;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    15
 $parser->setHandlers('Start' => \&sh,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    16
		      'End'   => \&eh,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    17
                      'Char'  => \&ch);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    18
 open(FOO, 'info.xml') or die "Couldn't open";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    19
 $parser->parse(*FOO);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    20
 close(FOO);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    21
 # $parser->parse('<foo id="me"> here <em>we</em> go </foo>');
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    22
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    23
 sub sh
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    24
 {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    25
   my ($p, $el, %atts) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    26
   $p->setHandlers('Char' => \&spec)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    27
     if ($el eq 'special');
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    28
   ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    29
 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    30
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    31
 sub eh
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    32
 {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    33
   my ($p, $el) = @_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    34
   $p->setHandlers('Char' => \&ch)  # Special elements won't contain
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    35
     if ($el eq 'special');         # other special elements
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    36
   ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    37
 } 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    38
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    39
=head1 DESCRIPTION
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    40
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    41
This module provides an interface to James Clark's XML parser, expat. As in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    42
expat, a single instance of the parser can only parse one document. Calls
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    43
to parsestring after the first for a given instance will die.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    44
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    45
Expat (and XML::Parser::Expat) are event based. As the parser recognizes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    46
parts of the document (say the start or end of an XML element), then any
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    47
handlers registered for that type of an event are called with suitable
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    48
parameters.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    49
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    50
=head1 METHODS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    51
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    52
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    53
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    54
=item new
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    55
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    56
This is a class method, the constructor for XML::Parser::Expat. Options are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    57
passed as keyword value pairs. The recognized options are:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    58
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    59
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    60
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    61
=item * ProtocolEncoding
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    62
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    63
The protocol encoding name. The default is none. The expat built-in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    64
encodings are: C<UTF-8>, C<ISO-8859-1>, C<UTF-16>, and C<US-ASCII>.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    65
Other encodings may be used if they have encoding maps in one of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    66
directories in the @Encoding_Path list. Setting the protocol encoding
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    67
overrides any encoding in the XML declaration.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    68
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    69
=item * Namespaces
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    70
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    71
When this option is given with a true value, then the parser does namespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    72
processing. By default, namespace processing is turned off. When it is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    73
turned on, the parser consumes I<xmlns> attributes and strips off prefixes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    74
from element and attributes names where those prefixes have a defined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    75
namespace. A name's namespace can be found using the L<"namespace"> method
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    76
and two names can be checked for absolute equality with the L<"eq_name">
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    77
method.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    78
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    79
=item * NoExpand
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    80
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    81
Normally, the parser will try to expand references to entities defined in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    82
the internal subset. If this option is set to a true value, and a default
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    83
handler is also set, then the default handler will be called when an
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    84
entity reference is seen in text. This has no effect if a default handler
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    85
has not been registered, and it has no effect on the expansion of entity
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    86
references inside attribute values.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    87
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    88
=item * Stream_Delimiter
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    89
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    90
This option takes a string value. When this string is found alone on a line
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    91
while parsing from a stream, then the parse is ended as if it saw an end of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    92
file. The intended use is with a stream of xml documents in a MIME multipart
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    93
format. The string should not contain a trailing newline.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    94
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    95
=item * ErrorContext
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    96
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    97
When this option is defined, errors are reported in context. The value
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    98
of ErrorContext should be the number of lines to show on either side of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    99
the line in which the error occurred.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   100
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   101
=item * ParseParamEnt
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   102
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   103
Unless standalone is set to "yes" in the XML declaration, setting this to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   104
a true value allows the external DTD to be read, and parameter entities
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   105
to be parsed and expanded.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   106
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   107
=item * Base
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   108
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   109
The base to use for relative pathnames or URLs. This can also be done by
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   110
using the base method.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   111
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   112
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   113
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   114
=item setHandlers(TYPE, HANDLER [, TYPE, HANDLER [...]])
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   115
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   116
This method registers handlers for the various events. If no handlers are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   117
registered, then a call to parsestring or parsefile will only determine if
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   118
the corresponding XML document is well formed (by returning without error.)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   119
This may be called from within a handler, after the parse has started.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   120
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   121
Setting a handler to something that evaluates to false unsets that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   122
handler.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   123
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   124
This method returns a list of type, handler pairs corresponding to the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   125
input. The handlers returned are the ones that were in effect before the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   126
call to setHandlers.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   127
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   128
The recognized events and the parameters passed to the corresponding
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   129
handlers are:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   130
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   131
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   132
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   133
=item * Start		(Parser, Element [, Attr, Val [,...]])
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   134
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   135
This event is generated when an XML start tag is recognized. Parser is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   136
an XML::Parser::Expat instance. Element is the name of the XML element that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   137
is opened with the start tag. The Attr & Val pairs are generated for each
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   138
attribute in the start tag.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   139
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   140
=item * End		(Parser, Element)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   141
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   142
This event is generated when an XML end tag is recognized. Note that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   143
an XML empty tag (<foo/>) generates both a start and an end event.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   144
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   145
There is always a lower level start and end handler installed that wrap
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   146
the corresponding callbacks. This is to handle the context mechanism.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   147
A consequence of this is that the default handler (see below) will not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   148
see a start tag or end tag unless the default_current method is called.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   149
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   150
=item * Char		(Parser, String)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   151
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   152
This event is generated when non-markup is recognized. The non-markup
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   153
sequence of characters is in String. A single non-markup sequence of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   154
characters may generate multiple calls to this handler. Whatever the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   155
encoding of the string in the original document, this is given to the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   156
handler in UTF-8.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   157
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   158
=item * Proc		(Parser, Target, Data)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   159
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   160
This event is generated when a processing instruction is recognized.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   161
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   162
=item * Comment		(Parser, String)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   163
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   164
This event is generated when a comment is recognized.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   165
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   166
=item * CdataStart	(Parser)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   167
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   168
This is called at the start of a CDATA section.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   169
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   170
=item * CdataEnd	(Parser)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   171
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   172
This is called at the end of a CDATA section.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   173
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   174
=item * Default		(Parser, String)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   175
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   176
This is called for any characters that don't have a registered handler.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   177
This includes both characters that are part of markup for which no
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   178
events are generated (markup declarations) and characters that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   179
could generate events, but for which no handler has been registered.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   180
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   181
Whatever the encoding in the original document, the string is returned to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   182
the handler in UTF-8.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   183
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   184
=item * Unparsed		(Parser, Entity, Base, Sysid, Pubid, Notation)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   185
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   186
This is called for a declaration of an unparsed entity. Entity is the name
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   187
of the entity. Base is the base to be used for resolving a relative URI.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   188
Sysid is the system id. Pubid is the public id. Notation is the notation
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   189
name. Base and Pubid may be undefined.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   190
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   191
=item * Notation		(Parser, Notation, Base, Sysid, Pubid)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   192
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   193
This is called for a declaration of notation. Notation is the notation name.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   194
Base is the base to be used for resolving a relative URI. Sysid is the system
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   195
id. Pubid is the public id. Base, Sysid, and Pubid may all be undefined.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   196
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   197
=item * ExternEnt		(Parser, Base, Sysid, Pubid)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   198
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   199
This is called when an external entity is referenced. Base is the base to be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   200
used for resolving a relative URI. Sysid is the system id. Pubid is the public
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   201
id. Base, and Pubid may be undefined.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   202
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   203
This handler should either return a string, which represents the contents of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   204
the external entity, or return an open filehandle that can be read to obtain
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   205
the contents of the external entity, or return undef, which indicates the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   206
external entity couldn't be found and will generate a parse error.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   207
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   208
If an open filehandle is returned, it must be returned as either a glob
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   209
(*FOO) or as a reference to a glob (e.g. an instance of IO::Handle). The
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   210
parser will close the filehandle after using it.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   211
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   212
=item * Entity			(Parser, Name, Val, Sysid, Pubid, Ndata)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   213
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   214
This is called when an entity is declared. For internal entities, the Val
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   215
parameter will contain the value and the remaining three parameters will
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   216
be undefined. For external entities, the Val parameter
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   217
will be undefined, the Sysid parameter will have the system id, the Pubid
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   218
parameter will have the public id if it was provided (it will be undefined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   219
otherwise), the Ndata parameter will contain the notation for unparsed
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   220
entities. If this is a parameter entity declaration, then a '%' will be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   221
prefixed to the name.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   222
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   223
Note that this handler and the Unparsed handler above overlap. If both are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   224
set, then this handler will not be called for unparsed entities.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   225
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   226
=item * Element			(Parser, Name, Model)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   227
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   228
The element handler is called when an element declaration is found. Name is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   229
the element name, and Model is the content model as a string.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   230
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   231
=item * Attlist			(Parser, Elname, Attname, Type, Default, Fixed)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   232
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   233
This handler is called for each attribute in an ATTLIST declaration.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   234
So an ATTLIST declaration that has multiple attributes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   235
will generate multiple calls to this handler. The Elname parameter is the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   236
name of the element with which the attribute is being associated. The Attname
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   237
parameter is the name of the attribute. Type is the attribute type, given as
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   238
a string. Default is the default value, which will either be "#REQUIRED",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   239
"#IMPLIED" or a quoted string (i.e. the returned string will begin and end
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   240
with a quote character). If Fixed is true, then this is a fixed attribute.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   241
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   242
=item * Doctype			(Parser, Name, Sysid, Pubid, Internal)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   243
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   244
This handler is called for DOCTYPE declarations. Name is the document type
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   245
name. Sysid is the system id of the document type, if it was provided,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   246
otherwise it's undefined. Pubid is the public id of the document type,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   247
which will be undefined if no public id was given. Internal is the internal
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   248
subset, given as a string. If there was no internal subset, it will be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   249
undefined. Internal will contain all whitespace, comments, processing
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   250
instructions, and declarations seen in the internal subset. The declarations
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   251
will be there whether or not they have been processed by another handler
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   252
(except for unparsed entities processed by the Unparsed handler). However,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   253
comments and processing instructions will not appear if they've been processed
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   254
by their respective handlers.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   255
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   256
=item * XMLDecl			(Parser, Version, Encoding, Standalone)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   257
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   258
This handler is called for xml declarations. Version is a string containg
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   259
the version. Encoding is either undefined or contains an encoding string.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   260
Standalone will be either true, false, or undefined if the standalone attribute
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   261
is yes, no, or not made respectively.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   262
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   263
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   264
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   265
=item namespace(name)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   266
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   267
Return the URI of the namespace that the name belongs to. If the name doesn't
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   268
belong to any namespace, an undef is returned. This is only valid on names
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   269
received through the Start or End handlers from a single document, or through
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   270
a call to the generate_ns_name method. In other words, don't use names
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   271
generated from one instance of XML::Parser::Expat with other instances.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   272
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   273
=item eq_name(name1, name2)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   274
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   275
Return true if name1 and name2 are identical (i.e. same name and from
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   276
the same namespace.) This is only meaningful if both names were obtained
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   277
through the Start or End handlers from a single document, or through
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   278
a call to the generate_ns_name method.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   279
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   280
=item generate_ns_name(name, namespace)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   281
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   282
Return a name, associated with a given namespace, good for using with the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   283
above 2 methods. The namespace argument should be the namespace URI, not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   284
a prefix.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   285
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   286
=item new_ns_prefixes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   287
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   288
When called from a start tag handler, returns namespace prefixes declared
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   289
with this start tag. If called elsewere (or if there were no namespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   290
prefixes declared), it returns an empty list. Setting of the default
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   291
namespace is indicated with '#default' as a prefix.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   292
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   293
=item expand_ns_prefix(prefix)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   294
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   295
Return the uri to which the given prefix is currently bound. Returns
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   296
undef if the prefix isn't currently bound. Use '#default' to find the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   297
current binding of the default namespace (if any).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   298
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   299
=item current_ns_prefixes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   300
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   301
Return a list of currently bound namespace prefixes. The order of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   302
the prefixes in the list has no meaning. If the default namespace is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   303
currently bound, '#default' appears in the list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   304
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   305
=item recognized_string
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   306
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   307
Returns the string from the document that was recognized in order to call
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   308
the current handler. For instance, when called from a start handler, it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   309
will give us the the start-tag string. The string is encoded in UTF-8.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   310
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   311
=item original_string
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   312
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   313
Returns the verbatim string from the document that was recognized in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   314
order to call the current handler. The string is in the original document
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   315
encoding.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   316
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   317
=item default_current
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   318
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   319
When called from a handler, causes the sequence of characters that generated
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   320
the corresponding event to be sent to the default handler (if one is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   321
registered). Use of this method is deprecated in favor the recognized_string
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   322
method, which you can use without installing a default handler.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   323
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   324
=item xpcroak(message)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   325
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   326
Concatenate onto the given message the current line number within the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   327
XML document plus the message implied by ErrorContext. Then croak with
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   328
the formed message.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   329
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   330
=item xpcarp(message)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   331
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   332
Concatenate onto the given message the current line number within the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   333
XML document plus the message implied by ErrorContext. Then carp with
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   334
the formed message.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   335
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   336
=item current_line
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   337
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   338
Returns the line number of the current position of the parse.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   339
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   340
=item current_column
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   341
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   342
Returns the column number of the current position of the parse.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   343
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   344
=item current_byte
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   345
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   346
Returns the current position of the parse.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   347
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   348
=item base([NEWBASE]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   349
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   350
Returns the current value of the base for resolving relative URIs. If
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   351
NEWBASE is supplied, changes the base to that value.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   352
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   353
=item context
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   354
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   355
Returns a list of element names that represent open elements, with the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   356
last one being the innermost. Inside start and end tag handlers, this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   357
will be the tag of the parent element.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   358
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   359
=item current_element
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   360
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   361
Returns the name of the innermost currently opened element. Inside
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   362
start or end handlers, returns the parent of the element associated
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   363
with those tags.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   364
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   365
=item in_element(NAME)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   366
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   367
Returns true if NAME is equal to the name of the innermost currently opened
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   368
element. If namespace processing is being used and you want to check
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   369
against a name that may be in a namespace, then use the generate_ns_name
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   370
method to create the NAME argument.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   371
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   372
=item within_element(NAME)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   373
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   374
Returns the number of times the given name appears in the context list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   375
If namespace processing is being used and you want to check
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   376
against a name that may be in a namespace, then use the generate_ns_name
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   377
method to create the NAME argument.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   378
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   379
=item depth
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   380
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   381
Returns the size of the context list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   382
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   383
=item element_index
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   384
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   385
Returns an integer that is the depth-first visit order of the current
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   386
element. This will be zero outside of the root element. For example,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   387
this will return 1 when called from the start handler for the root element
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   388
start tag.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   389
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   390
=item skip_until(INDEX)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   391
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   392
INDEX is an integer that represents an element index. When this method
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   393
is called, all handlers are suspended until the start tag for an element
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   394
that has an index number equal to INDEX is seen. If a start handler has
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   395
been set, then this is the first tag that the start handler will see
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   396
after skip_until has been called.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   397
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   398
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   399
=item position_in_context(LINES)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   400
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   401
Returns a string that shows the current parse position. LINES should be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   402
an integer >= 0 that represents the number of lines on either side of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   403
current parse line to place into the returned string.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   404
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   405
=item xml_escape(TEXT [, CHAR [, CHAR ...]])
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   406
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   407
Returns TEXT with markup characters turned into character entities. Any
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   408
additional characters provided as arguments are also turned into character
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   409
references where found in TEXT.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   410
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   411
=item parse (SOURCE)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   412
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   413
The SOURCE parameter should either be a string containing the whole XML
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   414
document, or it should be an open IO::Handle. Only a single document
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   415
may be parsed for a given instance of XML::Parser::Expat, so this will croak
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   416
if it's been called previously for this instance.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   417
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   418
=item parsestring(XML_DOC_STRING)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   419
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   420
Parses the given string as an XML document. Only a single document may be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   421
parsed for a given instance of XML::Parser::Expat, so this will die if either
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   422
parsestring or parsefile has been called for this instance previously.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   423
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   424
This method is deprecated in favor of the parse method.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   425
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   426
=item parsefile(FILENAME)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   427
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   428
Parses the XML document in the given file. Will die if parsestring or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   429
parsefile has been called previously for this instance.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   430
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   431
=item is_defaulted(ATTNAME)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   432
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   433
NO LONGER WORKS. To find out if an attribute is defaulted please use
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   434
the specified_attr method.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   435
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   436
=item specified_attr
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   437
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   438
When the start handler receives lists of attributes and values, the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   439
non-defaulted (i.e. explicitly specified) attributes occur in the list
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   440
first. This method returns the number of specified items in the list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   441
So if this number is equal to the length of the list, there were no
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   442
defaulted values. Otherwise the number points to the index of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   443
first defaulted attribute name.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   444
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   445
=item finish
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   446
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   447
Unsets all handlers (including internal ones that set context), but expat
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   448
continues parsing to the end of the document or until it finds an error.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   449
It should finish up a lot faster than with the handlers set.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   450
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   451
=item release
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   452
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   453
There are data structures used by XML::Parser::Expat that have circular
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   454
references. This means that these structures will never be garbage
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   455
collected unless these references are explicitly broken. Calling this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   456
method breaks those references (and makes the instance unusable.)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   457
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   458
Normally, higher level calls handle this for you, but if you are using
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   459
XML::Parser::Expat directly, then it's your responsibility to call it.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   460
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   461
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   462
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   463
=head2 XML::Parser::ExpatNB Methods
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   464
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   465
The class XML::Parser::ExpatNB is a subclass of XML::Parser::Expat used
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   466
for non-blocking access to the expat library. It does not support the parse,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   467
parsestring, or parsefile methods, but it does have these additional methods:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   468
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   469
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   470
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   471
=item parse_more(DATA)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   472
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   473
Feed expat more text to munch on.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   474
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   475
=item parse_done
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   476
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   477
Tell expat that it's gotten the whole document.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   478
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   479
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   480
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   481
=head1 FUNCTIONS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   482
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   483
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   484
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   485
=item XML::Parser::Expat::load_encoding(ENCODING)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   486
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   487
Load an external encoding. ENCODING is either the name of an encoding or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   488
the name of a file. The basename is converted to lowercase and a '.enc'
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   489
extension is appended unless there's one already there. Then, unless
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   490
it's an absolute pathname (i.e. begins with '/'), the first file by that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   491
name discovered in the @Encoding_Path path list is used.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   492
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   493
The encoding in the file is loaded and kept in the %Encoding_Table
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   494
table. Earlier encodings of the same name are replaced.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   495
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   496
This function is automaticly called by expat when it encounters an encoding
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   497
it doesn't know about. Expat shouldn't call this twice for the same
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   498
encoding name. The only reason users should use this function is to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   499
explicitly load an encoding not contained in the @Encoding_Path list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   500
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   501
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   502
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   503
=head1 AUTHORS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   504
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   505
Larry Wall <F<larry@wall.org>> wrote version 1.0.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   506
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   507
Clark Cooper <F<coopercc@netheaven.com>> picked up support, changed the API
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   508
for this version (2.x), provided documentation, and added some standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   509
package features.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   510
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   511
=cut