SGML-Grove
view release on metacpan or search on metacpan
C<$element-E<gt>attr> returns the value of an attribute, if a second
argument is given then that value is assigned to the attribute and
returned. The value of an attribute may be an array of scalar or
C<SGML::SData> objects, an C<SGML::Notation>, or an array of
C<SGML::Entity> or C<SGML::ExtEntity> objects. C<attr> returns
C<undef> for implied attributes.
C<$element-E<gt>attr_as_string> returns the value of an attribute as a
string, possibly modified by C<$context>. (XXX undefined results if
the attribute is not cdata/sdata.)
C<$element-E<gt>attributes> returns a reference to a hash containing
the attributes of the element, or undef if there are no attributes
defined for for this element. The keys of the hash are the attribute
names and the values are as defined above.
C<$element-E<gt>attributes($attributes)> assigns the attributes from
the hash C<$attributes>. No hash entries are made for implied
attributes.
C<$element-E<gt>contents> returns a reference to an array containing
C<children_accept> and C<children_accept_gi> call C<accept> and
C<accept_gi>, respectively, on each object in the element's content.
Element handles scalars internally for C<as_string>,
C<children_accept>, and C<children_accept_gi>. For C<children_accept>
and C<children_accept_gi> (both), Element calls back with
S<C<$visitor-E<gt>visit_scalar($scalar[, ...])>>.
For C<as_string>, Element will use the string unless
C<$context-E<gt>{cdata_mapper}> is defined, in which case it returns the
result of calling the C<cdata_mapper> subroutine with the scalar and
the remaining arguments. The actual implementation is:
&{$context->{cdata_mapper}} ($scalar, @_);
=head1 AUTHOR
Ken MacLeod, ken@bitsko.slc.ut.us
=head1 SEE ALSO
perl(1), SGML::Grove(3), Text::EntityMap(3), SGML::SData(3),
SGML::PI(3), Class::Visitor(3).
my $value = $attributes->{$attr};
return "" if (!defined($value));
return $value if (!ref ($value)); # return tokens
my ($ii, @string);
for ($ii = 0; $ii <= $#{$value}; $ii ++) {
my $child = $value->[$ii];
if (!ref ($child)) {
my $context = shift;
if (defined ($context->{'cdata_mapper'})) {
push (@string, &{$context->{'cdata_mapper'}}($child, @_));
} else {
push (@string, $child);
}
} else {
push (@string, $child->as_string(@_));
}
}
return (join ("", @string));
}
# $element->as_string($context);
sub as_string {
my $self = shift;
my $context = shift;
my @string;
my $ii;
for ($ii = 0; $ii <= $#{$self->[0]}; $ii ++) {
my $child = $self->[0][$ii];
if (!ref ($child)) {
if (defined ($context->{'cdata_mapper'})) {
push (@string, &{$context->{'cdata_mapper'}}($child, @_));
} else {
push (@string, $child);
}
} else {
push (@string, $child->as_string($context, @_));
}
}
return (join ("", @string));
}
ExtEntity.pm view on Meta::CPAN
#
# $Id: ExtEntity.pm,v 1.2 1998/01/18 00:21:13 ken Exp $
#
package SGML::ExtEntity;
use strict;
use Class::Visitor;
visitor_class 'SGML::ExtEntity', 'SGML::Entity', {
'type' => '$', # cdata, sdata, ndata
'system_id' => '$',
'public_id' => '$',
'generated_id' => '$',
'attributes' => '@',
'notation' => '$',
};
=head1 NAME
SGML::ExtEntity - an external entity defined in an SGML or XML document
Simple/BuilderBuilder.pm view on Meta::CPAN
use Carp;
use vars qw{$AUTOLOAD};
sub visit_scalar {
my $self = shift; my $scalar = shift; my $parent = shift;
if (ref ($scalar) =~ /::Iter/) {
$parent->push ($scalar->delegate);
} else {
# XXX cdata_mapper?
$parent->push ($scalar);
}
}
sub visit_SGML_SData {
my $self = shift; my $sdata = shift; my $parent = shift;
if (ref ($sdata) =~ /::Iter/) {
$parent->push ($sdata->delegate);
} else {
( run in 0.272 second using v1.01-cache-2.11-cpan-454fe037f31 )