Commits

Anonymous committed 68efc49

Added the trailing slash in the xsltproc output.

Comments (0)

Files changed (2)

modules/App-XML-DocBook-Docmake/lib/App/XML/DocBook/Docmake.pm

 use warnings;
 
 use Getopt::Long qw(GetOptionsFromArray);
+use File::Path;
 
 use base 'Class::Accessor';
 
     return $self->_run_xslt();
 }
 
+sub _mkdir
+{
+    my ($self, $dir) = @_;
+
+    mkpath($dir);
+}
+
 sub _run_mode_xhtml
 {
     my $self = shift;
 
+    # Create the directory, because xsltproc requires it.
+    $self->_mkdir($self->_output_path());
+
     return $self->_run_xslt();
 }
 
         ;
 }
 
+sub _calc_output_param_for_xslt
+{
+    my $self = shift;
+    my $args = shift;
+
+    my $output_path = $self->_output_path();
+    if (defined($args->{output_path}))
+    {
+        $output_path = $args->{output_path};
+    }
+
+    if (!defined($output_path))
+    {
+        die "Output path not specified!";
+    }
+
+    # If it's XHTML, then it's a directory and xsltproc requires that
+    # it will have a trailing slash.
+    if ($self->_mode() eq "xhtml")
+    {
+        if ($output_path !~ m{/\z})
+        {
+            $output_path .= "/";
+        }
+    }
+
+    return ["-o", $output_path];
+}
+
 sub _run_xslt
 {
     my $self = shift;
         @stylesheet_params = ($self->_stylesheet());
     }
     
-    my $output_path = $self->_output_path();
-    if (defined($args->{output_path}))
-    {
-        $output_path = $args->{output_path};
-    }
-
-    if (!defined($output_path))
-    {
-        die "Output path not specified!";
-    }
-
     return $self->_exec_command(
         [
             "xsltproc",
-            "-o", $output_path,
+            @{$self->_calc_output_param_for_xslt($args)},
             (map { ("--stringparam", @$_ ) } @{$self->_xslt_stringparams()}),
             @stylesheet_params,
             $self->_input_path(),

modules/App-XML-DocBook-Docmake/t/01-use.t

     push @commands_executed, [@$cmd];
 }
 
+sub _mkdir
+{
+    # Do nothing - to override.
+}
+
 sub debug_commands
 {
     my @ret = @commands_executed;
             "-v",
             "--stringparam",
             "chunk.section.depth=2",
-            "-o", "output.xhtml",
+            "-o", "my-output-dir",
             "xhtml",
             "input.xml",
             ]});
         [
             [
                 "xsltproc",
-                "-o", "output.xhtml",
+                "-o", "my-output-dir/",
                 "--stringparam", "chunk.section.depth", "2",
                 "http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl",
                 "input.xml",