XML::Template::Document - Module to encapsulate a parsed or unparsed XML document.
use XML::Template::Document; my $document = XML::Template::Document->new (XML => $xml); $document->code ($code) if ! $document->compiled;
This module defines an object class that represents a parsed or unparsed XML document. Typically, in XML::Template::Process, one in a series of load objects will return a XML::Template::Document object. If the document is not parsed (i.e., no code has been generated), the document is passed to XML::Template::Parser to be parsed. The parsed XML::Template::Document object is then passed to each in a series of put objects to store the document. If document caching is turned on, the first object in the load and put lists is a XML::Template::Cache object.
The constructor returns a reference to a new document object or undef if an error occurred. If undef is returned, you can use the method error to retrieve the error. For instance:
error
my $document = XML::Templatte::Document->new (%config) || die XML::Template::Document->error;
A list of named configuration parameters may be passed to the constructor. The following named configuration parameters are supported by this module:
The unparsed XML document.
The Perl code that will generate the output of the XML document.
The original source of the document. This is used by the file caching system to check if a document has been updated. The format is
C<type>:C<source_info>
Where type can be
type
Indicates the original source is a file. source_info is the full filespec of the original document.
source_info
Indicates the original document comes from a data source. source_info is
C<sourcename>:C<data_source_info>
where sourcename is the name of the document's data source entry and, data_source_info is specific to the type of source. For a DBI source, it is a table.
sourcename
data_source_info
my $iscompiled = $document->compiled;
This method returns 1 if the document is compiled (i.e., code is stored) and 0 if otherwise.
$document->code ($code); my $code = $document->code;
This method stores and returns the Perl code that generates the document output. The first parameter is a string containg the Perl code to store.
$document->xml ($xml); my $xml = $document->xml;
This method stores and returns the unparsed XML document. The first parameter is a string containg the XML.
$document->source ($source); my $source = $document->source;
This method stores and returns the original document source. The first argument is a string containing the document source as described above.
Jonathan Waxman <jowaxman@bbl.med.upenn.edu>
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.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
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.