Common(3)
SYNOPSIS
use XML::LibXML::Common;
DESCRIPTION
XML::LibXML and XML::GDOME share some of the same func
tionality. This package should bundle some shared con
stansts 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:
- · use XML::LibXML::Common qw(:libxml);
- :libxml will use the XML::LibXML Compatibility mode,
which defines the old 'XML_' node-type definitions - · use XML::LibXML::Common qw(:gdome);
- This allows one to use the XML::LibXML Compatibility
mode, which defines the old 'GDOME_' node-type defini
tions - · use XML::LibXML::Common qw(:w3c);
- This uses the nodetype definition names as specified
for DOM. - · use XML::LibXML::Common qw(:encoding);
- This is ment if only the encoding functions of
XML::LibXML::Common should be used. - By default the W3 definitions as defined in the DOM speci
fications and the encoding functions are exported by
XML::LibXML::Common. - 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). - encodeToUTF8
$encodedstring = encodeToUTF8( $name_of_encoding,- $sting_to_encode );
- The function will encode a string from the specified
encoding to UTF-8. - decodeFromUTF8
$decodedstring = decodeFromUTF8($name_of_encoding,- $string_to_decode );
- This Function transforms an UTF-8 encoded string the spec
ified encoding. While transforms to ISO encodings may
cause errors if the given stirng contains unsupported
characters, both functions can transform to UTF-16 encod
ings 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.
AUTHOR
Christian Glahn, (christian.glahn@uibk.ac.at) Innsbruck
University
SEE ALSO
- perl, XML::LibXML, XML::GDOME