The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Apache::AxKit::Language::YPathScript

Sub-class of Apache::AxKit::Language and XML::XPathScript.

global variables

$VERSION

$stash - Hash table of stylesheets

Imported modules

Apache
Apache::File
XML::XPath 1.00
XML::XPath::XMLParser
XML::XPath::Node
XML::XPath::NodeSet
XML::Parser
Apache::AxKit::Provider
Apache::AxKit::Language
Apache::AxKit::Cache
Apache::AxKit::Exception
Apache::AxKit::CharsetConv
X::X::Processor

Functions

$xps = new Apache::AxKit::Language::YPathScript($xml_provider, $style_provider)

Constructs a new YPathScript language interpreter out of the provided providers.

$rc = handler( $class, $request, $xml_provider, $style_provider )
        The function called by Apache. Does all cache-managing magic.
        Not present in X::X.
$file_content = include_file( $filename )
$file_content = include_file( $filename, @includestack )

Overloaded from XML::XPathScript in order to provide URI-based stylesheet inclusions: $filename may now be any AxKit URI. The AxKit language class drops support for plain filenames that exists in the ancestor class: this means that include directives like

   <!-- #include file="/some/where.xps" -->

in existing stylesheets should be turned into

   <!-- #include file="file:///some/where.xps" -->

in order to work with AxKit.

$doc = get_source_tree( $xml_provider )
        Reads an XML document from the provider.
        Return the doc as a string.

        Not present in X::X
$string = read_stylesheet( $stylesheet )

Read the $stylesheet (which can be a filehandler or a string). Used by extract.

Overrides the XML::XPathScript method

$self->debug( $level, $message )

Prints $message if the requested debug level is equal or smaller than $level.

$self->die( $suicide_note )
$compiled_package = $self->get_stylesheet( $stylesheet_provider )
check_inc_mtime( $mtime, $provider, \@includes )
        Check the modified time of included files

        Use Apache::Axkit::Provider

        Return 0 if recompile is required, 1 otherwise (?)

        Not in X::X.
compile( $package, $provider )

Compile the XPS stylesheet given in $provider into the package $package and wrap it in the function &handler of that package.

Pretty much the same as for X::X

sub compile { my ($self, $package, $provider) = @_;

    $self->debug( 5, 'Compiling package...' );

    my $script = $self->extract($provider);
    
    my $eval = join('',
            'package ',
            $package,
            '; use Apache qw(exit);',
            'use XML::XPath::Node;',
            'Apache::AxKit::Language::YPathScript::Processor->import;',
            'sub handler {',
            'my ($r, $xp, $t) = @_;',
            "\n#line 1 " . $provider->key() . "\n",
            $script,
            ";\n",
            'return Apache::Constants::OK;',
            "\n}",
            );

    local $^W;

    AxKit::Debug(10, "Compiling script:\n$eval\n");
    eval $eval;
    if ($@) {
        AxKit::Debug(1, "Compilation failed: $@");
        throw $@;
    }
}
$file_content = include_file( $filename, $provider, $scalar_output )

Wrapper around extract. Verify if $filename hasn't already been extracted before.

Exists in X::X in a simplified version.

$nodeset = XML::XPath::Function::document( $node, $uri )
        Reads XML given in $uri, parses it and returns it in a nodeset.

        Pretty similar to the one in X::X, except for details like inclusion
        of scheme axkit://.
$mtime = get_mtime( $class, $provider )

Returns the mtime of $provider.

$class is not used.

The global $stash is modified as a side-effect.

Does not exist in X::X.

NAME

Apache::AxKit::Language::YPathScript - An XML Stylesheet Language

SYNOPSIS

  AxAddStyleMap "application/x-xpathscript => \
        Apache::AxKit::Language::YPathScript"

DESCRIPTION

This documentation has been removed. The definitive reference for XPathScript is now at http://axkit.org/docs/xpathscript/guide.dkb in DocBook format.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 67:

'=item' outside of any '=over'

Around line 553:

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