| SGML-Grove documentation | Contained in the SGML-Grove distribution. |
SGML::SData - an SGML, XML, or HTML document SData replacement
$sdata = SGML::SData->new ($replacement[, $entity_name]); $name = $sdata->name; $data = $sdata->data; $sdata->as_string([$context, ...]); $sdata->iter; $sdata->accept($visitor, ...); $sdata->accept_gi($visitor, ...); $sdata->children_accept($visitor, ...); $sdata->children_accept_gi($visitor, ...);
An SGML::SData contains the entity name and replacement value of a
character entity reference.
$sdata->name returns the entity name of the SData object.
$sdata->data returns the data of the SData object.
The Perl module Text::EntityMap can be used to map commonly used
character entity sets to common output formats.
$sdata->as_string([$context, ...]) returns data surrounded
by brackets (`[ ... ]') unless $context->{sdata_mapper} is
defined, in which case it returns the result of calling the
sdata_mapper subroutine with data and the remaining arguments.
The actual implementation is:
&{$context->{sdata_mapper}} ($self->data, @_);
$sdata->iter returns an iterator for the sdata object, see
Class::Visitor for details.
$sdata->accept($visitor[, ...]) issues a call back to
$visitor->visit_SGML_SData($sdata[, ...]). See examples
visitor.pl and simple-dump.pl for more information.
$sdata->accept_gi($visitor[, ...]) is implemented as a synonym
for accept.
children_accept and children_accept_gi do nothing.
Ken MacLeod, ken@bitsko.slc.ut.us
perl(1), SGML::Grove(3), Text::EntityMap(3), SGML::Element(3), SGML::PI(3), Class::Visitor(3).
| SGML-Grove documentation | Contained in the SGML-Grove distribution. |
# # Copyright (C) 1997 Ken MacLeod # See the file COPYING for distribution terms. # # $Id: SData.pm,v 1.2 1998/01/18 00:21:15 ken Exp $ # package SGML::SData; use strict; use Class::Visitor; visitor_class 'SGML::SData', 'Class::Visitor::Base', [ 'data' => '@', # [0] 'name' => '$', # [1] ];
sub as_string { my $self = shift; my $context = shift; if (defined ($context->{'sdata_mapper'})) { return &{$context->{'sdata_mapper'}} ($self->data, @_); } else { return ("[" . $self->data . "]"); } } sub accept { my $self = shift; my $visitor = shift; $visitor->visit_SGML_SData ($self, @_); } # synonomous to `accept' sub accept_gi { my $self = shift; my $visitor = shift; $visitor->visit_SGML_SData ($self, @_); } # these are here just for type compatibility sub children_accept { } sub children_accept_gi { } sub contents { return [] } 1;