NAME
XML::Template::Base - Base class for XML::Template modules.
SYNOPSIS
use base qw(XML::Template::Base);
use XML::Template::Base;
DESCRIPTION
This module is the XML::Template base class. It implements common functionality for many other XML::Template modules, including construction and error handling.
CONSTRUCTOR
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:
- Debug
-
Set to true to turn on printing debug information.
- HTTPHost
-
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 islocalhost
. - Config
-
A reference to a hash containing configuration information. This is typically a representation of the XML configuration file
xml-template.conf
.
PRIVATE METHODS
_init
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.
_copy
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:
<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,
<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:
$namespace_info = { 'name' => 'http://syrme.net/xml-template/user/v1', 'sourcename' => 'syrme' };
PUBLIC METHODS
error
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
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.
get_source_info
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.
get_subroutine_info
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.
get_namespace_info
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.
get_element_info
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.
get_source
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.
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.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 66:
=back doesn't take any parameters, but you said =back 4