NAME
XML::Template::Element - XML::Template plugin 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 plugin element modules.
CONSTRUCTOR
The first parameter of the constructor is hash containing local name/namespace pairs, i.e. the currently loaded namespaces. 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
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-2003 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.