The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SGML::Simple::Spec - a simple transformation specification

SYNOPSIS

    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);

DESCRIPTION

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 and SGML::Simple::Spec::Rule inherit all methods from Class::Visitor and Class::Template. Fields are defined below.

Spec objects are passed to SGML::Simple::BuilderBuilder to build a Perl package for transforming other SGML groves.

SGML::Simple::Spec

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.

    rules  --  an array

rules contains the global set of rules for this transformation.

    stuff

stuff contains extra Perl code to be added as part of the new package.

SGML::Simple::Spec::Rule

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.

    make

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  --  an array

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:

    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, @_);

AUTHOR

Ken MacLeod, ken@bitsko.slc.ut.us

SEE ALSO

  perl(1), SGML::Grove(3), SGML::Simple::SpecBuilder(3),
  SGML::Simple::BuilderBuilder(3), Class::Visitor(3),
  Class::Template(3)