XML-DTD
view release on metacpan or search on metacpan
lib/XML/DTD/Component.pm view on Meta::CPAN
if (defined($r) && ref($r) eq $cls) {
return 1;
} else {
return 0;
}
}
# Set the unparsed component text
sub define {
my $self = shift;
my $type = shift;
my $text = shift;
my $ltdl = shift;
my $rtdl = shift;
$self->{'CMPNTTYPE'} = $type;
$self->{'UNPARSEDTEXT'} = $text;
$text =~ s/^$ltdl// if defined ($ltdl);
$text =~ s/$rtdl$// if defined ($rtdl);
$self->{'WITHINDELIM'} = $text if (defined($ltdl) and defined ($rtdl));
}
# Get a string containing the unparsed component text
sub unparsed {
my $self = shift;
return $self->{'UNPARSEDTEXT'};
}
# Print the unparsed component text
sub fwrite {
my $self = shift;
my $fh = shift;
print $fh $self->{'UNPARSEDTEXT'};
}
# Return the unparsed component text as a string
sub swrite {
my $self = shift;
return $self->{'UNPARSEDTEXT'};
}
# Write an XML representation
sub writexml {
my $self = shift;
my $xmlw = shift;
my $tag = $self->{'CMPNTTYPE'};
my $atr = $self->xmlattrib;
$xmlw->open($tag, $atr);
$xmlw->open('unparsed');
if (defined($self->{'WITHINDELIM'})) {
$xmlw->pcdata($self->{'WITHINDELIM'});
} else {
$xmlw->pcdata($self->{'UNPARSEDTEXT'});
}
$xmlw->close;
$self->writexmlelts($xmlw);
$xmlw->close;
}
# Return attributes for XML representation
sub xmlattrib {
my $self = shift;
return {};
}
# Write component-specific part of the XML representation
sub writexmlelts {
my $self = shift;
my $xmlw = shift;
}
1;
__END__
=head1 NAME
XML::DTD::Component - Perl module representing a component of an XML DTD
=head1 DESCRIPTION
XML::DTD::Component is a Perl module representing a component of an
XML DTD. It is intended to be a base class for derived classes, and
should not itself be instantiated. The following methods are
provided.
=over 4
=item B<new>
$obj = new XML::DTD::Component;
=item B<isa>
if (XML::DTD::Component->isa($obj) {
...
}
Test object type
=item B<define>
$obj->define('component type', 'component text', 'left delimiter',
'right delimiter');
Set the component description
=item B<unparsed>
( run in 0.612 second using v1.01-cache-2.11-cpan-39bf76dae61 )