Apache::AxKit::Util::LibXSLTAddonFunction - AxKit extension to load perl callbacks for XSL


Apache-AxKit-Language-LibXSLTEnhanced documentation  | view source Contained in the Apache-AxKit-Language-LibXSLTEnhanced distribution.

Index


NAME

Top

Apache::AxKit::Util::LibXSLTAddonFunction - AxKit extension to load perl callbacks for XSL

SYNOPSIS

Top

  package Apache::AxKit::Util::MiscAddonFunctions;

  use base qw( Apache::AxKit::Util::LibXSLTAddonFunction );
  use strict;
  use XML::LibXML;

  my $parser = XML::LibXML->new();

  sub init {
      my $this = shift;

      $this->addRegisteredFunction( "staticFunction", \&staticFunction );
      $this->addRegisteredFunction( "instanceMethod", sub { $this->instanceMethod( @_ ) } );
  }

  sub getNamespace {
      return "urn:perl-example-addon";
  }

  sub staticMethod {
      my $val  = shift;

      ## this is not 100% correct
      $val =~ s/<\s+/&lt;/;

      my $doc = $parser->parse_string(<<"EOT");
  <tree>
  $val
  </tree>
  EOT
      return $doc->getElementsByTagName("tree");
  }

  sub instanceMethod {
      my $this = shift;
      my $val  = shift;

     ## this is not 100% correct
      $val =~ s/<\s+/&lt;/;

      my $doc = $parser->parse_string(<<"EOT");
  <tree>
  $val
  </tree>
  EOT
      return $doc->getElementsByTagName("tree");
  }

  1;

  ## in XSL
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:UML="org.omg.xmi.namespace.UML"
                              xmlns:str="http://exslt.org/strings"
                              xmlns:pma="urn:perl-example-addon"
                              xmlns:exslt="http://exslt.org/common"
                              extension-element-prefixes="str">
  ....
  <xsl:value-of select="pma:staticMethod('Hallo')" /> 
  <xsl:value-of select="pma:instanceMethod('Hallo')" /> 
  ....

DESCRIPTION

Top

This is an abstract base class. Classes used by Apache::AxKit::Language::LibXSLTEnhanced must inherit from this class and implement the following 2 methods:

* init
* getNamespace

EXPORT

None by default.

SEE ALSO

Top

Apache::AxKit::Language::LibXSLT, AxKit, Apache::AxKit::Language::LibXSLTEnhanced

AUTHOR

Top

Tom Schindl, <tom.schindl@bestsolution.at>

COPYRIGHT AND LICENSE

Top


Apache-AxKit-Language-LibXSLTEnhanced documentation  | view source Contained in the Apache-AxKit-Language-LibXSLTEnhanced distribution.