#!/usr/bin/perl -w
use strict;
use warnings;
use utf8;
use open qw(:std :utf8);

require $ENV{'ECHO_SCRIPTS_DIR'} . "/share/common_functions.pl";

printlnInConsole('Numbering divs.');

# Filter_5_05_number_divs.pl
# 2010-05-04
# Wolfgang Schmidle

# This Filter is a wrapper for applying div-tags.xsl using the Saxon xslt engine.


# read default parameters

#my $filter = "mpdl-workflow-settings.pl";
#my $result = `perl $filter`;

#my $saxon = ($result =~ m! saxon=([^ ]+) ! ? $1 : "" );
#my $stylesheet = ($result =~ m! stylesheet=([^ ]+) ! ? $1 : "" );

my $saxon = $ENV{'ECHO_SCRIPTS_DIR'} . "/share/thirdparty/saxonhe9-2-1-1j/saxon9he.jar";
my $stylesheet = $ENV{'ECHO_SCRIPTS_DIR'} . "/share/xslFiles/number-divs.xsl";

# text input

my $file = shift @ARGV;

my $result = `java -jar $saxon -s:"$file" -xsl:$stylesheet`;
printInOutputTextFile($result);
#print $result;
printlnInConsole('Finished.');
