/usr/lib/perl5/XML/Easy/Content.pm is in libxml-easy-perl 0.009-1build1.
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 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 | =head1 NAME
XML::Easy::Content - abstract form of XML content
=head1 SYNOPSIS
use XML::Easy::Content;
$content = XML::Easy::Content->new([
"foo",
$subelement,
"bar",
]);
$twine = $content->twine;
=head1 DESCRIPTION
An object of this class represents a chunk of XML content, the kind
of matter that can be contained within an XML element. This is in an
abstract form, intended for general manipulation. It is completely
isolated from the textual representation of XML, and holds only the
meaningful content of the chunk. The data in a content object cannot
be modified: different data requires the creation of a new object.
An XML content chunk consists of a sequence of zero or more characters
and XML elements, interspersed in any fashion. Character content can
use almost all Unicode characters, with only a few characters (such as
most of the ASCII control characters) prohibited by the specification
from being directly represented in XML. Each XML element in a content
chunk itself recursively contains a chunk of content, in addition to
having attached metadata.
This class is not meant to be subclassed. XML content is unextendable,
dumb data. Content objects are better processed using the functions in
L<XML::Easy::NodeBasics> than using the methods of this class.
=cut
package XML::Easy::Content;
{ use 5.008; }
use warnings;
use strict;
our $VERSION = "0.009";
eval { local $SIG{__DIE__};
require XSLoader;
XSLoader::load("XML::Easy", $VERSION) unless defined &new;
};
if($@ eq "") {
close(DATA);
} else {
(my $filename = __FILE__) =~ tr# -~##cd;
local $/ = undef;
my $pp_code = "#line 75 \"$filename\"\n".<DATA>;
close(DATA);
{
local $SIG{__DIE__};
eval $pp_code;
}
die $@ if $@ ne "";
}
*content = \&twine;
1;
__DATA__
# Note perl bug: a bug in perl 5.8.{0..6} screws up __PACKAGE__ (used below)
# for the eval. Explicit package declaration here fixes it.
package XML::Easy::Content;
use Params::Classify 0.000 qw(is_ref);
use XML::Easy::Classify qw(check_xml_content_twine);
BEGIN {
if(eval { local $SIG{__DIE__};
require Internals;
exists &Internals::SetReadOnly;
}) {
*_set_readonly = \&Internals::SetReadOnly;
} else {
*_set_readonly = sub { };
}
}
sub _throw_data_error($) {
my($msg) = @_;
die "invalid XML data: $msg\n";
}
=head1 CONSTRUCTOR
=over
=item XML::Easy::Content->new(TWINE)
Constructs and returns a new content chunk object with the specified
content.
I<TWINE> must be a reference to an array listing the chunk's
content in twine form (see L<XML::Easy::NodeBasics/Twine>).
The content is checked for validity, against the XML 1.0
specification, and the function C<die>s if it is invalid.
=cut
sub new {
my($class, $twine) = @_;
_throw_data_error("content array isn't an array")
unless is_ref($twine, "ARRAY");
$twine = [ @$twine ];
_set_readonly(\$_) foreach @$twine;
_set_readonly($twine);
check_xml_content_twine($twine);
my $self = bless([ $twine ], __PACKAGE__);
_set_readonly(\$_) foreach @$self;
_set_readonly($self);
return $self;
}
=back
=head1 METHODS
=over
=item $content->twine
Returns a reference to an array listing the chunk's
content in twine form (see L<XML::Easy::NodeBasics/Twine>).
The returned array must not be subsequently modified. If possible,
it will be marked as read-only in order to prevent modification.
=cut
sub twine { $_[0]->[0] }
=item $content->content
Deprecated alias for the L</twine> method.
=back
=head1 SEE ALSO
L<XML::Easy::Element>,
L<XML::Easy::NodeBasics>
=head1 AUTHOR
Andrew Main (Zefram) <zefram@fysh.org>
=head1 COPYRIGHT
Copyright (C) 2008, 2009 PhotoBox Ltd
Copyright (C) 2009, 2010, 2011 Andrew Main (Zefram) <zefram@fysh.org>
=head1 LICENSE
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
1;
|