Fiction-XML / perl / modules / XML-Grammar-Fiction / lib / XML / Grammar / Screenplay /

package XML::Grammar::Screenplay::ToDocBook;

use strict;
use warnings;

use Carp;
use File::Spec;

use XML::LibXSLT;

use File::ShareDir ':ALL';

use XML::LibXML;
use XML::LibXSLT;

use base 'XML::Grammar::Screenplay::Base';

use Moose;

has '_data_dir' => (isa => 'Str', is => 'rw');
has '_dtd' => (isa => 'XML::LibXML::Dtd', is => 'rw');
has '_xml_parser' => (isa => "XML::LibXML", is => 'rw');
has '_stylesheet' => (isa => "XML::LibXSLT::StylesheetWrapper", is => 'rw');

=head1 NAME

XML::Grammar::Screenplay::ToDocBook - module that converts the Screenplay
XML to DocBook.

=head1 VERSION

Version 0.1.4


our $VERSION = '0.1.4';

=head2 new()

Accepts no arguments so far. May take some time as the grammar is compiled
at that point.

=head2 meta()

Internal - (to settle pod-coverage.).


sub _init
    my ($self, $args) = @_;

    my $data_dir = $args->{'data_dir'} || dist_dir ( 'XML-Grammar-Fiction');


    my $dtd =
            "Screenplay XML 0.1.0",



    my $xslt = XML::LibXSLT->new();

    my $style_doc = $self->_xml_parser()->parse_file(


    return 0;

=head2 $converter->translate_to_docbook({source => {file => $filename}, output => "string" })

Does the actual conversion. $filename is the filename to translate (currently
the only available source). 

The C<'output'> key specifies the return value. A value of C<'string'> returns 
the XML as a string, and a value of C<'xml'> returns the XML as an 
L<XML::LibXML> DOM object.


sub translate_to_docbook
    my ($self, $args) = @_;

    my $source_dom =

    my $stylesheet = $self->_stylesheet();

    my $results = $stylesheet->transform($source_dom);

    my $medium = $args->{output};

    if ($medium eq "string")
        return $stylesheet->output_string($results);
    elsif ($medium eq "xml")
        return $results;
        confess "Unknown medium";

=head1 AUTHOR

Shlomi Fish, L<>.

=head1 BUGS

Please report any bugs or feature requests to
C<bug-xml-grammar-screenplay at>, or through the web interface at
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.



Copyright 2007 Shlomi Fish, all rights reserved.

This program is released under the following license: MIT X11.