XML::Template::Base - Base class for XML::Template modules.
use base qw(XML::Template::Base); use XML::Template::Base;
This module is the XML::Template base class. It implements common functionality for many other XML::Template modules, including construction and error handling.
XML::Template::Base provides a common constructor for XML::Template modules. The constructor simply creates a new self and calls an initialization method. If the derived class does not have its own initialization subroutine, XML::Template::Base provides one that simply returns true.
The following named configuration parameters are supported:
Set to true to turn on printing debug information.
The hostname of the requesting server. The default value is set to the environment variable HTTP_HOST. If this is not set (for instance, if running on the command line), the default is localhost.
HTTP_HOST
localhost
A reference to a hash containing configuration information. This is typically a representation of the XML configuration file xml-template.conf.
xml-template.conf
XML::Template::Base provides an initialization function that simply returns 1. This is required for modules that use XML::Template::Base as a base class, but do not require an initialization function.
XML::Template::Base
my $namespace_info = $self->_copy ($orig_namespace_info);
This method makes a copy of whatever is passed to it (scalar, array, or hash), interpolating any config variables with values from the appropriate host entry of the config file. For instance, if the host is syrme.net, and the host entry for syrme.net in the config file is:
syrme.net
<host name="syrme.net"> <sourcename>syrme</sourcename> </host>
and if the variable $orig_namespace_info is a reference to a hash representing the following section of the config file,
$orig_namespace_info
<namespace name="http://syrme.net/xml-template/block/v1"> <sourcename>${sourcename}</sourcename> </namespace>
that is,
$orig_namespace_info = { 'name' => 'http://syrme.net/xml-template/user/v1', 'sourcename' => '${sourcename}' };
_copy will replace ${sourcename} with the value from the variable named sourcename from the host entry, that is, syrme. So, c<_copy> will return a reference to the hash:
_copy
${sourcename}
$namespace_info = { 'name' => 'http://syrme.net/xml-template/user/v1', 'sourcename' => 'syrme' };
return $self->error ($errstr); print $self->error;
XML::Template::Base provides the method error to do simple error handling. If an argument is given (the error), it is stored, otherwise, the stored error is returned.
error
error may be called as a package method (e.g., XML::Template::Module->error ($error); or as an object method (e.g., $xmlt->error ($error);. If it is called as a package method, the error is stored as a package variable. If it is called as an object method, the error is stored as a private variable.
XML::Template::Module->error ($error);
$xmlt->error ($error);
my $source_info = $self->get_source_info ($sourcename);
This method returns a hash containing name/value pairs for the config variables from the source entry, $sourcename in the config file.
$sourcename
my $subroutine_info = $self->get_subroutine_info ($subroutine);
This method returns a hash containing name/value pairs for the config variables from the subroutine entry, $subroutine, in the config file.
$subroutine
my $namespace_info = $self->get_namespace_info ($namespace);
This method returns a hash containing name/value pairs for the config variables from the namespace entry, $namespace, in the config file.
$namespace
my $element_info = $self->get_element_info ($namespace, $type);
This method returns a hash containing name/value pairs for the config variables from the element entry, $type, in the namespace entry, $namespace, in the config file.
$type
my $source = $self->get_source ($sourcename);
This method returns the data source, $sourcename, from the config file.
Data source references are stored in a private hash. If a requested data source has already been loaded, the stored reference to it is returned.
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.
1 POD Error
The following errors were encountered while parsing the POD:
=back doesn't take any parameters, but you said =back 4
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.