XML::Template::Element - XML::Template plug-in element base class.
package XML::Template::Element::MyElement;
use base qw(XML::Template::Element); use XML::Template::Element;
This module provides base functionality for XML::Template plug-in element modules.
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:
XML::Template::Base
error
my $element = XML::Template::Element->new ($namespaces, $namespace, %params) || die XML::Template::Element->error;
my $namespace = $self->namespace;
This method returns the current namespace.
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
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.
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.
Jonathan Waxman jowaxman@bbl.med.upenn.edu
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.
To install XML::Template, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Template
CPAN shell
perl -MCPAN -e shell install XML::Template
For more information on module installation, please visit the detailed CPAN module installation guide.