AxKit2::Processor - AxKit's core XML processing engine


AxKit2 documentation  | view source Contained in the AxKit2 distribution.

Index


NAME

Top

AxKit2::Processor - AxKit's core XML processing engine

DESCRIPTION

Top

The Processor is provided to the xmlresponse hook in order to facilitate transforming XML prior to being output to the browser. A typical XSLT example might look like this:

  sub hook_xmlresponse {
    my ($self, $input) = @_;

    # $input is a AxKit2::Processor object

    my $stylesheet = './myfirstplugin/stylesheets/default.xsl';
    my $out = $input->transform(XSLT($stylesheet));

    # $out is also an AxKit2::Processor object

    return OK, $out;
  }

API

Top

CLASS->new( CLIENT, PATH [, INPUT [, OUTPUT]] )

Normally you would not need to call the constructor - this is done for you.

$obj->path

Returns the path to the object being requested. Normally the same as the request filename.

$obj->input

This method returns the input DOM if there was one. This may be useful for a transformer to know - for example XSP will need to recompile its code if there was an input DOM because it implies XSP -> XSP.

Normally you would just access the input DOM via $obj->dom.

$obj->client

The AxKit2::Connection object for this request.

$obj->dom( [ INPUT ] )

Get/set the DOM for whatever is being transformed. Auto-generates a DOM if there wasn't one already stored in the input.

See XML::LibXML::Document for the DOM API.

$obj->output()

Sends the transformation result to the browser. You do not need to call this as it is performed by AxKit when you return (OK, PROCESSOR) from your xmlresponse hook.

$obj->transform( LIST )

Performs the transformations specified in LIST. The transform method is extremely flexible in how it will accept this list of transformations.

The following are all equivalent:

* As strings:
  $input->transform(qw(
            XSP
            XSLT(/path/to/stylesheet.xsl)
            XSLT(/path/to/xml2html.xsl)
            ));

* Via helper functions:
  $input->transform(
        XSP()
     => XSLT("/path/to/stylesheet.xsl")
     => XSLT("/path/to/xml2html.xsl")
     );

* By constructing transformers directly:
  $input->transform(
        AxKit2::Transformer::XSP->new(),
        AxKit2::Transformer::XSLT->new("/path/to/stylesheet.xsl"),
        AxKit2::Transformer::XSLT->new("/path/to/xml2html.xsl"),
    );

Note that XSLT() can take a list of key/value pairs to pass to the stylesheet as parameters. Unlike AxKit1 the stylesheet does NOT automatically get access to all the querystring parameters - you have to explicitly pass these in.


AxKit2 documentation  | view source Contained in the AxKit2 distribution.