Catalyst::View::XML::Generator - Serialize the stash as XML using XML::Generator::PerlData


Catalyst-View-XML-Generator documentation Contained in the Catalyst-View-XML-Generator distribution.

Index


Code Index:

NAME

Top

Catalyst::View::XML::Generator - Serialize the stash as XML using XML::Generator::PerlData

VERSION

Top

Version 0.02

SYNOPSIS

Top

    __PACKAGE__->config(
        'XML::Generator' => {
            rootname => 'document',
            attrmap => {
                action => [qw( class name )],
                view   => [qw( type )]
            }
        }
    );

DESCRIPTION

Top

This Catalyst view renders the context stash as XML using XML::Generator::PerlData. This enables you to quickly render customized XML output using a set of rules to dictate which hash parameters will be stored as attributes, elements, and other configuration options.

AUTHOR

Top

Michael Nachbaur, <mike@nachbaur.com>

BUGS

Top

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

SEE ALSO

Top

Catalyst, Catalyst::View, XML::Generator::PerlData

SUPPORT

Top

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

    perldoc Catalyst::View::XML::Generator

You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-View-XML-Generator

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Catalyst-View-XML-Generator

* CPAN Ratings

http://cpanratings.perl.org/d/Catalyst-View-XML-Generator

* Search CPAN

http://search.cpan.org/dist/Catalyst-View-XML-Generator/

* Download the source from Github

http://github.com/NachoMan/Catalyst-View-XML-Generator/

COPYRIGHT & LICENSE

Top


Catalyst-View-XML-Generator documentation Contained in the Catalyst-View-XML-Generator distribution.
package Catalyst::View::XML::Generator;
use Moose;
BEGIN { extends 'Catalyst::View' }

use XML::SAX::Writer;
use XML::Generator::PerlData;
use namespace::clean;

our $VERSION = '0.02';

sub process {
    my ($self, $c) = @_;

    my $conf = $c->config->{'View::XML'};

    my $content = '';
    my $builder = XML::SAX::Writer->new(Output => \$content);
    my $generator = XML::Generator::PerlData->new(
        Handler => $builder,
        %{ $conf }
    );

    my $dom = $generator->parse($c->stash);

    $c->response->content_type("text/xml");
    $c->response->body($content);
    1;
}

1;