1XML::SAX2Perl(3) User Contributed Perl Documentation XML::SAX2Perl(3)
2
3
4
6 XML::SAX2Perl -- translate Java/CORBA style SAX methods to Perl methods
7
9 use XML::SAX2Perl;
10
11 $sax2perl = XML::SAX2Perl(Handler => $my_handler);
12 $sax->setDocumentHandler($sax2perl);
13
15 "XML::SAX2Perl" is a SAX filter that translates Java/CORBA style SAX
16 methods to Perl style method calls. This man page summarizes the spe‐
17 cific options, handlers, and properties supported by "XML::SAX2Perl";
18 please refer to the Perl SAX standard "XML::SAX" for general usage
19 information.
20
22 new Creates a new parser object. Default options for parsing,
23 described below, are passed as key-value pairs or as a single hash.
24 Options may be changed directly in the parser object unless stated
25 otherwise. Options passed to `"parse()"' override the default
26 options in the parser object for the duration of the parse.
27
28 parse
29 Parses a document. Options, described below, are passed as key-
30 value pairs or as a single hash. Options passed to `"parse()"'
31 override default options in the parser object.
32
33 location
34 Returns the location as a hash:
35
36 ColumnNumber The column number of the parse.
37 LineNumber The line number of the parse.
38 PublicId A string containing the public identifier, or undef
39 if none is available.
40 SystemId A string containing the system identifier, or undef
41 if none is available.
42
43 SAX DocumentHandler Methods
44 The following methods are DocumentHandler methods that the SAX 1.0
45 parser will call and "XML::SAX2Perl" will translate to Perl SAX
46 methods calls. See SAX 1.0 for details.
47
48 setDocumentLocator(locator)
49 startDocument()
50 endDocument()
51 startElement(name, atts)
52 endElement(name)
53 characters(ch, start, length)
54 ignorableWhitespace(ch, start, length)
55 processingInstruction(target, data)
56
58 The following options are supported by "XML::SAX2Perl":
59
60 Handler default handler to receive events
61 DocumentHandler handler to receive document events
62 DTDHandler handler to receive DTD events
63 ErrorHandler handler to receive error events
64 EntityResolver handler to resolve entities
65 Locale locale to provide localisation for errors
66 Source hash containing the input source for parsing
67
68 If no handlers are provided then all events will be silently ignored,
69 except for `"fatal_error()"' which will cause a `"die()"' to be called
70 after calling `"end_document()"'.
71
72 If a single string argument is passed to the `"parse()"' method, it is
73 treated as if a `"Source"' option was given with a `"String"' parame‐
74 ter.
75
76 The `"Source"' hash may contain the following parameters:
77
78 ByteStream The raw byte stream (file handle) containing the
79 document.
80 String A string containing the document.
81 SystemId The system identifier (URI) of the document.
82 PublicId The public identifier.
83 Encoding A string describing the character encoding.
84
85 If more than one of `"ByteStream"', `"String"', or `"SystemId"', then
86 preference is given first to `"ByteStream"', then `"String"', then
87 `"SystemId"'.
88
90 The following handlers and properties are supported by "XML::SAX2Perl":
91
92 DocumentHandler methods
93
94 start_document
95 Receive notification of the beginning of a document.
96
97 Locator An object that can return the location of any SAX
98 document event.
99
100 end_document
101 Receive notification of the end of a document.
102
103 No properties defined.
104
105 start_element
106 Receive notification of the beginning of an element.
107
108 Name The element type name.
109 Attributes Attributes attached to the element, if any.
110
111 ALPHA WARNING: The `"Attributes"' value is not translated from the
112 SAX 1.0 value, so it will contain an AttributeList object.
113
114 end_element
115 Receive notification of the end of an element.
116
117 Name The element type name.
118
119 characters
120 Receive notification of character data.
121
122 Data The characters from the XML document.
123
124 ignorable_whitespace
125 Receive notification of ignorable whitespace in element content.
126
127 Data The characters from the XML document.
128
129 processing_instruction
130 Receive notification of a processing instruction.
131
132 Target The processing instruction target.
133 Data The processing instruction data, if any.
134
136 Ken MacLeod <ken@bitsko.slc.ut.us>
137
139 perl(1), XML::Perl2SAX(3).
140
141 Extensible Markup Language (XML) <http://www.w3c.org/XML/>
142 Simple API for XML (SAX) <http://www.megginson.com/SAX/>
143
144
145
146perl v5.8.8 2003-10-21 XML::SAX2Perl(3)