Taxi::Mysql::Format::XSLT - hit list formatter: XSL-transformed flat XML


NAME

Taxi::Mysql::Format::XSLT - hit list formatter: XSL-transformed flat XML

(Back to Top)


SYNOPSIS

 ##========================================================================
 ## PRELIMINARIES
 use Taxi::Mysql::Format::XSLT;
 ##========================================================================
 ## Constructors etc.
 $q = $CLASS_OR_OBJ->new(%args);
 ##========================================================================
 ## Initialization / reset
 $xslt = $fmt->newXslt();
 ##========================================================================
 ## Stylesheet parsing
 $stylesheet = $fmt->parseStyleString($string);
 $stylesheet = $fmt->parseStyleFile($filename);
 $stylesheet = $fmt->parseStyleFh($filehandle);
 ##========================================================================
 ## Transformation
 $stylesheet = $fmt->stylesheet($hitList);
 $results = $fmt->transform($hitList);
 \%params = $fmt->xsltParams($hitList);
 ##========================================================================
 ## Output
 $contentType = $fmt->contentType();
 $str = $fmt->toString($hitList);
 undef = $fmt->toFile($hitList,$filename);
 undef = $fmt->toFh($hitList,$fh);

(Back to Top)


DESCRIPTION

Taxi::Mysql::Format::XSLT is a class for formatting HitList objects via user-specified XSL transformation of an XML document containing a ``flat'' series of records.

Globals etc.

Variable: @ISA

Taxi::Mysql::Format::XML inherits from and implements the API specified by Taxi::Mysql::Format::XML. XSL transformation is applied after XML generation has succeeded.

Variable: $_parser

Package-global variable holding the default XML::LibXML (parser) object used for parsing user-specified stylesheets.

Constructors etc.

new
 $q = $CLASS_OR_OBJ->new(%args);

Object structre / %args:

   {
    ##-- Stylesheet data
    parser   => $xml_parser, ##-- XML::LibXML::Parser object; default = $_parser
    xslt     => $xslt,       ##-- an XML::LibXSLT object; default = (new object)
    styledoc => $doc,        ##-- an XML::LibXML::Document for the stylesheet (see parseStyle*() methods)
    stylesheet => $style,    ##-- an XML::LibXSLT::Stylesheet object (parsed stylesheet)
    params   => \%params,    ##-- params for $style->transform()
    ##-- XML formatting (from ../XML)
    xmlVersion    => $version,  ##-- output XML version (default="1.0")
    xmlEncoding   => $encoding, ##-- output XML encoding (default="UTF-8")
    xmlHitListElt => $listElt,  ##-- element for whole HitList (root); default='hitlist'
    xmlHitElt     => $hitElt,   ##-- element for single hits; default='hit'
    xmlTokElt     => $tokElt,   ##-- element for single tokens; default='tok'
    xmlHitNAttr   => $hitNAttr, ##-- hit-number attribute (default="n")
    pretty        => $level,    ##-- $format argument for XML::LibXML::Document->toXXX()
    ##-- Source data (from ../../Format)
    index  => $index,     ##-- underlying Taxi::Mysql object
   }
free()

Deletes parser, xslt object, and any parameters to avoid circular references.

Initialization / reset

newXslt
 $xslt = $CLASS_OR_OBJ->newXslt()

Returns default XML::LibXSLT object to be used for stylesheet parsing. Method may be overridden by descendant classes, e.g. to call $xslt->register_function() for subclass-specific functions.

Stylesheet parsing

parseStyleString
 $stylesheet = $fmt->parseStyleString($string);

Parses stylesheet to use for transformation from a string.

parseStyleFile
 $stylesheet = $fmt->parseStyleFile($filename);

Parses stylesheet to use for transformation from a named file.

parseStyleFh
 $stylesheet = $fmt->parseStyleFh($filehandle);

Parses stylesheet to use for transformation from an open filehandle.

Transformation

stylesheet
 $stylesheet = $fmt->stylesheet($hitList);

Returns stylesheet (as an XML::LibXSLT::Stylesheet object?) to be used for transformation. May be re-implemented in descendant classes to generate stylesheet on-demand. Default implementation just returns $fmt->{stylesheet}.

transform
 $results = $fmt->transform($hitList);

Transforms the hitListDocument() for $hitList by means of the stylesheet $fmt->stylesheet($hitList) and the parameters returned by $fmt->xsltParams($hitList).

xsltParams
 \%params = $fmt->xsltParams($hitList);

Should return parameters for XSL transformations. Default version just returns $fmt->{params}.

Output

contentType
 $contentType = $fmt->contentType();

Default version uses stylesheet()->media_type(). If no stylesheet is available, 'text/xml' is returned as a default.

toString
 $str = $fmt->toString($hitList);
toFile
 undef = $fmt->toFile($hitList,$filename);
toFh
 undef = $fmt->toFh($hitList,$fh);

(Back to Top)


ACKNOWLEDGEMENTS

Perl by Larry Wall.

(Back to Top)


AUTHOR

Bryan Jurish <moocow@ling.uni-potsdam.de>

(Back to Top)


COPYRIGHT AND LICENSE

Copyright (C) 2006 by Bryan Jurish

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.

(Back to Top)


SEE ALSO

perl(1), Taxi::Mysql(3perl), Taxi::Mysql::Format(3perl), Taxi::Mysql::Format::XML(3perl), Taxi::Mysql::Format::XSLTBibl(3perl).

(Back to Top)

 Taxi::Mysql::Format::XSLT - hit list formatter: XSL-transformed flat XML