SGML::Simple::Spec - a simple transformation specification
use SGML::SPGroveBuilder; use SGML::Simple::Spec; use SGML::Simple::SpecBuilder; use SGML::Simple::BuilderBuilder; $spec_grove = SGML::SPGroveBuilder->new ($spec_sysid); $spec = SGML::Simple::Spec->new; $spec_grove->accept (SGML::Simple::SpecBuilder->new, $spec); $builder = SGML::Simple::BuilderBuilder->new (spec => $spec);
A SGML::Simple::Spec object containing SGML::Simple::Spec::Rule objects is built by the SpecBuilder module from a grove of a simple specification file.
SGML::Simple::Spec
SGML::Simple::Spec::Rule
SpecBuilder
SGML::Simple::Spec and SGML::Simple::Spec::Rule inherit all methods from Class::Visitor and Class::Template. Fields are defined below.
Class::Visitor
Class::Template
Spec objects are passed to SGML::Simple::BuilderBuilder to build a Perl package for transforming other SGML groves.
Spec
SGML::Simple::BuilderBuilder
SGML::Simple::Spec contains the following fields:
default_prefix, default_object
default_prefix defines the default package prefix to be used for objects being created during a transform. default_object defines an object to be created when a make field is undefined in a rule.
default_prefix
default_object
make
rules -- an array
rules contains the global set of rules for this transformation.
rules
stuff
stuff contains extra Perl code to be added as part of the new package.
SGML::Simple::Spec::Rule defines a single transformation rule and contains the following fields:
query
A space seperated list of generic identifiers that this rule applies to.
holder
A flag indicating that this element merely contains other elements. No objects are created during the transformation.
ignore
A flag indicating that this element should be ignored. No objects are created during the transformation and no elements contained in this element are processed.
The package name of an object to be created for this rule. An object in the `make' package is created to hold any elements contained in this element.
port
A field name in the parent object to append this object to. If not defined, this object is added to the parent's `contents' field.
Rules that apply only within the current element.
code
If code is defined it is used in place of any code that would have been generated by BuilderBuilder, all other fields are ignored. Code for a holder element looks like this:
BuilderBuilder
my $self = shift; my $element = shift; my $parent = shift; $element->children_accept_gi ($self, $parent, @_);
Code for creating a new object looks like this:
my $self = shift; my $element = shift; my $parent = shift; my $obj = My::Object->new; $parent->push ($obj); $element->children_accept_gi ($self, $obj, @_);
Code for switching a set of rules (the current ``builder'') looks like this:
my $self = shift; my $element = shift; my $parent = shift; $new_builder = Another::Builder->new; $element->children_accept_gi ($new_builder, $obj, @_);
Ken MacLeod, ken@bitsko.slc.ut.us
perl(1), SGML::Grove(3), SGML::Simple::SpecBuilder(3), SGML::Simple::BuilderBuilder(3), Class::Visitor(3), Class::Template(3)
To install SGML::Grove, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SGML::Grove
CPAN shell
perl -MCPAN -e shell install SGML::Grove
For more information on module installation, please visit the detailed CPAN module installation guide.