NAME

XML::Template::Element - XML::Template plug-in element base class.

SYNOPSIS

package XML::Template::Element::MyElement;

use base qw(XML::Template::Element); use XML::Template::Element;

DESCRIPTION

This module provides base functionality for XML::Template plug-in element modules.

CONSTRUCTOR

The first parameter of the constructor is hash containing namespace prefix/expanded namespace name/value pairs. The second parameter is the current namespace. The remaining named parameters are passed to the XML::Template::Base constructor. The constructor returns a reference to a new element object or undef if an error occurred. If undef is returned, you can use the method error to retrieve the error. For instance:

my $element = XML::Template::Element->new ($namespaces, $namespace, %params)
  || die XML::Template::Element->error;

PUBLIC METHODS

namespace

my $namespace = $self->namespace;

This method returns the current namespace.

generate_named_params

my $attribs_named_params = $self->generate_named_params (\%attrbs);

This method generates Perl code for a named parameter list. The first parameter is a reference to a hash containing parameter name/value pairs. For instance,

my $attribs_named_params = $self->generate_named_params ({
                             type		=> "'newsletter'",
                             date		=> "'2002%'",
                             'map.num'	=> 3});

would return the following string

'type' => 'newsletter', 'date' => '2002%', 'map.num' => 3

generate_xmlinfo_code

my $xmlinfo_code = $self->generate_xmlinfo_code ($self->{_xmlinfo});

This method generates Perl code that creates the data structure that store current XML information (currently declared namespaces. This is necessary for passing current XML information from the parse-time to run-time. For instance, sometimes it is necessary to make the XML information current when an element module is called available when the code the element module generates is later evaluated.

get_attrib

my $field = $self->get_attrib ($attribs, ['field', 'fields']) || 'undef';
my $name = $self->get_attrib ($attribs, 'name'], 0) || '"default"';

This method returns an attribute value. The first parameter is a reference to a hash containing attribute/value pairs. The second parameter is a scalar or a reference to an array of attribute names to look for. The value of the first attribute name found is returned.

Unless the optional third parameter is true, the attribute is deleted from the attribute hash.

AUTHOR

Jonathan Waxman jowaxman@bbl.med.upenn.edu

COPYRIGHT

Copyright (c) 2002 Jonathan A. Waxman All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.