NAME

XML::Template::Process - The main XML::Template document processing module.

SYNOPSIS

This module is the main XML::Template document processing module. It loads, compiles, stores (and caches), and evaluates XML documents. In addition is contains many useful subroutines for processing documents.

CONSTRUCTOR

A constructor method new is provided by XML::Template::Base. A list of named configuration parameters may be passed to the constructor. The constructor returns a reference to a new parser object or under if an error occurred. If undef is returned, you can use the method error to retrieve the error. For instance:

my $parser = XML::Template::Process->new (%config)
  || die XML::Template::Process->error;

The following named configuration parameters may be passed to the constructor:

CGIHeader

Whether to print a CGI header. The default is 1.

Cache

A blessed object that handles caching compiled XML documents to memory. This value will override the default value $CACHE in XML::Template::Config. The default cache object is of the class XML::Template::Cache.

NoCache

Whether to cache compiled XML documents to memory. If 1, a Cache object is prepended to the load and put chains of responsibility. The default is 1.

FileCache

A blessed object that handles caching compiled XML documents to files. This value will override the default value $FILE_CACHE in XML::Template::Config. The default file cache object is of the class XML::Template::Cache::File.

NoFileCache

Whether to cache compiled XML documents to files. If 1, a FileCache object is prepended to the load and put chains of responsibility. The default is 1.

Load

A single object or reference to an array of objects to be added to the load chain of responsibility.

Handler

A blessed XML::SAX handler object used to parse XML document. This value will override the default value $HANDLER in XML::Template::Config. The default parser handler is of the class XML::Template::Parser.

Subroutine

A blessed object for default XML::Template subroutine handling. This value will override the default value $SUBROUTINE in XML::Template::Config. The default subroutine object is of the class XML::Template::Subroutine.

Put

A single object or reference to an array of objects to be added to the put chain of responsibility.

Vars

A blessed object for XML::Template variable handling. This value will override the default value $VARS in XML::Template::Config. The default vars object is of the class XML::Template::Vars.

PRIVATE METHODS

_init

This method is the internal initialization function called from XML::Template::Base when a new process object is created.

PUBLIC METHODS

print

my $code = "\$process->print ($text);\n";

This method is used to print text from XML documents. Typically it will be used in Perl code generated by XML::Template. A CGI header will be printed if the onstructor parameter CGIHeader is set to 1 and one has not yet been printed.

subroutine

my $code = "\$process->subroutine ('$subname', $text, \@params)";

This method is used to handle XML::Template subroutine calls. It is typically not used directly, but called from Perl code generated by XML::Template. The first parameter is the XML::Template subroutine name, the second is the variable on which the XML::Template subroutine is being called, and the remaining parameters are additional parameters that are being passed to the XML::Template subroutine. If no modules is associated with the XML::Template subroutine in the XML::Template configuration file, the default subroutine module (specified by the constructor parameter Subroutine) is used.

process

$process->process ($name, $vars)
  || die $process->error ();

This is the main XML document processing subroutine. The first parameter is the name of the XML document. The format of this parameter depends on loader. For instance, a block loader will interpret the name as a primary key in a database table. The file loader will interpret the name as a file. The second parameter is a reference to a hash containing name/value pairs of defined variables.

get_load

my %loaded = $process->get_load ()

This method returns a hash that contains module name / enabled flag pairs that lists which loader modules are loaded and enabled. This is used with the method set_load to selectively dis/enable loader modules. It is definately not the best way to handle this sort of thing!

set_load

$process->set_load (%load)

This method is used to selectively dis/enable loader modules. It takes a hash containing loader module names / enable flag pairs. For each loader module listed, if the flag is set to 1, the module will be enabled, otherwise it will be disabled. I would like to replace this with something more sensible if it's even necessary.

generate_where

my $where = $self->generate_where (\%attribs, $table);

This method returns the where clause of an SQL statement. The first parameter is a reference to a hash containing attributes which are the column names/values to be matched in the where clause. The second parameter is the name of the default table to use for columns given in %attribs. If column names do not have . in them, they are prepended by $table. If column values have % in them, LIKE is used for the comparison test. Otherwise = is used. For instance,

my $where = $self->generate_where ({type      => 'newsletter',
                                    'map.num' => 5,
                                    date      => '2002%'},
                                   'items')

will return the following SQL where clause:

items.type='newsletter' and map.num='5' and items.date like '2002%'

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.