XML::Elemental::Document - a generic document object.
package XML::Elemental::Document;
use strict;
use base qw( XML::Elemental::Node );
use Scalar::Util qw(weaken);
sub root_element { $_[0]->{contents} }
sub contents {
if (@_ > 1) {
$_[0]->{contents} = ref $_[1] eq 'ARRAY' ? $_[1]->[0] : $_[1];
weaken($_[0]->{contents}->{parent} = $_[0]);
}
return $_[0]->{contents} ? [$_[0]->{contents}] : [];
}
sub attributes { } # deprecated. documents never have attributes.
sub DESTROY {
$_[0]->{contents}->DESTROY if $_[0]->{contents};
} # starts circular reference teardown
1;
__END__