Matt Sergeant > AxKit2 > AxKit2::Processor

Download:
AxKit2-1.1.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Source  

NAME ^

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

DESCRIPTION ^

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 ^

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:

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.

syntax highlighting: