Commits

Anonymous committed 6cb3ee1

Fix the ::ToTEI class.

Comments (0)

Files changed (2)

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/FictionBase/XSLT/Converter.pm

 use XML::LibXML;
 use XML::LibXSLT;
 
-use base 'XML::Grammar::Screenplay::Base';
-
 use Moose;
 
 has '_data_dir' => (isa => 'Str', is => 'rw');
+has '_data_dir_from_input' => (isa => 'Str', is => 'rw', init_arg => 'data_dir',);
 has '_rng' => (isa => 'XML::LibXML::RelaxNG', is => 'rw');
 has '_xml_parser' => (isa => "XML::LibXML", is => 'rw');
 has '_stylesheet' => (isa => "XML::LibXSLT::StylesheetWrapper", is => 'rw');
-has 'rng_basename' => (is => 'ro', isa => 'Str',);
-has 'xslt_basename' => (is => 'ro', isa => 'Str',);
+has 'rng_basename' => (is => 'ro', isa => 'Str', required => 1,);
+has 'xslt_basename' => (is => 'ro', isa => 'Str', required => 1,);
 
 =head1 NAME
 
 
 Internal - (to settle pod-coverage.).
 
+=head2 BUILD()
+
+Internal - (to settle pod-coverage.).
+
 =cut
 
-sub _init
+sub BUILD
 {
-    my ($self, $args) = @_;
+    my ($self) = @_;
 
-    my $data_dir = $args->{'data_dir'} ||
+    my $data_dir = $self->_data_dir_from_input() ||
         dist_dir( 'XML-Grammar-Fiction');
 
     $self->_data_dir($data_dir);

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Screenplay/ToTEI.pm

 use strict;
 use warnings;
 
-use Carp;
-use File::Spec;
-
-use XML::LibXSLT;
-
-use File::ShareDir ':ALL';
-
-use XML::LibXML;
-use XML::LibXSLT;
-
 use Moose;
 
 extends('XML::Grammar::FictionBase::XSLT::Converter');
 
 Internal - (to settle pod-coverage.).
 
-=cut
-
-sub _init
-{
-    my ($self, $args) = @_;
-
-    my $data_dir = $args->{'data_dir'} ||
-        dist_dir( 'XML-Grammar-Fiction');
-
-    $self->_data_dir($data_dir);
-
-    my $rngschema =
-        XML::LibXML::RelaxNG->new(
-            location =>
-            File::Spec->catfile(
-                $self->_data_dir(), 
-                "screenplay-xml.rng"
-            ),
-        );
-
-    $self->_rng($rngschema);
-
-    $self->_xml_parser(XML::LibXML->new());
-
-    my $xslt = XML::LibXSLT->new();
-
-    my $style_doc = $self->_xml_parser()->parse_file(
-            File::Spec->catfile(
-                $self->_data_dir(), 
-                "screenplay-xml-to-tei.xslt"
-            ),
-        );
-
-    $self->_stylesheet($xslt->parse_stylesheet($style_doc));
-
-    return 0;
-}
-
 =head2 $converter->translate_to_tei({source => {file => $filename}, output => "string" })
 
 Does the actual conversion. $filename is the filename to translate (currently
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.