/usr/share/perl5/SRU/Utils/XML.pm is in libsru-perl 1.01-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | package SRU::Utils::XML;
{
$SRU::Utils::XML::VERSION = '1.01';
}
#ABSTRACT: XML utility functions for SRU
use strict;
use warnings;
use base qw( Exporter );
our @EXPORT_OK = qw( element elementNoEscape escape stylesheet );
sub element {
my ($tag, $text) = @_;
return '' if ! defined $text;
return "<$tag>" . escape($text) . "</$tag>";
}
sub elementNoEscape {
my ($tag, $text) = @_;
return '' if ! defined $text;
return "<$tag>$text</$tag>";
}
sub escape {
my $text = shift || '';
$text =~ s/</</g;
$text =~ s/>/>/g;
$text =~ s/&/&/g;
return $text;
}
sub stylesheet {
my $uri = shift;
return qq(<?xml-stylesheet type='text/xsl' href="$uri" ?>);
}
1;
__END__
=pod
=head1 NAME
SRU::Utils::XML - XML utility functions for SRU
=head1 SYNOPSIS
use SRU::Utils::XML qw( escape );
return escape( $text );
=head1 DESCRIPTION
This is a set of utility functions for use with XML data.
=head1 METHODS
=head2 element( $tag, $text )
Creates an xml element named C<$tag> containing escaped data (C<$text>).
=cut
=head2 elementNoEscape( $tag, $text )
Similar to C<element>, except that C<$text> is not escaped.
=cut
=head2 escape( $text )
Does minimal escaping on C<$text>.
=cut
=head2 stylesheet( $uri )
A shortcut method to create an xml-stylesheet declaration.
=cut
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Ed Summers.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|