| Alvis-NLPPlatform documentation | Contained in the Alvis-NLPPlatform distribution. |
Alvis::NLPPlatform::XMLEntities - Perl extension for managing characters which can not be used in a XML document
use Alvis::NLPPlatform::XMLEntities;
Alvis::NLPPlatform::XMLEntities::decode($line);
Alvis::NLPPlatform::XMLEntities::eecode($line);
This module is used to encode or decode special XML characters
(&, ', ", >, <).
This method encodes special XML characters as XML entities in the line $line.
This method decodes XML entities corresponding to special XML characters in the line $line . It returns the shift in the offset after substitution;
Alvis::NLPPlatform
Alvis web site: http://www.alvis.info
Guillaume Vauvert <guillaume.vauvert@lipn.univ-paris13.fr>
Currently maintained by Julien Deriviere <julien.deriviere@lipn.univ-paris13.fr> and Thierry Hamon <thierry.hamon@lipn.univ-paris13.fr>
Copyright (C) 2004 by Guillaume Vauvert, Thierry Hamon and Julien Deriviere
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
| Alvis-NLPPlatform documentation | Contained in the Alvis-NLPPlatform distribution. |
package Alvis::NLPPlatform::XMLEntities; use strict; use warnings; our $VERSION=$Alvis::NLPPlatform::VERSION; sub encode { $_[0]=~s/&/&/g; $_[0]=~s/\"/"/g; $_[0]=~s/\'/'/g; $_[0]=~s/</</g; $_[0]=~s/>/>/g; } sub decode { my $shift_offset = 0; $shift_offset += ($_[0]=~s/"/\"/g) * 5; $shift_offset += ($_[0]=~s/'/\'/g) * 5; $shift_offset += ($_[0]=~s/&/&/g) * 4; $shift_offset += ($_[0]=~s/</</g) * 3; $shift_offset += ($_[0]=~s/>/>/g) * 3; return($shift_offset); } 1; __END__