| File | /usr/lib/perl5/XML/LibXML/Common.pm |
| Statements Executed | 201 |
| Total Time | 0.0022096 seconds |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2 | 1 | 2 | 48µs | 48µs | XML::LibXML::Common::bootstrap(xsub) |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Common::BEGIN |
| Line | Stmts. | Exclusive Time | Avg. | Code |
|---|---|---|---|---|
| 1 | #-------------------------------------------------------------------------# | |||
| 2 | # $Id: Common.pm,v 1.5 2003/02/27 18:32:59 phish108 Exp $ | |||
| 3 | #-------------------------------------------------------------------------# | |||
| 4 | package XML::LibXML::Common; | |||
| 5 | ||||
| 6 | #-------------------------------------------------------------------------# | |||
| 7 | # global blur # | |||
| 8 | #-------------------------------------------------------------------------# | |||
| 9 | 3 | 41µs | 14µs | use strict; # spent 7µs making 1 call to strict::import |
| 10 | ||||
| 11 | 1 | 800ns | 800ns | require Exporter; |
| 12 | 1 | 8µs | 8µs | require DynaLoader; |
| 13 | 3 | 281µs | 94µs | use vars qw( @ISA $VERSION @EXPORT @EXPORT_OK %EXPORT_TAGS); # spent 74µs making 1 call to vars::import |
| 14 | ||||
| 15 | 1 | 12µs | 12µs | @ISA = qw(DynaLoader Exporter); |
| 16 | ||||
| 17 | 1 | 600ns | 600ns | $VERSION = '0.13'; |
| 18 | ||||
| 19 | 1 | 14µs | 14µs | bootstrap XML::LibXML::Common $VERSION; # spent 546µs making 1 call to DynaLoader::bootstrap |
| 20 | ||||
| 21 | #-------------------------------------------------------------------------# | |||
| 22 | # export information # | |||
| 23 | #-------------------------------------------------------------------------# | |||
| 24 | 1 | 32µs | 32µs | %EXPORT_TAGS = ( |
| 25 | all => [qw( | |||
| 26 | ELEMENT_NODE | |||
| 27 | ATTRIBUTE_NODE | |||
| 28 | TEXT_NODE | |||
| 29 | CDATA_SECTION_NODE | |||
| 30 | ENTITY_REFERENCE_NODE | |||
| 31 | ENTITY_NODE | |||
| 32 | PI_NODE | |||
| 33 | PROCESSING_INSTRUCTION_NODE | |||
| 34 | COMMENT_NODE | |||
| 35 | DOCUMENT_NODE | |||
| 36 | DOCUMENT_TYPE_NODE | |||
| 37 | DOCUMENT_FRAG_NODE | |||
| 38 | DOCUMENT_FRAGMENT_NODE | |||
| 39 | NOTATION_NODE | |||
| 40 | HTML_DOCUMENT_NODE | |||
| 41 | DTD_NODE | |||
| 42 | ELEMENT_DECLARATION | |||
| 43 | ATTRIBUTE_DECLARATION | |||
| 44 | ENTITY_DECLARATION | |||
| 45 | NAMESPACE_DECLARATION | |||
| 46 | XINCLUDE_END | |||
| 47 | XINCLUDE_START | |||
| 48 | encodeToUTF8 | |||
| 49 | decodeFromUTF8 | |||
| 50 | )], | |||
| 51 | w3c => [qw( | |||
| 52 | ELEMENT_NODE | |||
| 53 | ATTRIBUTE_NODE | |||
| 54 | TEXT_NODE | |||
| 55 | CDATA_SECTION_NODE | |||
| 56 | ENTITY_REFERENCE_NODE | |||
| 57 | ENTITY_NODE | |||
| 58 | PI_NODE | |||
| 59 | PROCESSING_INSTRUCTION_NODE | |||
| 60 | COMMENT_NODE | |||
| 61 | DOCUMENT_NODE | |||
| 62 | DOCUMENT_TYPE_NODE | |||
| 63 | DOCUMENT_FRAG_NODE | |||
| 64 | DOCUMENT_FRAGMENT_NODE | |||
| 65 | NOTATION_NODE | |||
| 66 | HTML_DOCUMENT_NODE | |||
| 67 | DTD_NODE | |||
| 68 | ELEMENT_DECLARATION | |||
| 69 | ATTRIBUTE_DECLARATION | |||
| 70 | ENTITY_DECLARATION | |||
| 71 | NAMESPACE_DECLARATION | |||
| 72 | XINCLUDE_END | |||
| 73 | XINCLUDE_START | |||
| 74 | )], | |||
| 75 | libxml => [qw( | |||
| 76 | XML_ELEMENT_NODE | |||
| 77 | XML_ATTRIBUTE_NODE | |||
| 78 | XML_TEXT_NODE | |||
| 79 | XML_CDATA_SECTION_NODE | |||
| 80 | XML_ENTITY_REF_NODE | |||
| 81 | XML_ENTITY_NODE | |||
| 82 | XML_PI_NODE | |||
| 83 | XML_COMMENT_NODE | |||
| 84 | XML_DOCUMENT_NODE | |||
| 85 | XML_DOCUMENT_TYPE_NODE | |||
| 86 | XML_DOCUMENT_FRAG_NODE | |||
| 87 | XML_NOTATION_NODE | |||
| 88 | XML_HTML_DOCUMENT_NODE | |||
| 89 | XML_DTD_NODE | |||
| 90 | XML_ELEMENT_DECL | |||
| 91 | XML_ATTRIBUTE_DECL | |||
| 92 | XML_ENTITY_DECL | |||
| 93 | XML_NAMESPACE_DECL | |||
| 94 | XML_XINCLUDE_END | |||
| 95 | XML_XINCLUDE_START | |||
| 96 | )], | |||
| 97 | gdome => [qw( | |||
| 98 | GDOME_ELEMENT_NODE | |||
| 99 | GDOME_ATTRIBUTE_NODE | |||
| 100 | GDOME_TEXT_NODE | |||
| 101 | GDOME_CDATA_SECTION_NODE | |||
| 102 | GDOME_ENTITY_REF_NODE | |||
| 103 | GDOME_ENTITY_NODE | |||
| 104 | GDOME_PI_NODE | |||
| 105 | GDOME_COMMENT_NODE | |||
| 106 | GDOME_DOCUMENT_NODE | |||
| 107 | GDOME_DOCUMENT_TYPE_NODE | |||
| 108 | GDOME_DOCUMENT_FRAG_NODE | |||
| 109 | GDOME_NOTATION_NODE | |||
| 110 | GDOME_HTML_DOCUMENT_NODE | |||
| 111 | GDOME_DTD_NODE | |||
| 112 | GDOME_ELEMENT_DECL | |||
| 113 | GDOME_ATTRIBUTE_DECL | |||
| 114 | GDOME_ENTITY_DECL | |||
| 115 | GDOME_NAMESPACE_DECL | |||
| 116 | GDOME_XINCLUDE_END | |||
| 117 | GDOME_XINCLUDE_START | |||
| 118 | )], | |||
| 119 | encoding => [qw( | |||
| 120 | encodeToUTF8 | |||
| 121 | decodeFromUTF8 | |||
| 122 | )], | |||
| 123 | ); | |||
| 124 | ||||
| 125 | @EXPORT_OK = ( | |||
| 126 | @{$EXPORT_TAGS{encoding}}, | |||
| 127 | @{$EXPORT_TAGS{w3c}}, | |||
| 128 | @{$EXPORT_TAGS{libxml}}, | |||
| 129 | 1 | 31µs | 31µs | @{$EXPORT_TAGS{gdome}}, |
| 130 | ); | |||
| 131 | ||||
| 132 | @EXPORT = ( | |||
| 133 | @{$EXPORT_TAGS{encoding}}, | |||
| 134 | 1 | 10µs | 10µs | @{$EXPORT_TAGS{w3c}}, |
| 135 | ); | |||
| 136 | ||||
| 137 | #-------------------------------------------------------------------------# | |||
| 138 | # W3 conform node types # | |||
| 139 | #-------------------------------------------------------------------------# | |||
| 140 | 3 | 30µs | 10µs | use constant ELEMENT_NODE => 1; # spent 54µs making 1 call to constant::import |
| 141 | 3 | 28µs | 9µs | use constant ATTRIBUTE_NODE => 2; # spent 38µs making 1 call to constant::import |
| 142 | 3 | 24µs | 8µs | use constant TEXT_NODE => 3; # spent 42µs making 1 call to constant::import |
| 143 | 3 | 28µs | 9µs | use constant CDATA_SECTION_NODE => 4; # spent 42µs making 1 call to constant::import |
| 144 | 3 | 28µs | 9µs | use constant ENTITY_REFERENCE_NODE => 5; # spent 43µs making 1 call to constant::import |
| 145 | 3 | 28µs | 9µs | use constant ENTITY_NODE => 6; # spent 42µs making 1 call to constant::import |
| 146 | 3 | 23µs | 8µs | use constant PROCESSING_INSTRUCTION_NODE => 7; # spent 45µs making 1 call to constant::import |
| 147 | 3 | 28µs | 9µs | use constant COMMENT_NODE => 8; # spent 42µs making 1 call to constant::import |
| 148 | 3 | 28µs | 9µs | use constant DOCUMENT_NODE => 9; # spent 41µs making 1 call to constant::import |
| 149 | 3 | 28µs | 9µs | use constant DOCUMENT_TYPE_NODE => 10; # spent 43µs making 1 call to constant::import |
| 150 | 3 | 23µs | 8µs | use constant DOCUMENT_FRAGMENT_NODE => 11; # spent 39µs making 1 call to constant::import |
| 151 | 3 | 28µs | 9µs | use constant NOTATION_NODE => 12; # spent 38µs making 1 call to constant::import |
| 152 | 3 | 27µs | 9µs | use constant HTML_DOCUMENT_NODE => 13; # spent 43µs making 1 call to constant::import |
| 153 | 3 | 28µs | 9µs | use constant DTD_NODE => 14; # spent 44µs making 1 call to constant::import |
| 154 | 3 | 23µs | 8µs | use constant ELEMENT_DECLARATION => 15; # spent 41µs making 1 call to constant::import |
| 155 | 3 | 28µs | 9µs | use constant ATTRIBUTE_DECLARATION => 16; # spent 42µs making 1 call to constant::import |
| 156 | 3 | 26µs | 9µs | use constant ENTITY_DECLARATION => 17; # spent 34µs making 1 call to constant::import |
| 157 | 3 | 24µs | 8µs | use constant NAMESPACE_DECLARATION => 18; # spent 29µs making 1 call to constant::import |
| 158 | ||||
| 159 | #-------------------------------------------------------------------------# | |||
| 160 | # some extras for the W3 spec | |||
| 161 | #-------------------------------------------------------------------------# | |||
| 162 | 3 | 23µs | 8µs | use constant PI_NODE => 7; # spent 37µs making 1 call to constant::import |
| 163 | 3 | 28µs | 9µs | use constant DOCUMENT_FRAG_NODE => 11; # spent 37µs making 1 call to constant::import |
| 164 | 3 | 28µs | 9µs | use constant XINCLUDE_END => 19; # spent 32µs making 1 call to constant::import |
| 165 | 3 | 29µs | 10µs | use constant XINCLUDE_START => 20; # spent 42µs making 1 call to constant::import |
| 166 | ||||
| 167 | #-------------------------------------------------------------------------# | |||
| 168 | # libxml2 compat names # | |||
| 169 | #-------------------------------------------------------------------------# | |||
| 170 | 3 | 28µs | 9µs | use constant XML_ELEMENT_NODE => 1; # spent 48µs making 1 call to constant::import |
| 171 | 3 | 27µs | 9µs | use constant XML_ATTRIBUTE_NODE => 2; # spent 38µs making 1 call to constant::import |
| 172 | 3 | 28µs | 9µs | use constant XML_TEXT_NODE => 3; # spent 47µs making 1 call to constant::import |
| 173 | 3 | 25µs | 8µs | use constant XML_CDATA_SECTION_NODE => 4; # spent 40µs making 1 call to constant::import |
| 174 | 3 | 33µs | 11µs | use constant XML_ENTITY_REF_NODE => 5; # spent 43µs making 1 call to constant::import |
| 175 | 3 | 28µs | 9µs | use constant XML_ENTITY_NODE => 6; # spent 42µs making 1 call to constant::import |
| 176 | 3 | 31µs | 10µs | use constant XML_PI_NODE => 7; # spent 42µs making 1 call to constant::import |
| 177 | 3 | 27µs | 9µs | use constant XML_COMMENT_NODE => 8; # spent 47µs making 1 call to constant::import |
| 178 | 3 | 28µs | 9µs | use constant XML_DOCUMENT_NODE => 9; # spent 37µs making 1 call to constant::import |
| 179 | 3 | 28µs | 9µs | use constant XML_DOCUMENT_TYPE_NODE => 10; # spent 42µs making 1 call to constant::import |
| 180 | 3 | 28µs | 9µs | use constant XML_DOCUMENT_FRAG_NODE => 11; # spent 41µs making 1 call to constant::import |
| 181 | 3 | 36µs | 12µs | use constant XML_NOTATION_NODE => 12; # spent 61µs making 1 call to constant::import |
| 182 | 3 | 30µs | 10µs | use constant XML_HTML_DOCUMENT_NODE => 13; # spent 44µs making 1 call to constant::import |
| 183 | 3 | 28µs | 9µs | use constant XML_DTD_NODE => 14; # spent 38µs making 1 call to constant::import |
| 184 | 3 | 28µs | 9µs | use constant XML_ELEMENT_DECL => 15; # spent 43µs making 1 call to constant::import |
| 185 | 3 | 28µs | 9µs | use constant XML_ATTRIBUTE_DECL => 16; # spent 43µs making 1 call to constant::import |
| 186 | 3 | 28µs | 9µs | use constant XML_ENTITY_DECL => 17; # spent 42µs making 1 call to constant::import |
| 187 | 3 | 27µs | 9µs | use constant XML_NAMESPACE_DECL => 18; # spent 41µs making 1 call to constant::import |
| 188 | 3 | 28µs | 9µs | use constant XML_XINCLUDE_START => 19; # spent 41µs making 1 call to constant::import |
| 189 | 3 | 39µs | 13µs | use constant XML_XINCLUDE_END => 20; # spent 37µs making 1 call to constant::import |
| 190 | ||||
| 191 | #-------------------------------------------------------------------------# | |||
| 192 | # libgdome compat names # | |||
| 193 | #-------------------------------------------------------------------------# | |||
| 194 | 3 | 23µs | 8µs | use constant GDOME_ELEMENT_NODE => 1; # spent 38µs making 1 call to constant::import |
| 195 | 3 | 28µs | 9µs | use constant GDOME_ATTRIBUTE_NODE => 2; # spent 42µs making 1 call to constant::import |
| 196 | 3 | 23µs | 8µs | use constant GDOME_TEXT_NODE => 3; # spent 37µs making 1 call to constant::import |
| 197 | 3 | 28µs | 9µs | use constant GDOME_CDATA_SECTION_NODE => 4; # spent 32µs making 1 call to constant::import |
| 198 | 3 | 31µs | 10µs | use constant GDOME_ENTITY_REF_NODE => 5; # spent 46µs making 1 call to constant::import |
| 199 | 3 | 27µs | 9µs | use constant GDOME_ENTITY_NODE => 6; # spent 42µs making 1 call to constant::import |
| 200 | 3 | 28µs | 9µs | use constant GDOME_PI_NODE => 7; # spent 51µs making 1 call to constant::import |
| 201 | 3 | 28µs | 9µs | use constant GDOME_COMMENT_NODE => 8; # spent 38µs making 1 call to constant::import |
| 202 | 3 | 28µs | 9µs | use constant GDOME_DOCUMENT_NODE => 9; # spent 41µs making 1 call to constant::import |
| 203 | 3 | 27µs | 9µs | use constant GDOME_DOCUMENT_TYPE_NODE => 10; # spent 42µs making 1 call to constant::import |
| 204 | 3 | 28µs | 9µs | use constant GDOME_DOCUMENT_FRAG_NODE => 11; # spent 42µs making 1 call to constant::import |
| 205 | 3 | 26µs | 9µs | use constant GDOME_NOTATION_NODE => 12; # spent 42µs making 1 call to constant::import |
| 206 | 3 | 27µs | 9µs | use constant GDOME_HTML_DOCUMENT_NODE => 13; # spent 42µs making 1 call to constant::import |
| 207 | 3 | 28µs | 9µs | use constant GDOME_DTD_NODE => 14; # spent 37µs making 1 call to constant::import |
| 208 | 3 | 27µs | 9µs | use constant GDOME_ELEMENT_DECL => 15; # spent 42µs making 1 call to constant::import |
| 209 | 3 | 28µs | 9µs | use constant GDOME_ATTRIBUTE_DECL => 16; # spent 55µs making 1 call to constant::import |
| 210 | 3 | 22µs | 8µs | use constant GDOME_ENTITY_DECL => 17; # spent 38µs making 1 call to constant::import |
| 211 | 3 | 28µs | 9µs | use constant GDOME_NAMESPACE_DECL => 18; # spent 32µs making 1 call to constant::import |
| 212 | 3 | 27µs | 9µs | use constant GDOME_XINCLUDE_START => 19; # spent 42µs making 1 call to constant::import |
| 213 | 3 | 60µs | 20µs | use constant GDOME_XINCLUDE_END => 20; # spent 42µs making 1 call to constant::import |
| 214 | ||||
| 215 | 1 | 36µs | 36µs | 1; |
| 216 | #-------------------------------------------------------------------------# | |||
| 217 | __END__ | |||
| 218 | ||||
| 219 | =head1 NAME | |||
| 220 | ||||
| 221 | XML::LibXML::Common - Routines and Constants common for XML::LibXML and XML::GDOME | |||
| 222 | ||||
| 223 | =head1 SYNOPSIS | |||
| 224 | ||||
| 225 | use XML::LibXML::Common; | |||
| 226 | ||||
| 227 | =head1 DESCRIPTION | |||
| 228 | ||||
| 229 | XML::LibXML and XML::GDOME share some of the same functionality. This | |||
| 230 | package should bundle some shared constansts and functions, so both | |||
| 231 | modules may coexist within the same scripts. | |||
| 232 | ||||
| 233 | XML::LibXML::Common defines all node types as constants. While | |||
| 234 | XML::LibXML and XML::GDOME originally declared their own node type | |||
| 235 | definitions, one may want to use XML::LibXML::Common in its | |||
| 236 | compatibility mode: | |||
| 237 | ||||
| 238 | =over 4 | |||
| 239 | ||||
| 240 | =item * use XML::LibXML::Common qw(:libxml); | |||
| 241 | ||||
| 242 | :libxml will use the XML::LibXML Compatibility mode, which defines the | |||
| 243 | old 'XML_' node-type definitions | |||
| 244 | ||||
| 245 | =item * use XML::LibXML::Common qw(:gdome); | |||
| 246 | ||||
| 247 | This allows one to use the XML::LibXML Compatibility mode, which | |||
| 248 | defines the old 'GDOME_' node-type definitions | |||
| 249 | ||||
| 250 | =item * use XML::LibXML::Common qw(:w3c); | |||
| 251 | ||||
| 252 | This uses the nodetype definition names as specified for DOM. | |||
| 253 | ||||
| 254 | =item * use XML::LibXML::Common qw(:encoding); | |||
| 255 | ||||
| 256 | This is ment if only the encoding functions of XML::LibXML::Common | |||
| 257 | should be used. | |||
| 258 | ||||
| 259 | =back | |||
| 260 | ||||
| 261 | By default the W3 definitions as defined in the DOM specifications and | |||
| 262 | the encoding functions are exported by XML::LibXML::Common. | |||
| 263 | ||||
| 264 | =head2 encoding functions | |||
| 265 | ||||
| 266 | To encode or decode a string to or from UTF-8 XML::LibXML::Common exports | |||
| 267 | two functions, which use the encoding mechanism of the underlaying | |||
| 268 | implementation. These functions should be used, if external encoding | |||
| 269 | is required (e.g. for queryfunctions). | |||
| 270 | ||||
| 271 | =head2 encodeToUTF8 | |||
| 272 | ||||
| 273 | $encodedstring = encodeToUTF8( $name_of_encoding, $sting_to_encode ); | |||
| 274 | ||||
| 275 | The function will encode a string from the specified encoding to UTF-8. | |||
| 276 | ||||
| 277 | =head2 decodeFromUTF8 | |||
| 278 | ||||
| 279 | $decodedstring = decodeFromUTF8($name_of_encoding, $string_to_decode ); | |||
| 280 | ||||
| 281 | This Function transforms an UTF-8 encoded string the specified | |||
| 282 | encoding. While transforms to ISO encodings may cause errors if the | |||
| 283 | given stirng contains unsupported characters, both functions can | |||
| 284 | transform to UTF-16 encodings as well. | |||
| 285 | ||||
| 286 | Note that both encoding functions report their errors on the standard | |||
| 287 | error. If an error occours the function will croak(). To catch the | |||
| 288 | error information it is required to call the encoding function from | |||
| 289 | within an eval block to avoid a script to stop. | |||
| 290 | ||||
| 291 | =head1 AUTHOR | |||
| 292 | ||||
| 293 | Christian Glahn, (christian.glahn@uibk.ac.at) Innsbruck University | |||
| 294 | ||||
| 295 | =head1 COPYRIGHT | |||
| 296 | ||||
| 297 | (c) 2002 Christian Glahn. All rights reserved. | |||
| 298 | ||||
| 299 | This program is free software; you can redistribute it and/or modify | |||
| 300 | it under the same terms as Perl itself. | |||
| 301 | ||||
| 302 | =head1 SEE ALSO | |||
| 303 | ||||
| 304 | L<perl>, L<XML::LibXML>, L<XML::GDOME> | |||
| 305 | ||||
| 306 | =cut | |||
# spent 48µs within XML::LibXML::Common::bootstrap which was called
# once (48µs+0s) by DynaLoader::bootstrap at line 219 of /usr/lib/perl/5.10/DynaLoader.pm |