Copy
To the docbook-xsl folder, the contents of the docbook xsl download
To the lib folder
The saxon jar files (3)
The jars from the fop/lib folder as well as the fop.jar file from the fop/build folder
The fop-hyph.jar file from the offo folder
Depending on your Eclipse installation you may have to modify the Ant runtime setup so that Ant finds a number of classes at execution time. In the 'Window' drop-down menu select 'Preferences', navigate down to the Ant runtime classpath tabbed window. Click 'Ant Home entries' and use the 'Add External Jars' to locate these jars in your fop directory:
The xercesImpl-2.7.1 jar file
The serializer-2.7.0 jar file
![]() |
In the input/epub folder create a simple text file named 'mimetype' (no extension) with this only line
application/epub+zip
Copy
To the input/epub folder the test.xml, test_epub.xml and images from the epub folder in the examples
To the input/pdf folder the test.xml, test_pdf.xml and images from the pdf folder in the examples
To the input/webhelp folder the test.xml, test_webhelp.xml and images from the epub folder in the examples
Right in the XMLpublisher folder the buildSimpleBook.xml script
To get the examples follow this link or copy the below.
<?xml version="1.0"?> <!-- - Author: Patrice Cotte <patrice_cotte@hotmail.com> --> <project name="docbook-src" default="all"> <description> This Ant build.xml file is used to transform DocBook XML 1. xml to epub epubinput -> output/epub 2. xml to fo to PDF input -> ouput/pdf 3. xml to webhelp input -> output/webhelp </description> <!-- ========================================================================== - Configure basic properties that will be used in the file. The properties - define the locations of the input, output and utilities such as libraries. Note the division.xsl xsl element in the xsl/fo subdirectory has been modified to add a (static) cover page to a PDF file. - ======================================================================= --> <!-- inputs --> <property name="webhelpbook" value="test"/> <property name="pdfbook" value="test"/> <property name="epubbook" value="test"/> <property name="epubinput.dir" value="input/epub"/> <property name="epubimg.dir" value="${epubinput.dir}/images"/> <property name="epubinput" value="${epubbook}"/> <property name="pdfinput.dir" value="input/pdf"/> <property name="pdfimg.dir" value="${pdfinput.dir}/images"/> <property name="pdfinput" value="${pdfbook}"/> <property name="webhelpinput.dir" value="input/webhelp"/> <property name="webhelpinputimg.dir" value="${webhelpinput.dir}/images"/> <property name="webhelpinput" value="${webhelpbook}"/> <!-- outputs --> <property name="fo.dir" value="output/fo"/> <property name="epub.dir" value="output/epub"/> <property name="epuboutput" value="${epubbook}"/> <property name="epubhtml.dir" value="${epubinput.dir}"/> <property name="pdf.dir" value="output/pdf"/> <property name="pdfoutput" value="${pdfbook}"/> <property name="webhelp.dir" value="output/webhelp"/> <property name="webhelpimg.dir" value="output/webhelp/docs/common/images"/> <!-- Utilities and stylesheet --> <property name="docbook.xsl.dir" value="docbook-xsl"/> <property name="extensions.dir" value="${docbook.xsl.dir}/extensions"/> <property name="fo.stylesheet" value="${docbook.xsl.dir}/fo/docbook.xsl"/> <property name="epub.stylesheet" value="${docbook.xsl.dir}/epub/docbook.xsl"/> <property name="webhelp.stylesheet" value="${docbook.xsl.dir}/webhelp/xsl/webhelp.xsl"/> <property name="xalan.lib.dir" value="lib"/> <property name="epubcheck.jar" value="lib/epubcheck-3.0.1.jar"/> <!-- - Sets up the classpath for the Xalan and Xerces implementations - that are to be used in this script, since the versions that ship - with Ant may be out of date. - Set up the class for saxon. - Set up the class for the webhelp indexer --> <path id="xalan.classpath"> <fileset dir="${xalan.lib.dir}" id="xalan.fileset"> <include name="xalan-2.7.0.jar"/> <include name="xercesImpl-2.7.1.jar"/> </fileset> </path> <path id="saxon.class.path"> <pathelement location="lib/saxon.jar"/> </path> <path id="index.classpath"> <pathelement location="${extensions.dir}/lucene-analyzers-3.0.0.jar"/> <pathelement location="${extensions.dir}/lucene-core-3.0.0.jar"/> <pathelement location="${extensions.dir}/webhelpindexer.jar"/> </path> <!-- epub check macro definition --> <macrodef name="epub.check" description="Check an epub"> <attribute name="epub" description="Name of the EPUB" /> <sequential> <java jar="${epubcheck.jar}" fork="true"> <arg value="${epub.dir}/@{epub}.epub" /> </java> </sequential> </macrodef> <!-- ================================================================== - setup is done. Prepare to execute each transformation - target: all - ================================================================== --> <target name="all" description="Execute all the targets in my ant file" depends="xml-epub,xml-fo-PDF,xml-webhelp"/> <!-- Epub production - Delete and recreate the EPUB output location - Copy the mimetype source to the tmp location - Copy the images to the tmp location - Transform XML files into epub using saxon. The transformation - is performed one xml file at a time - Delete tmp stuff - Validate the EPUB document --> <target name="xml-epub" description="Transform xml into epub"> <echo message="Generate the epub file"/> <delete dir="${epub.dir}" failonerror="false"/> <mkdir dir="${epub.dir}"/> <mkdir dir="${epub.dir}/tmp"/> <!-- note the fileset specifies to keep the folder structure while copying the images (an output images folder will be created and the images copied to it) --> <fileset id="image-files" dir="${epubinput.dir}"> <include name="**/*.png"></include> <include name="**/*.jpg"></include> </fileset> <copy todir="${epub.dir}/tmp/OEBPS"> <fileset refid="image-files"></fileset> </copy> <copy todir="${epub.dir}/tmp"> <fileset dir="${epubinput.dir}"> <include name="mimetype"/> </fileset> </copy> <!-- Transform XML into HTML using XALAN --> <xslt style="${docbook.xsl.dir}/html/docbook.xsl" extension=".html" basedir="${epubinput.dir}" destdir="${epubhtml.dir}"> <classpath refid="xalan.classpath"/> <include name="${epubinput}.xml"/> <!-- no generation of the book xml file or the images --> <exclude name="**/*.xml"/> <exclude name="**/*.png"/> <exclude name="**/*.jpg"/> <exclude name="**/*.gif"/> <!-- reference a stylesheet file; style.css only defines the font and some colors - style.css is copied prior to the transformation to the output folder --> <param name="html.stylesheet" expression="style.css"/> <!-- if any of these two parameters is indicated the TOC is not generated --> <!-- param name="generate.index" expression="1"/ --> <!-- param name="generate.toc" expression="1"/ --> </xslt> <!-- - transform XML files into EPUB using SAXON, creating transient OEBPS and META-INF - Note, epub transformation can only transform one xml file at a time --> <xslt style="${epub.stylesheet}" extension=".html" basedir="${epubinput.dir}" destdir="${epub.dir}/tmp"> <include name="${epubinput}.xml" /> <param name="epub.stylesheet" expression="style.css" /> <!-- A cover is generated as cover.html in the OEBPS output folder and declared in the contents.opf file wen the bookinfo containts a cover pararaph --> <!-- The following parameter do not work currently <param name="epub.metainf.dir" expression="${epub.dir}/META-INF/" /> <param name="epub.oebps.dir" expression="${epub.dir}/OEBPS/" /> --> <classpath refid="saxon.class.path" /> </xslt> <copy todir="${epub.dir}/tmp/OEBPS"> <fileset dir="OEBPS"> </fileset> </copy> <copy todir="${epub.dir}/tmp/META-INF"> <fileset dir="META-INF"> </fileset> </copy> <!-- - Don't know how to avoid generation of "${destfilename}.html" by Saxon - Delete it --> <delete file="${output.dir}/tmp/${epuboutput}.html" /> <echo message="Generating epub output" level="info" /> <!-- We create temporary zips so that minetype is the first one in the final zip --> <zip destfile="${epub.dir}/temp.mimetype" basedir="${epub.dir}/tmp" compress="false" includes="mimetype" /> <zip destfile="${epub.dir}/temp.zip" basedir="${epub.dir}/tmp/" level="9" compress="true" excludes="mimetype" includes="OEBPS/** META-INF/**"> </zip> <!-- create the epub document, writing the mimetype file first --> <zip destfile="${epub.dir}/${epuboutput}.epub" update="true" keepcompression="true" encoding="UTF-8" excludes="*.html"> <zipfileset src="${epub.dir}/temp.mimetype" /> <zipfileset src="${epub.dir}/temp.zip" /> </zip> <!-- Have to delete these directories would be nicer to place then in tmp output dir --> <delete dir="./OEBPS" /> <delete dir="./META-INF" /> <!-- Make sure the epubcheck lib has a subfolder lib with saxon.jar and jing.jar in it Unfortunately epubcheck fails with NofFound classes I could never resolve ... <epub.check epub="${epuboutput}.epub"/> --> </target> <!-- PDF processing - Delete and recreate the PDF output location - Transform XML files using xalan into fo files. Generic input. - Set up the "fop" task - Transform fo files into PDF using the fop utility --> <target name="xml-fo-PDF" description="Transform xml into fo then into PDF"> <echo message="Generating the PDF file."/> <delete dir="${pdf.dir}"/> <delete dir="${fo.dir}"/> <mkdir dir="${pdf.dir}"/> <mkdir dir="${fo.dir}"/> <!-- copy images for fop task: the below fileset sets up a copy - operation that includes the path and images (basically /images/*.*) - This retains the structure of the input folder in the fo folder. --> <fileset id="image-files" dir="${pdfinput.dir}"> <include name="**/*.png"></include> <include name="**/*.jpg"></include> </fileset> <copy todir="${fo.dir}"> <fileset refid="image-files"></fileset> </copy> <xslt style="${fo.stylesheet}" basedir="${pdfinput.dir}" destdir="${fo.dir}" extension=".fo"> <classpath refid="xalan.classpath"/> <include name="${pdfinput}.xml"/> <exclude name="**/*.png"/> <exclude name="**.*.gif"/> <exclude name="**/*.jpg"/> <param name="section.autolabel" expression="1" /> <param name="fo.stylesheet" expression="style.css" /> </xslt> <!-- iterates through a directory and transforms xml files into fo file and then into PDF: does not seem to work yet! In this setup fop-home is my project. I have copied all the fop jars to the lib folder of my project --> <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop"> <classpath> <fileset dir="lib"> <include name="*.jar"/> </fileset> </classpath> </taskdef> <!-- location setting: use basedir="${fo.dir}" to set for the base location for the entire run use relativebase="true" to let fop set the base location to the path of each transformed fo file. Graphic files: JPG and GIF files are OK but suprisingly PNG files make the Java IO mechanism fail and abort the PDF build --> <fop format="application/pdf" fofile="${fo.dir}/${pdfoutput}.fo" outfile="${pdf.dir}/${pdfoutput}.pdf" basedir="${fo.dir}" messagelevel="verbose"> </fop> </target> <!-- Webhelp processing - Delete and recrete the webhelp output - Transform XML files using XALAN. - Cheat sheet: - generate.toc=0 When this option is set to 1, a hyperlinked table of contents appears on the index page of your WebHelp system. I find this table of contents to be a waste of space and redundant considering that the WebHelp system contains a table of contents applet. - html.stylesheet.type=text/css This option specifies that you will be using a Cascading Style Sheet to format the HTML pages that make up the WebHelp system. - html.stylesheet=webhelp.css This option creates a pointer to the Cascading Style Sheet. In this case, I point to a CSS file that I created especially for use with WebHelp. - generate.index=1 If you have added index entries to your DocBook source file, this option generates a hyperlinked index. The output is structured as follows. docs/contents is created. common/images must bee added to store the images. docs common/images contents See the webhelp folder in the docbook-xsl folder. It contains a working example of a Webhelp (doc subfolder) that can be copied to create your own webhelp and an example of a build.properties and build.html pair that generate a webhelp using saxon. The output of the webhelp transformation must be structured as follows: docs -> common -> css -> images -> jquery main.js -> content -> search -> stemmer *.js files index.html *.html files webhelp icon index.html --> <target name="xml-webhelp" description="transform XML into a weblhelp app"> <property name="webhelp.include.search.tab" value="true"/> <property name="webhelp.indexer.language" value="en"/> <delete dir="${webhelp.dir}" failonerror="false"/> <mkdir dir="${webhelp.dir}"/> <delete dir="${webhelpimg.dir}" failonerror="false"/> <mkdir dir="${webhelpimg.dir}"/> <xslt style="${webhelp.stylesheet}" basedir="${webhelpinput.dir}" destdir="${webhelp.dir}"> <!-- classpath refid="saxon.class.path"/ --> <classpath refid="xalan.classpath"/> <include name="**/${webhelpinput}.xml"/> <!-- no generation for included xml files or images --> <exclude name="**/*.png"/> <exclude name="**/*.jpg"/> <exclude name="**/*.gif"/> <!-- reference a stylesheet file --> <param name="htmlhelp.stylesheet.type" expression="text.css"/> <param name="htmlhelp.stylesheet" expression="webhelp.css"/> <param name="generate.index" expression="1"/> <param name="generate.toc" expression="0"/> </xslt> <!-- index the content subfolder --> <taskdef name="indexertask" classname="com.nexwave.nquindexer.IndexerTask"> <classpath refid="index.classpath"/> </taskdef> <indexertask htmldir="${webhelp.dir}/docs/content" indexerLanguage="${webhelp.indexer.language}"/> <!-- copy the docbook-xsl/webhelp/template directory to our output folder less the search content --> <copy todir="${webhelp.dir}/docs"> <fileset dir="${docbook.xsl.dir}/webhelp/template"> <include name="**/*.*"></include> <exclude name="**/content/search/*.props"/> <exclude name="**/content/search/stemmers/*"/> </fileset> </copy> <copy todir="${webhelp.dir}/docs"> <fileset dir="${docbook.xsl.dir}/webhelp/template"> <include name="**/content/search/default.props"></include> <include name="**/content/search/punctuation.props"></include> <include name="**/content/search/${webhelp.indexer.language}*.props"></include> <include name="**/content/search/stemmers/${webhelp.indexer.language}_stemmer.js"></include> </fileset> </copy> <!-- copy the additional images --> <copy todir="${webhelpimg.dir}" failonerror="false"> <fileset dir="${webhelpinput.dir}/images"> <include name="**/*.png"/> <include name="**/*.jpg"/> </fileset> </copy> <!-- copy the webhelp icon --> <copy todir="${webhelp.dir}/docs" failonerror="false"> <fileset dir="${docbook.xsl.dir}/webhelp/docs"> <include name="PCB inc.favico.ico"/> </fileset> </copy> </target> </project>
Review
The buildSimpleBook script and adjust as needed by your installation.