XML::DTD::PERef - Perl module representing a parameter entity reference


XML-DTD documentation Contained in the XML-DTD distribution.

Index


Code Index:

NAME

Top

XML::DTD::PERef - Perl module representing a parameter entity reference

SYNOPSIS

Top

  use XML::DTD::PERef;

  my $per = XML::DTD::PERef->new('%entname;');

DESCRIPTION

Top

XML::DTD::PERef is a Perl module representing a parameter entity reference. The following methods are provided.

new
 my $per = XML::DTD::PERef->new('%entname;');

Construct a new XML::DTD::PERef object.

value
 print $per->value;

Return the value of the referenced entity.

xmlattrib
 $xat = $per->xmlattrib;

Return attributes for XML representation.

SEE ALSO

Top

XML::DTD, XML::DTD::Component

AUTHOR

Top

Brendt Wohlberg <wohl@cpan.org>

COPYRIGHT AND LICENSE

Top


XML-DTD documentation Contained in the XML-DTD distribution.

package XML::DTD::PERef;

use XML::DTD::Component;

use 5.008;
use strict;
use warnings;

our @ISA = qw(XML::DTD::Component);

our $VERSION = '0.09';


# Constructor
sub new {
  my $arg = shift;
  my $man = shift;
  my $ent = shift;

  my $cls = ref($arg) || $arg;
  my $obj = ref($arg) && $arg;

  my $self;
  if ($obj) {
    # Called as a copy constructor
    $self = { %$obj };
    bless $self, $cls;
  } else {
    # Called as the main constructor
    $self = { };
    bless $self, $cls;
    $self->define('peref', $ent);
    $self->{'ENTVAL'} = $man->pevalue($ent);
    $ent =~ /^%(.+);$/;
    $self->{'NAME'} = $1;
  }
  return $self;
}


# Return the value of the referenced entity
sub value {
  my $self = shift;

  return $self->{'ENTVAL'};
}


# Return attributes for XML representation
sub xmlattrib {
  my $self = shift;

  return {'name' => $self->{'NAME'}};
}


1;
__END__