Scroll to navigation

Recipe(3pm) User Contributed Perl Documentation Recipe(3pm)

NAME

Embperl::Recipe - base class for defining custom recipes

SYNOPSIS

   EMBPERL_RECIPE "XSLT Embperl"

DESCRIPTION

Embperl::Recipe provides basic features that are necessary for createing your own recipes. To do so you have to create a class that provides a "get_recipe" method which returns a array reference that contains the description what to do.

get_recipe ($class, $r, $recipe)

$class
The class name
$r
The Embperl request record object (Embperl::Req), maybe a derived object when running under EmbperlObject.
$recipe
The name of the recipe

The function must return an array that describes the desired action. The array contains a tree structure of providers.

Providers

read file data

Parameter:

Gives the file to read
get data from a scalar

Parameter:

Gives the source as a scalar reference
Gives the name under which this item should be cache
parse file into a Embperl tree structure

Parameter:

Gives the source
Syntax to use
compile Embperl tree structure

Parameter:

Gives the source
execute Embperl tree structure

Parameter:

Gives the source
See description of cacheing
See description of cacheing
See description of cacheing
convert Embperl tree structure to string

Parameter:

Gives the source
parse xml source for libxslt

Parameter:

Gives the xml source
parse and compile stylesheet for libxslt

Parameter:

Gives the stylesheet source
do a xsl transformation via libxslt

Parameter:

Gives the parsed xml source
Gives the compiled stylesheet source
Gives the parameters as hash ref
parse xml source for xalan

Parameter:

Gives the xml source
parse and compile stylesheet for xalan

Parameter:

Gives the stylesheet source
do a xsl transformation via xalan

Parameter:

Gives the parsed xml source
Gives the compiled stylesheet source
Gives the parameters as hash ref

Cache parameter

Format

Heres an example that show how the recipe must be build:

  sub get_recipe
    {
    my ($class, $r, $recipe) = @_ ;
    my $param  = $r -> component -> param  ;
    my @recipe ;
    push @recipe, {'type'   =>  'file'      } ;
    push @recipe, {'type'   =>  'epparse'   } ;
    push @recipe, {'type'   =>  'epcompile', cache => 1 } ;
    push @recipe, {'type'   =>  'eprun'     }  ;
    my $config = $r -> component -> config  ;
    my $xsltproc = $config -> xsltproc ;
    my @stylesheet =
        (
        { type => 'file',  filename  => $config -> xsltstylesheet, },
        { type =>  $xsltproc . '-compile-xsl', cache => 1 },
        ) ;
    push @recipe, {'type'   =>  'eptostring' } ;
    push @recipe, {'type'   =>  $xsltproc . '-parse-xml', } ;
    push @recipe, {'type'   =>  $xsltproc,   stylesheet => \@stylesheet } ;
    return \@recipe ;
    }

This corresponds to the following diagramm (when xsltproc = xalan):

    +-------------------+   +--------------------+           
    + file {inputfile}  +   +file{xsltstylesheet}+           
    +-------------------+   +--------------------+           
          |                         |                         
          v                         v                         
    +-------------------+   +-------------------+           
    + xalan-parse-xml   +   + xalan-compile-xsl +           
    +-------------------+   +-------------------+           
          |                         | 
          |                         |
          |         +-----------+   |
          +-------> + xalan     + <-+
                    +-----------+

Take a look at the recipes that comes with Embperl to get more ideas what can be done.

2023-01-22 perl v5.36.0