The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

XML::Template::Document - Module to encapsulate a parsed or unparsed XML document.

SYNOPSIS

  use XML::Template::Document;

  my $document = XML::Template::Document->new (XML => $xml);
  $document->code ($code) if ! $document->compiled;

DESCRIPTION

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.

CONSTRUCTOR

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:

  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:

XML

The unparsed XML document.

Code

The Perl code that will generate the output of the XML document.

Source

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

file

Indicates the original source is a file. source_info is the full filespec of the original document.

source

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.

PUBLIC METHODS

compiled

  my $iscompiled = $document->compiled;

This method returns 1 if the document is compiled (i.e., code is stored) and 0 if otherwise.

code

  $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.

xml

  $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.

source

  $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.

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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 110:

You forgot a '=back' before '=head1'