diff --git a/data/System/XslFoContrib.txt b/data/System/XslFoContrib.txt new file mode 100644 index 0000000..465a7d4 --- /dev/null +++ b/data/System/XslFoContrib.txt @@ -0,0 +1,162 @@ +%META:TOPICINFO{author="micha" comment="reprev" date="1364373322" format="1.1" reprev="3" version="3"}% +---+!! %TOPIC% +%SHORTDESCRIPTION% + +%TOC% + +This extension allows to publish structured content using XSL Formatting +Objects (XSL-FO). It therefore leverages conversion of structured meta data +from XML to PDF or RTF +using a print formater such as [[http://xmlgraphics.apache.org/fop/][Apache™ FOP]]. + +As a print formatter Apache™ FOP is able to produce the +resulting pages to a specified output. Output formats currently supported +include + + * PDF, + * PS, PCL, + * AFP, + * XML (area tree representation), + * Print, + * PNG, + * RTF and + * TXT. + +The primary output target is PDF. + +Conversion of content is primarily done using a wiki application that reads +native Foswiki data to render it as XML which is then converted into XSL-FO using a XSLT style sheet. + +---++ Usage + +The fop renderer itself is triggered by calling the =fop= service which then will process the content specified. + +| *Url Parameter* | *Description* | +| section | named section of the current topic to extract content from | +| format | defines the output format, defaults to pdf | +| xsltopic | topic holding the xsl transformation, defaults to the current topic | +| xslsection | named section of the xsltopic to extract the transformation code from | +| xslattachment | defines an attachment at the xsltopic holding the transformation file (specify either xslsection or xslattachment but not both) | +| filename | optionally define the name of the file being generated, defaults to <current-topic>.<format> | +| template | optionally define a view template to be used to render the FO content; content will be inserted to the template specifying a =%TEXT%= macro | + +---++ Examples + +---+++ Fo Mode + + * pdf: %SCRIPTURL{"fop"}%/%WEB%/%TOPIC%?section=fo + * rtf: %SCRIPTURL{"fop"}%/%WEB%/%TOPIC%?section=fo&format=rtf&filename=myreport.rtf + +%TWISTY{showlink="show fo ..." hidelink="hide fo ..."}% + +%STARTSECTION{"fo"}% + + + + + + + + + + + + + + + + + + Hello, %WIKINAME%! + + + + The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to + enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML + has been designed for ease of implementation and for interoperability with both SGML and HTML. + + + + + +%ENDSECTION{"fo"}% + +%ENDTWISTY% + +---+++ XSL mode + + * %SCRIPTURL{"fop"}%/%WEB%/%TOPIC%?section=xml&xslsection=transform + * %SCRIPTURL{"fop"}%/%WEB%/%TOPIC%?section=xml&xslsection=transform&format=rtf + +%TWISTY{showlink="show xml/xsl ..." hidelink="hide xml/xsl..."}% + + +%STARTSECTION{"xml"}%%WIKINAME%%ENDSECTION{"xml"}% + + + +%STARTSECTION{"transform"}% + + + + + + + + + + + + + + Hello, ! + + + + + + +%ENDSECTION{"transform"}% + +%ENDTWISTY% + +---++ Installation Instructions + +%$INSTALL_INSTRUCTIONS% + +---++ Info + + +| Author(s): | Michael Daum| +| Copyright: | © 2013 Michael Daum http://michaeldaumconsulting.com | +| License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] | +| Release: | %$RELEASE% | +| Version: | %$VERSION% | +| Change History: |   | +| 24 Jun 2013: | initial release | +| Dependencies: | %$DEPENDENCIES% | +| Home page: | Foswiki:Extensions/%TOPIC% | +| Support: | Foswiki:Support/%TOPIC% | diff --git a/lib/Foswiki/Contrib/XslFoContrib.pm b/lib/Foswiki/Contrib/XslFoContrib.pm new file mode 100644 index 0000000..ede4a37 --- /dev/null +++ b/lib/Foswiki/Contrib/XslFoContrib.pm @@ -0,0 +1,263 @@ +# See bottom of file for default license and copyright information +package Foswiki::Contrib::XslFoContrib; + +use strict; +use warnings; + +our $VERSION = '1.00'; +our $RELEASE = '1.00'; +our $SHORTDESCRIPTION = 'FOP print formatter'; + +use Foswiki (); +use Foswiki::UI (); +use Foswiki::Func (); +use File::Temp (); + +use constant DEBUG => 0; + +sub writeDebug { + print STDERR "- XslFoContrib - " . $_[0] . "\n" if DEBUG; +} + +sub fop { + my ($session) = @_; + + writeDebug("called fop"); + + my $request = $session->{request}; + my $response = $session->{response}; + + my $web = $session->{webName}; + my $topic = $session->{topicName}; + my $section = $request->param("section"); + my $format = $request->param("format") || 'pdf'; + my $xslWebTopic = $request->param("xsltopic"); + my $xslSection = $request->param("xslsection"); + my $xslAttachment = $request->param("xslattachment"); + my $fileName = $request->param("filename") || $topic.".".$format; + $fileName .= ".".$format unless $fileName =~ /\.(pdf|rtf|txt|html|ps|afp|tiff|png|pcl)$/; # TODO: what else? + + Foswiki::UI::checkTopicExists($session, $web, $topic, 'view'); + + my ($meta, $text) = Foswiki::Func::readTopic($web, $topic); + Foswiki::UI::checkAccess($session, 'VIEW', $meta); + + writeDebug("topic=$web.$topic"); + + # get content + my $content = '%TEXT%'; + my $xsl; + my $template = $request->param('template'); + if ($template) { + Foswiki::Func::loadTemplate($template); + $content = Foswiki::Func::expandTemplate("xml"); + $xsl = Foswiki::Func::expandTemplate("xsl"); + } + + if (defined $section) { + writeDebug("section=$section"); + $text = extractSection($text, $section) || ''; + } else { + $text =~ s/.*%STARTINCLUDE%\s*//gs; + $text =~ s/\s*%STOPINCLUDE%.*//gs; + } + + $content =~ s/%TEXT%/$text/g; + $content = Foswiki::Func::expandCommonVariables($content, $topic, $web, $meta); + $content =~ s/(]+src=["'])([^"']+)(["'])/$1.toFileUrl($2).$3/ge; + $content =~ s/(]+href=["'])([^"']+)(["'])/$1.toFileUrl($2).$3/ge; + $content =~ s/<\/?noautolink>||<\/?literal>//g; + #writeDebug("content=$content"); + + my $xslWeb = $web; + my $xslTopic = $topic; + my $xslMeta = $meta; + + if (defined $xslWebTopic) { + ($xslWeb, $xslTopic) = Foswiki::Func::normalizeWebTopicName($web, $xslWebTopic); + writeDebug("xsl web=$xslWeb, topic=$xslTopic"); + } + + if ($xslAttachment) { + writeDebug("xslAttachment=$xslAttachment"); + $xsl = Foswiki::Func::readAttachment($xslWeb, $xslTopic, $xslAttachment); + } else { + if (defined $xslWebTopic || defined $xslSection) { + ($xslMeta, $xsl) = Foswiki::Func::readTopic($xslWeb, $xslTopic); + } + if (defined $xslSection) { + writeDebug("xslSection=$xslSection"); + $xsl = extractSection($xsl, $xslSection) || ''; + } else { + if (defined $xsl) { + $xsl =~ s/.*%STARTINCLUDE%\s*//gs; + $xsl =~ s/\s*%STOPINCLUDE%.*//gs; + } + } + } + + my $stdout; + my $exit; + my $stderr; + + if (defined $xsl) { + # xsl mode + writeDebug("xsl mode, xslTopic=$xslTopic, xslWeb=$xslWeb"); + + Foswiki::Func::pushTopicContext($xslWeb, $xslTopic) if ($web ne $xslWeb || $topic ne $xslTopic); + + $xsl = Foswiki::Func::expandCommonVariables($xsl, $xslTopic, $xslWeb, $xslMeta); + $xsl =~ s/(]+src=["'])([^"']+)(["'])/$1.toFileUrl($2).$3/ge; + $xsl =~ s/(]+href=["'])([^"']+)(["'])/$1.toFileUrl($2).$3/ge; + $xsl =~ s/<\/?noautolink>||<\/?literal>//g; + + #writeDebug("xsl=$xsl"); + + Foswiki::Func::popTopicContext() if ($web ne $xslWeb || $topic ne $xslTopic);; + + my $xmlFile = new File::Temp(SUFFIX => '.xml', UNLINK => (DEBUG ? 0 : 1)); + writeDebug("xmlFile=" . $xmlFile->filename); + + print $xmlFile $content; + + my $xslFile = new File::Temp(SUFFIX => '.xsl', UNLINK => (DEBUG ? 0 : 1)); + writeDebug("xslFile=" . $xslFile->filename); + + print $xslFile $xsl; + + my $fopCmd = $Foswiki::cfg{XslFoContrib}{FopXmlCommand} + || "/usr/bin/fop -xml %XMLFILE|F% -xsl %XSLFILE% -%FORMAT|S% -"; + + writeDebug("fopCmd=$fopCmd"); + + ($stdout, $exit, $stderr) = Foswiki::Sandbox::sysCommand( + undef, $fopCmd, + XMLFILE => $xmlFile->filename, + XSLFILE => $xslFile->filename, + FORMAT => $format, + ); + + } else { + # fo mode + writeDebug("fo mode"); + + my $foFile = new File::Temp(SUFFIX => '.fo', UNLINK => (DEBUG ? 0 : 1)); + writeDebug("foFile=" . $foFile->filename); + + print $foFile $content; + + my $fopCmd = $Foswiki::cfg{XslFoContrib}{FopFoCommand} + || "/usr/bin/fop %FOFILE|F% -%FORMAT|S% - "; + + writeDebug("fopCmd=$fopCmd"); + + ($stdout, $exit, $stderr) = Foswiki::Sandbox::sysCommand( + undef, $fopCmd, + FOFILE => $foFile->filename, + FORMAT => $format, + ); + } + +# writeDebug("stderr=$stderr, exit=$exit"); +# if ($stderr) { +# print STDERR "- XslFoContrib - $stderr\n"; +# } + + my $mimeType = formatToMimeType($format); + writeDebug("format=$format, mimeType=$mimeType"); + + if ($exit) { + my $line = 1; + $content =~ s/^/sprintf("%03d", $line++)." "/gem; + $session->writeCompletePage("Error: " . $stderr . "\n" . $content .(defined $xsl?"\n'$xsl'":""), "txt", "text/plain"); + } else { + $response->header( + -status => 200, + -type => $mimeType, + -content_disposition => "inline; filename=\"$fileName\"", + ); + $response->print($stdout); + } + + return; +} + +my $types; # cache content of MimeTypesFileName + +sub formatToMimeType { + my $format = shift; + + #return "application/msword" if $format eq 'rtf'; + + my $mimeType = 'application/octet-stream'; + if ($format) { + $types = Foswiki::Func::readFile($Foswiki::cfg{MimeTypesFileName}) unless defined $types; + + if ($types =~ /^([^#]\S*).*?\s$format(?:\s|$)/im) { + $mimeType = $1; + } + } + + return $mimeType; +} + +sub extractSection { + my ($text, $name) = @_; + + # SMELL: no Func api for parseSections + my ($ntext, $sections) = Foswiki::parseSections($text); + + for my $s (@$sections) { + if ($s->{type} eq 'section' && $s->{name} eq $name) { + my $section = substr($ntext, $s->{start}, $s->{end} - $s->{start}); + $section =~ s/^\s*//gs; + $section =~ s/\s*$//gs; + return $section; + } + } + + return; +} + +sub toFileUrl { + my $url = shift; + + my $fileUrl = $url; + + if ($fileUrl =~ /^(?:$Foswiki::cfg{DefaultUrlHost})?$Foswiki::cfg{PubUrlPath}(.*)$/) { + $fileUrl = $1; + $fileUrl =~ s/\?.*$//; + if ($fileUrl =~ /^\/(.*)\/([^\/]+)\/[^\/]+$/) { + my $web = $1; + my $topic = $2; + my $wikiName = Foswiki::Func::getWikiName(); + writeDebug("checking access for $wikiName on $web.$topic"); + return '' unless Foswiki::Func::checkAccessPermission("VIEW", $wikiName, undef, $topic, $web); + } + $fileUrl = "file://".$Foswiki::cfg{PubDir}.$fileUrl; + } else { + writeDebug("url=$url does not point to the local server"); + } + + writeDebug("url=$url, fileUrl=$fileUrl"); + return $fileUrl; +} + +1; + +__END__ +Foswiki - The Free and Open Source Wiki, http://foswiki.org/ + +Copyright (C) 2013 Michael Daum http://michaeldaumconsulting.com + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. For +more details read LICENSE in the root of this distribution. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +As per the GPL, removal of this notice is prohibited. diff --git a/lib/Foswiki/Contrib/XslFoContrib/Config.spec b/lib/Foswiki/Contrib/XslFoContrib/Config.spec new file mode 100644 index 0000000..29a9b35 --- /dev/null +++ b/lib/Foswiki/Contrib/XslFoContrib/Config.spec @@ -0,0 +1,19 @@ +# ---+ Extensions +# ---++ XslFoContrib +# **PERL H** +# This setting is required to register the fop service +$Foswiki::cfg{SwitchBoard}{fop} = { + package => 'Foswiki::Contrib::XslFoContrib', + function => 'fop', + context => { fop => 1 }, +}; + +# **COMMAND** +# fop commandline tool to process FO directly +$Foswiki::cfg{XslFoContrib}{FopFoCommand} = '$Foswiki::cfg{ToolsDir}/fop/fop -c $Foswiki::cfg{ToolsDir}/fop/conf/fop.conf %FOFILE|F% -%FORMAT|S% -'; + +# **COMMAND** +# fop commandline tool to transform an input xml using xsl +$Foswiki::cfg{XslFoContrib}{FopXmlCommand} = '$Foswiki::cfg{ToolsDir}/fop/fop -c $Foswiki::cfg{ToolsDir}/fop/conf/fop.conf -xml %XMLFILE|F% -xsl %XSLFILE% -%FORMAT|S% -'; + +1; diff --git a/lib/Foswiki/Contrib/XslFoContrib/DEPENDENCIES b/lib/Foswiki/Contrib/XslFoContrib/DEPENDENCIES new file mode 100644 index 0000000..e69de29 diff --git a/lib/Foswiki/Contrib/XslFoContrib/MANIFEST b/lib/Foswiki/Contrib/XslFoContrib/MANIFEST new file mode 100644 index 0000000..d8642c1 --- /dev/null +++ b/lib/Foswiki/Contrib/XslFoContrib/MANIFEST @@ -0,0 +1,17 @@ +data/System/XslFoContrib.txt 0644 +lib/Foswiki/Contrib/XslFoContrib/Config.spec 0644 +lib/Foswiki/Contrib/XslFoContrib.pm 0644 +tools/fop/build/fop-hyph.jar 0755 +tools/fop/build/fop.jar 0755 +tools/fop/fop 0755 +tools/fop/fop.bat 0755 +tools/fop/lib/avalon-framework-4.2.0.jar 0755 +tools/fop/lib/batik-all-1.7.jar 0755 +tools/fop/lib/commons-io-1.3.1.jar 0755 +tools/fop/lib/commons-logging-1.0.4.jar 0755 +tools/fop/lib/serializer-2.7.0.jar 0755 +tools/fop/lib/xalan-2.7.0.jar 0755 +tools/fop/lib/xercesImpl-2.7.1.jar 0755 +tools/fop/lib/xml-apis-1.3.04.jar 0755 +tools/fop/lib/xml-apis-ext-1.3.04.jar 0755 +tools/fop/lib/xmlgraphics-commons-1.5.jar 0755 diff --git a/lib/Foswiki/Contrib/XslFoContrib/build.pl b/lib/Foswiki/Contrib/XslFoContrib/build.pl new file mode 100755 index 0000000..ed1a764 --- /dev/null +++ b/lib/Foswiki/Contrib/XslFoContrib/build.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; + +BEGIN { unshift @INC, split( /:/, $ENV{FOSWIKI_LIBS} ); } + +use Foswiki::Contrib::Build; + +my $build = new Foswiki::Contrib::Build('XslFoContrib'); + +$build->build( $build->{target} ); + +1; diff --git a/tools/fop/build/fop-hyph.jar b/tools/fop/build/fop-hyph.jar new file mode 100644 index 0000000..e3aba33 Binary files /dev/null and b/tools/fop/build/fop-hyph.jar differ diff --git a/tools/fop/build/fop.jar b/tools/fop/build/fop.jar new file mode 100644 index 0000000..5113064 Binary files /dev/null and b/tools/fop/build/fop.jar differ diff --git a/tools/fop/conf/fop.conf b/tools/fop/conf/fop.conf new file mode 100644 index 0000000..e4a017c --- /dev/null +++ b/tools/fop/conf/fop.conf @@ -0,0 +1,464 @@ + + + + + + + + + + . + + + 72 + + 72 + + + + + + + + + + + flate + + + + + + + + + + + + + + + + + + + + + + + + 240 + 2.5 + resources.afp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/fop/fop b/tools/fop/fop new file mode 100755 index 0000000..aca642b --- /dev/null +++ b/tools/fop/fop @@ -0,0 +1,255 @@ +#! /bin/sh +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Shell script to run FOP, adapted from the Jakarta-Ant project. + +rpm_mode=true +java_exec_args="-Djava.awt.headless=true" +fop_exec_args= +no_config=false +fop_exec_debug=false +show_help=false +for arg in "$@" ; do + if [ "$arg" = "--noconfig" ] ; then + no_config=true + elif [ "$arg" = "--execdebug" ] ; then + fop_exec_debug=true + elif [ my"$arg" = my"--h" -o my"$arg" = my"--help" ] ; then + show_help=true + fop_exec_args="$fop_exec_args -h" + else + if [ my"$arg" = my"-h" -o my"$arg" = my"-help" ] ; then + show_help=true + fi + fop_exec_args="$fop_exec_args \"$arg\"" + fi +done + +# Source/default fop configuration +if $no_config ; then + rpm_mode=false +else + # load system-wide fop configuration + if [ -f "/etc/fop.conf" ] ; then + . /etc/fop.conf + fi + + # load user fop configuration + if [ -f "$HOME/.fop/fop.conf" ] ; then + . $HOME/.fop/fop.conf + fi + if [ -f "$HOME/.foprc" ] ; then + . "$HOME/.foprc" + fi + + # provide default configuration values + if [ -z "$rpm_mode" ] ; then + rpm_mode=false + fi + if [ -z "$usejikes" ] ; then + usejikes=$use_jikes_default + fi +fi + +# Setup Java environment in rpm mode +if $rpm_mode ; then + if [ -f /usr/share/java-utils/java-functions ] ; then + . /usr/share/java-utils/java-functions + set_jvm + set_javacmd + fi +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +case "`uname`" in + CYGWIN*) cygwin=true ;; + Darwin*) darwin=true + if [ -z "$JAVA_HOME" ] ; then + JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home + fi + ;; +esac + +if [ -z "$FOP_HOME" -o ! -d "$FOP_HOME" ] ; then + ## resolve links - $0 may be a link to fop's home + PRG="$0" + progname=`basename "$0"` + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi + done + + FOP_HOME=`dirname "$PRG"` + + # make it fully qualified + FOP_HOME=`cd "$FOP_HOME" && pwd` +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$FOP_HOME" ] && + FOP_HOME=`cygpath --unix "$FOP_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +if [ "$OS" = "Windows_NT" ] ; then + pathSepChar=";" +else + pathSepChar=":" +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java 2> /dev/null ` + if [ -z "$JAVACMD" ] ; then + JAVACMD=java + fi + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." + echo " We cannot execute $JAVACMD" + exit 1 +fi + +if [ -n "$CLASSPATH" ] ; then + LOCALCLASSPATH=$CLASSPATH +fi + +# add fop.jar, fop-sandbox and fop-hyph.jar, which reside in $FOP_HOME/build +LOCALCLASSPATH=${FOP_HOME}/build/fop.jar${pathSepChar}${FOP_HOME}/build/fop-sandbox.jar${pathSepChar}${FOP_HOME}/build/fop-hyph.jar${pathSepChar}$LOCALCLASSPATH + +# add in the dependency .jar files, which reside in $FOP_HOME/lib +OLD_IFS=$IFS +IFS=" +" +DIRLIBS=${FOP_HOME}/lib/*.jar +for i in ${DIRLIBS} +do + # if the directory is empty, then it will return the input string + # this is stupid, so case for it + if [ "$i" != "${DIRLIBS}" ] ; then + if [ -z "$LOCALCLASSPATH" ] ; then + LOCALCLASSPATH=$i + else + LOCALCLASSPATH="$i"${pathSepChar}$LOCALCLASSPATH + fi + fi +done +IFS=$OLD_IFS + +# add in user-defined hyphenation JARs +if [ -n "$FOP_HYPHENATION_PATH" ] ; then + LOCALCLASSPATH=$LOCALCLASSPATH${pathSepChar}$FOP_HYPHENATION_PATH +fi + +# For Cygwin, switch paths to appropriate format before running java +# For PATHs convert to unix format first, then to windows format to ensure +# both formats are supported. Probably this will fail on directories with ; +# in the name in the path. Let's assume that paths containing ; are more +# rare than windows style paths on cygwin. +if $cygwin; then + if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then + format=mixed + else + format=windows + fi + FOP_HOME=`cygpath --$format "$FOP_HOME"` + LCP_TEMP=`cygpath --path --unix "$LOCALCLASSPATH"` + LOCALCLASSPATH=`cygpath --path --$format "$LCP_TEMP"` + if [ -n "$CLASSPATH" ] ; then + CP_TEMP=`cygpath --path --unix "$CLASSPATH"` + CLASSPATH=`cygpath --path --$format "$CP_TEMP"` + fi + CYGHOME=`cygpath --$format "$HOME"` +fi + +# Show script help if requested +if $show_help ; then + fop_exec_args="" + echo $0 '[script options] [FOP options]' + echo 'Script Options:' + echo ' --help, -h print this message and FOP help' + echo ' --noconfig suppress sourcing of /etc/fop.conf,' + echo ' $HOME/.fop/fop.conf, and $HOME/.foprc' + echo ' configuration files' + echo ' --execdebug print FOP exec line generated by this' + echo ' launch script' +fi + +# add a second backslash to variables terminated by a backslash under cygwin +if $cygwin; then + case "$FOP_HOME" in + *\\ ) + FOP_HOME="$FOP_HOME\\" + ;; + esac + case "$CYGHOME" in + *\\ ) + CYGHOME="$CYGHOME\\" + ;; + esac + case "$LOCALCLASSPATH" in + *\\ ) + LOCALCLASSPATH="$LOCALCLASSPATH\\" + ;; + esac + case "$CLASSPATH" in + *\\ ) + CLASSPATH="$CLASSPATH\\" + ;; + esac +fi + +# The default commons logger for JDK1.4 is JDK1.4Logger. +# To use a different logger, uncomment the one desired below +# LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog +# LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog +# LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger + +# Logging levels +# Below option is only if you are using SimpleLog instead of the default JDK1.4 Logger. +# To set logging levels for JDK 1.4 Logger, edit the %JAVA_HOME%/JRE/LIB/logging.properties +# file instead. +# Possible SimpleLog values: "trace", "debug", "info" (default), "warn", "error", or "fatal". +# LOGLEVEL=-Dorg.apache.commons.logging.simplelog.defaultlog=INFO + +# Execute FOP using eval/exec to preserve spaces in paths, +# java options, and FOP args +fop_exec_command="exec \"$JAVACMD\" $java_exec_args $LOGCHOICE $LOGLEVEL -classpath \"$LOCALCLASSPATH\" $FOP_OPTS org.apache.fop.cli.Main $fop_exec_args" +if $fop_exec_debug ; then + echo $fop_exec_command +fi +eval $fop_exec_command diff --git a/tools/fop/fop.bat b/tools/fop/fop.bat new file mode 100644 index 0000000..cf3eca5 --- /dev/null +++ b/tools/fop/fop.bat @@ -0,0 +1,75 @@ +@ECHO OFF +REM Licensed to the Apache Software Foundation (ASF) under one or more +REM contributor license agreements. See the NOTICE file distributed with +REM this work for additional information regarding copyright ownership. +REM The ASF licenses this file to You under the Apache License, Version 2.0 +REM (the "License"); you may not use this file except in compliance with +REM the License. You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM $Id: fop.bat 1325624 2012-04-13 06:28:25Z gadams $ + +SETLOCAL ENABLEDELAYEDEXPANSION + +rem %~dp0 is the expanded pathname of the current script under NT +set LOCAL_FOP_HOME= +if "%OS%"=="Windows_NT" set LOCAL_FOP_HOME="%~dp0" + +rem Code from Apache Ant project +rem Slurp the command line arguments. This loop allows for an unlimited number +rem of arguments (up to the command line limit, anyway). +rem Could also do a "shift" and "%*" for all params, but apparently doesn't work +rem with Win9x. +set FOP_CMD_LINE_ARGS=%1 +if ""%1""=="""" goto doneStart +shift +:setupArgs +if ""%1""=="""" goto doneStart +set FOP_CMD_LINE_ARGS=%FOP_CMD_LINE_ARGS% %1 +shift +goto setupArgs +rem This label provides a place for the argument list loop to break out +rem and for NT handling to skip to. +:doneStart + +set LOGCHOICE= +rem The default commons logger for JDK1.4 is JDK1.4Logger. +rem To use a different logger, uncomment the one desired below +rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog +rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog +rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger + +set LOGLEVEL= +rem Logging levels +rem Below option is only if you are using SimpleLog instead of the default JDK1.4 Logger. +rem To set logging levels for JDK 1.4 Logger, edit the %JAVA_HOME%\JRE\LIB\logging.properties +rem file instead. +rem Possible SimpleLog values: "trace", "debug", "info" (default), "warn", "error", or "fatal". +rem set LOGLEVEL=-Dorg.apache.commons.logging.simplelog.defaultlog=INFO + +set LIBDIR=%LOCAL_FOP_HOME%lib + +set LOCALCLASSPATH=%FOP_HYPHENATION_PATH% +for %%l in (%LOCAL_FOP_HOME%build\*.jar %LIBDIR%\*.jar) do set LOCALCLASSPATH=!LOCALCLASSPATH!;%%l + +set JAVAOPTS=-Denv.windir=%WINDIR% -Djava.awt.headless=true + +if "%JAVA_HOME%" == "" goto noJavaHome +if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome +if "%JAVACMD%" == "" set JAVACMD=%JAVA_HOME%\bin\java +goto runFop + +:noJavaHome +if "%JAVACMD%" == "" set JAVACMD=java + +:runFop +rem echo "%JAVACMD%" %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS% +"%JAVACMD%" %JAVAOPTS% %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" %FOP_OPTS% org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS% + +ENDLOCAL diff --git a/tools/fop/lib/avalon-framework-4.2.0.jar b/tools/fop/lib/avalon-framework-4.2.0.jar new file mode 100644 index 0000000..22a7ab3 Binary files /dev/null and b/tools/fop/lib/avalon-framework-4.2.0.jar differ diff --git a/tools/fop/lib/batik-all-1.7.jar b/tools/fop/lib/batik-all-1.7.jar new file mode 100644 index 0000000..5893285 Binary files /dev/null and b/tools/fop/lib/batik-all-1.7.jar differ diff --git a/tools/fop/lib/commons-io-1.3.1.jar b/tools/fop/lib/commons-io-1.3.1.jar new file mode 100644 index 0000000..7affdef Binary files /dev/null and b/tools/fop/lib/commons-io-1.3.1.jar differ diff --git a/tools/fop/lib/commons-logging-1.0.4.jar b/tools/fop/lib/commons-logging-1.0.4.jar new file mode 100644 index 0000000..b73a80f Binary files /dev/null and b/tools/fop/lib/commons-logging-1.0.4.jar differ diff --git a/tools/fop/lib/serializer-2.7.0.jar b/tools/fop/lib/serializer-2.7.0.jar new file mode 100644 index 0000000..7cd8069 Binary files /dev/null and b/tools/fop/lib/serializer-2.7.0.jar differ diff --git a/tools/fop/lib/xalan-2.7.0.jar b/tools/fop/lib/xalan-2.7.0.jar new file mode 100644 index 0000000..979ee76 Binary files /dev/null and b/tools/fop/lib/xalan-2.7.0.jar differ diff --git a/tools/fop/lib/xercesImpl-2.7.1.jar b/tools/fop/lib/xercesImpl-2.7.1.jar new file mode 100644 index 0000000..eac75ae Binary files /dev/null and b/tools/fop/lib/xercesImpl-2.7.1.jar differ diff --git a/tools/fop/lib/xml-apis-1.3.04.jar b/tools/fop/lib/xml-apis-1.3.04.jar new file mode 100644 index 0000000..d42c0ea Binary files /dev/null and b/tools/fop/lib/xml-apis-1.3.04.jar differ diff --git a/tools/fop/lib/xml-apis-ext-1.3.04.jar b/tools/fop/lib/xml-apis-ext-1.3.04.jar new file mode 100644 index 0000000..a7869d6 Binary files /dev/null and b/tools/fop/lib/xml-apis-ext-1.3.04.jar differ diff --git a/tools/fop/lib/xmlgraphics-commons-1.5.jar b/tools/fop/lib/xmlgraphics-commons-1.5.jar new file mode 100644 index 0000000..0ff3b4f Binary files /dev/null and b/tools/fop/lib/xmlgraphics-commons-1.5.jar differ