summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/cygwin/lib/perl5/vendor_perl/5.10/i686-cygwin/XML/LibXML/Common.pm
blob: 4c571ad861f118819501d8ca4c960dcbb378b430 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
#-------------------------------------------------------------------------#
# $Id: Common.pm,v 1.5 2003/02/27 18:32:59 phish108 Exp $
#-------------------------------------------------------------------------#
package XML::LibXML::Common;

#-------------------------------------------------------------------------#
# global blur                                                             #
#-------------------------------------------------------------------------#
use strict;

require Exporter;
require DynaLoader;
use vars qw( @ISA $VERSION @EXPORT @EXPORT_OK %EXPORT_TAGS);

@ISA = qw(DynaLoader Exporter);

$VERSION = '0.13';

bootstrap XML::LibXML::Common $VERSION;

#-------------------------------------------------------------------------#
# export information                                                      #
#-------------------------------------------------------------------------#
%EXPORT_TAGS = (
                all => [qw(
                           ELEMENT_NODE
                           ATTRIBUTE_NODE
                           TEXT_NODE
                           CDATA_SECTION_NODE
                           ENTITY_REFERENCE_NODE
                           ENTITY_NODE
                           PI_NODE
                           PROCESSING_INSTRUCTION_NODE
                           COMMENT_NODE
                           DOCUMENT_NODE
                           DOCUMENT_TYPE_NODE
                           DOCUMENT_FRAG_NODE
                           DOCUMENT_FRAGMENT_NODE
                           NOTATION_NODE
                           HTML_DOCUMENT_NODE
                           DTD_NODE
                           ELEMENT_DECLARATION
                           ATTRIBUTE_DECLARATION
                           ENTITY_DECLARATION
                           NAMESPACE_DECLARATION
                           XINCLUDE_END
                           XINCLUDE_START
                           encodeToUTF8
                           decodeFromUTF8
                          )],
                w3c => [qw(
                           ELEMENT_NODE
                           ATTRIBUTE_NODE
                           TEXT_NODE
                           CDATA_SECTION_NODE
                           ENTITY_REFERENCE_NODE
                           ENTITY_NODE
                           PI_NODE
                           PROCESSING_INSTRUCTION_NODE
                           COMMENT_NODE
                           DOCUMENT_NODE
                           DOCUMENT_TYPE_NODE
                           DOCUMENT_FRAG_NODE
                           DOCUMENT_FRAGMENT_NODE
                           NOTATION_NODE
                           HTML_DOCUMENT_NODE
                           DTD_NODE
                           ELEMENT_DECLARATION
                           ATTRIBUTE_DECLARATION
                           ENTITY_DECLARATION
                           NAMESPACE_DECLARATION
                           XINCLUDE_END
                           XINCLUDE_START
                          )],
                libxml => [qw(
                           XML_ELEMENT_NODE
                           XML_ATTRIBUTE_NODE
                           XML_TEXT_NODE
                           XML_CDATA_SECTION_NODE
                           XML_ENTITY_REF_NODE
                           XML_ENTITY_NODE
                           XML_PI_NODE
                           XML_COMMENT_NODE
                           XML_DOCUMENT_NODE
                           XML_DOCUMENT_TYPE_NODE
                           XML_DOCUMENT_FRAG_NODE
                           XML_NOTATION_NODE
                           XML_HTML_DOCUMENT_NODE
                           XML_DTD_NODE
                           XML_ELEMENT_DECL
                           XML_ATTRIBUTE_DECL
                           XML_ENTITY_DECL
                           XML_NAMESPACE_DECL
                           XML_XINCLUDE_END
                           XML_XINCLUDE_START
                          )],
                gdome => [qw(
                           GDOME_ELEMENT_NODE
                           GDOME_ATTRIBUTE_NODE
                           GDOME_TEXT_NODE
                           GDOME_CDATA_SECTION_NODE
                           GDOME_ENTITY_REF_NODE
                           GDOME_ENTITY_NODE
                           GDOME_PI_NODE
                           GDOME_COMMENT_NODE
                           GDOME_DOCUMENT_NODE
                           GDOME_DOCUMENT_TYPE_NODE
                           GDOME_DOCUMENT_FRAG_NODE
                           GDOME_NOTATION_NODE
                           GDOME_HTML_DOCUMENT_NODE
                           GDOME_DTD_NODE
                           GDOME_ELEMENT_DECL
                           GDOME_ATTRIBUTE_DECL
                           GDOME_ENTITY_DECL
                           GDOME_NAMESPACE_DECL
                           GDOME_XINCLUDE_END
                           GDOME_XINCLUDE_START
                          )],
                encoding => [qw(
                                encodeToUTF8
                                decodeFromUTF8
                               )],
               );

@EXPORT_OK = (
              @{$EXPORT_TAGS{encoding}},
              @{$EXPORT_TAGS{w3c}},
              @{$EXPORT_TAGS{libxml}},
              @{$EXPORT_TAGS{gdome}},
             );

@EXPORT = (
           @{$EXPORT_TAGS{encoding}},
           @{$EXPORT_TAGS{w3c}},
          );

#-------------------------------------------------------------------------#
# W3 conform node types                                                   #
#-------------------------------------------------------------------------#
use constant ELEMENT_NODE                => 1;
use constant ATTRIBUTE_NODE              => 2;
use constant TEXT_NODE                   => 3;
use constant CDATA_SECTION_NODE          => 4;
use constant ENTITY_REFERENCE_NODE       => 5;
use constant ENTITY_NODE                 => 6;
use constant PROCESSING_INSTRUCTION_NODE => 7;
use constant COMMENT_NODE                => 8;
use constant DOCUMENT_NODE               => 9;
use constant DOCUMENT_TYPE_NODE          => 10;
use constant DOCUMENT_FRAGMENT_NODE      => 11;
use constant NOTATION_NODE               => 12;
use constant HTML_DOCUMENT_NODE          => 13;
use constant DTD_NODE                    => 14;
use constant ELEMENT_DECLARATION         => 15;
use constant ATTRIBUTE_DECLARATION       => 16;
use constant ENTITY_DECLARATION          => 17;
use constant NAMESPACE_DECLARATION       => 18;

#-------------------------------------------------------------------------#
# some extras for the W3 spec
#-------------------------------------------------------------------------#
use constant PI_NODE                     => 7;
use constant DOCUMENT_FRAG_NODE          => 11;
use constant XINCLUDE_END                => 19;
use constant XINCLUDE_START              => 20;

#-------------------------------------------------------------------------#
# libxml2 compat names                                                    #
#-------------------------------------------------------------------------#
use constant XML_ELEMENT_NODE            => 1;
use constant XML_ATTRIBUTE_NODE          => 2;
use constant XML_TEXT_NODE               => 3;
use constant XML_CDATA_SECTION_NODE      => 4;
use constant XML_ENTITY_REF_NODE         => 5;
use constant XML_ENTITY_NODE             => 6;
use constant XML_PI_NODE                 => 7;
use constant XML_COMMENT_NODE            => 8;
use constant XML_DOCUMENT_NODE           => 9;
use constant XML_DOCUMENT_TYPE_NODE      => 10;
use constant XML_DOCUMENT_FRAG_NODE      => 11;
use constant XML_NOTATION_NODE           => 12;
use constant XML_HTML_DOCUMENT_NODE      => 13;
use constant XML_DTD_NODE                => 14;
use constant XML_ELEMENT_DECL            => 15;
use constant XML_ATTRIBUTE_DECL          => 16;
use constant XML_ENTITY_DECL             => 17;
use constant XML_NAMESPACE_DECL          => 18;
use constant XML_XINCLUDE_START          => 19;
use constant XML_XINCLUDE_END            => 20;

#-------------------------------------------------------------------------#
# libgdome compat names                                                   #
#-------------------------------------------------------------------------#
use constant GDOME_ELEMENT_NODE          => 1;
use constant GDOME_ATTRIBUTE_NODE        => 2;
use constant GDOME_TEXT_NODE             => 3;
use constant GDOME_CDATA_SECTION_NODE    => 4;
use constant GDOME_ENTITY_REF_NODE       => 5;
use constant GDOME_ENTITY_NODE           => 6;
use constant GDOME_PI_NODE               => 7;
use constant GDOME_COMMENT_NODE          => 8;
use constant GDOME_DOCUMENT_NODE         => 9;
use constant GDOME_DOCUMENT_TYPE_NODE    => 10;
use constant GDOME_DOCUMENT_FRAG_NODE    => 11;
use constant GDOME_NOTATION_NODE         => 12;
use constant GDOME_HTML_DOCUMENT_NODE    => 13;
use constant GDOME_DTD_NODE              => 14;
use constant GDOME_ELEMENT_DECL          => 15;
use constant GDOME_ATTRIBUTE_DECL        => 16;
use constant GDOME_ENTITY_DECL           => 17;
use constant GDOME_NAMESPACE_DECL        => 18;
use constant GDOME_XINCLUDE_START        => 19;
use constant GDOME_XINCLUDE_END          => 20;

1;
#-------------------------------------------------------------------------#
__END__

=head1 NAME

XML::LibXML::Common - Routines and Constants common for XML::LibXML and XML::GDOME

=head1 SYNOPSIS

  use XML::LibXML::Common;

=head1 DESCRIPTION

XML::LibXML and XML::GDOME share some of the same functionality. This
package should bundle some shared constansts and functions, so both
modules may coexist within the same scripts.

XML::LibXML::Common defines all node types as constants. While
XML::LibXML and XML::GDOME originally declared their own node type
definitions, one may want to use XML::LibXML::Common in its
compatibility mode:

=over 4

=item * use XML::LibXML::Common qw(:libxml);

:libxml will use the XML::LibXML Compatibility mode, which defines the
old 'XML_' node-type definitions

=item * use XML::LibXML::Common qw(:gdome);

This allows one to use the XML::LibXML Compatibility mode, which
defines the old 'GDOME_' node-type definitions

=item * use XML::LibXML::Common qw(:w3c);

This uses the nodetype definition names as specified for DOM.

=item * use XML::LibXML::Common qw(:encoding);

This is ment if only the encoding functions of XML::LibXML::Common
should be used.

=back

By default the W3 definitions as defined in the DOM specifications and
the encoding functions are exported by XML::LibXML::Common.

=head2 encoding functions

To encode or decode a string to or from UTF-8 XML::LibXML::Common exports
two functions, which use the encoding mechanism of the underlaying
implementation. These functions should be used, if external encoding
is required (e.g. for queryfunctions).

=head2 encodeToUTF8

    $encodedstring = encodeToUTF8( $name_of_encoding, $sting_to_encode );

The function will encode a string from the specified encoding to UTF-8.

=head2 decodeFromUTF8

    $decodedstring = decodeFromUTF8($name_of_encoding, $string_to_decode );

This Function transforms an UTF-8 encoded string the specified
encoding.  While transforms to ISO encodings may cause errors if the
given stirng contains unsupported characters, both functions can
transform to UTF-16 encodings as well.

Note that both encoding functions report their errors on the standard
error. If an error occours the function will croak(). To catch the
error information it is required to call the encoding function from
within an eval block to avoid a script to stop.

=head1 AUTHOR

Christian Glahn, (christian.glahn@uibk.ac.at) Innsbruck University

=head1 COPYRIGHT

(c) 2002 Christian Glahn. All rights reserved. 

This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 SEE ALSO

L<perl>, L<XML::LibXML>, L<XML::GDOME>

=cut