Shlomi Fish > XML-GrammarBase-v0.2.1 > XML::GrammarBase::Role::XSLT

Download:
XML-GrammarBase-v0.2.1.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: v0.2.1   Source   Latest Release: XML-GrammarBase-v0.2.3

NAME ^

XML::GrammarBase::Role::XSLT - a parameterized role for XSLT conversions.

VERSION ^

Version 0.2.1

SYNOPSIS ^

    package XML::Grammar::MyGrammar::ToOtherStuff;

    use MooX 'late';

    use XML::GrammarBase::Role::RelaxNG;
    use XML::GrammarBase::Role::XSLT;

    with ('XML::GrammarBase::Role::RelaxNG');
    with XSLT(output_format => 'html');
    with XSLT(output_format => 'docbook');

    has '+module_base' => (default => 'XML-Grammar-MyGrammar');
    has '+rng_schema_basename' => (default => 'my-grammar.rng');

    has '+to_html_xslt_transform_basename' => (default => 'mygrammar-xml-to-html.xslt');
    has '+to_docbook_xslt_transform_basename' => (default => 'mygrammar-xml-to-docbook.xslt');

    package main;

    my $xslt = XML::Grammar::MyGrammar::ToOtherStuff->new(
        data_dir => "/path/to/data-dir",
    );

    # Throws an exception on failure.
    my $as_html = $xslt->perform_xslt_translation(
        {
            output_format => 'html'
            source => {file => $input_filename, },
            output => "string",
        }
    );

PARAMATERS ^

output_format

A Perl identifier string identifying the format.

SLOTS ^

module_base

The basename of the module - used for dist dir.

data_dir

The data directory where the XML assets can be found (the RELAX NG schema, etc.)

rng_schema_basename

The Relax NG Schema basename.

to_${output_format}_xslt_transform_basename

The basename of the primary XSLT transform file. Should be overrided in the constructor or using has '+to_html'. For example:

    has '+to_html_xslt_transform_basename' => (default => 'fiction-xml-to-html.xslt');

METHODS ^

$self->rng_validate_dom($source_dom)

Validates the DOM ( $source_dom ) using the RELAX-NG schema.

$self->rng_validate_file($file_path)

Validates the file in $file_path using the RELAX-NG schema.

$self->rng_validate_string($xml_string)

Validates the XML in the $xml_string using the RELAX-NG schema.

$converter->perform_xslt_translation

This method does the actual conversion with the output format of $format. The 'source' argument points to a hash-ref with keys and values for the source. If 'file' is specified there it points to the filename to translate (currently the only available source). If 'string_ref' is specified it points to a reference to a string, with the contents of the source XML. If 'dom' is specified then it points to an XML DOM as parsed or constructed by XML::LibXML.

The 'output' key specifies the return value. A value of 'string' returns the XML as a string, and a value of 'dom' returns the XML as an XML::LibXML DOM object. If it is a hash ref then it specifies a 'file' or a 'fh' with a filepath or filehandle respectively.

An optional 'encoding' parameter determines if one should output the string as 'utf8' (the deafult - using XML::LibXSLT's output_as_chars()) or as 'bytes' - using its output_as_bytes() .

An optional 'xslt_params' parmater allows one to specify a hash of XSLT parameters.

BUILD

Moo constructor. For internal use.

make_variant

Package::Variant constructor. For internal use.

AUTHOR ^

Shlomi Fish, <shlomif at cpan.org>

BUGS ^

Please report any bugs or feature requests to bug-xml-grammarbase at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-GrammarBase. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

THANKS ^

Thanks to Matt S. Trout http://metacpan.org/author/MSTROUT and other people from #moose on irc.perl.org for helping me figure out Moo / MooX and steer me away from Any::Moose , and for writing the Moo ecosystem.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc XML::GrammarBase

You can also look for information at:

ACKNOWLEDGEMENTS ^

COPYRIGHT & LICENSE ^

Copyright 2009 Shlomi Fish.

This program is distributed under the MIT (X11) License: http://www.opensource.org/licenses/mit-license.php

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

syntax highlighting: