Table of ContentsThis document is for the first time user of XEP 4.0. If you have only limited experience with XSL FO (XSLFO), or are unfamiliar with the process of using XSLT and a formatter such as XEP, then this document is for you. For a longer tutorial, see XSL FO Formatting Objects Tutorial. Working from a simple (pre-prepared) XML example, you will produce both PDF and PostScript output using XEP 4.0 This document shows two ways of working with XEP, one graphical and one using the command line. Later, we can introduce errors into the example, and you will see how to find and correct them. The XML document and its associated XSLT stylesheet to make a
file ready for the XEP formatter are available in the
Once you are familiar with the transformation, further options are offered to show ways in which you can control the operation of XEP to generate the output you want. After reading it you will be able to use XEP with your own documents and the other components of XEP documentation as a reference. XEP is a formatter. A tool used as part of a chain normally used to transform an XML input document into a printable document for distribution. The process consists of two steps. The first transforms the input document into a standard XML format (XSL FO), the second generates the printable format from that intermediate form. XSL FO (XSLFO) can be considered as a specification for the formatting that you want for a particular document type. Starting with the file Open the file in any text editor. You will see its structure,
having a root element named In the same directory is a file named
This is the end to end process which will be described.
The input file, marked up in XML, is fed to an XSLT
transformer. XEP comes with one provided. The job of the
transformer is to take the content in the source document, and
depending on the element name and position (e.g. a paragraph or a
list or a chapter title), to modify (transform) the markup or
content, into the form used by XSL FO (XSLFO), which specifies
how XEP 4.0 should present the file ready for viewing or
printing. If you want to see this vocabulary in use, have a look
in the The second step feeds the XSL FO (XSLFO) document to the formatter, which creates and fills pages according to the specification laid out in the XSL FO (XSLFO) document. Finally, dependant on the format specified, the formatter writes out the pages in either PDF or PostScript. Since most users simply want to produce PDF or PostScript from XML (or XSL FO) XEP 4.0 may be used to perform all these processes as a single step. I'll assume you have XEP 4.0 installed on your computer. In order to view Adobe PDF (Portable Document Format) files, you will need a viewer. Adobe provide a free one. If you don't have it on your computer, you can download and install it from the Adobe website, free for personal use. Note where you install it, since you can set this in XEP Assistant, and view the PDF output file immediately when XEP has processed it. To view PostScript files, one of the options is to use a product called GhostView. Versions are available for most operating systems. This product is also capable of viewing PDF. With XEP is distributed a tool which enables the easy transformation of files in a graphical environment, suitable for users more familiar with a graphical interface. Find the The lower part of the screen may be used to select a viewer, either Adobe Acrobat reader or Ghostview. The Assistant needs to be told where you installed the application. Use the browse button to locate the application. Tick the display with box if you want to launch the viewer once the process is complete. Either remember the value in the output file selection box, or change its value to indicate where you want the output to be located. The default output is set as PDF. Leave it as that, then select OK. The right hand tab marked event log will show the file progress through to completion. The output file may be read with the Adobe Acrobat reader. Caution. Updating PDF files whilst viewing them.The Acrobat reader will not allow a file to be overwritten whilst it is open. If you wish to modify the source XML file, and re-process it to produce PDF, you must close the file in Acrobat reader, or XEP will not be able to re-write the modified file. This applies whichever route you take to producing PDF. For those used to the flexibility of the command line interface, one is provided with XEP. If you've never used the command line on Windows, it is
available from the start menu, programs, and either directly as an
option or as a tab from the acessories tab. Normally called
Command prompt. The window that pops up is
the command line interface to Windows. If you type
help it responds by listing all the commands it
understands. You may want to create a temporary directory to work
in, perhaps Taking the same example as previously, to format
The command below is split over 3 lines for readability. It should remain on one line, so just remove the \ characters used to indicate a continuation line. >\xep\xep.bat -xml \xep\examples\hammer\hammer.xml \
-xsl \xep\examples\hammer\hammer.xsl \
-out hammer.pdf
Finally, as a command line exercise, to produce
>java -jar /xep4/lib/saxon.jar -o hammer.fo \
/xep4/examples/hammer/hammer.xml \
/xep4/examples/hammer/hammer.xsl
This uses the Saxon XSLT
engine, another java tool, to
produce >java -jar saxon.jar \
-o outputFile \
inputFile \
stylesheet
If that makes sense to you, you can now start to use your own XML files to produce output suitable for the XEP formatter. Rather fake, but in order to find and correct errors it is necessary to see how they are reported. Two potential sources of errors are possible. Firstly in the source XML document. It could be either syntax or validity. Secondly, an error in the input to XEP. Often generated by an XSLT conversion, where the properties are mis-used. XEP has a tool to validate this input and isolate the source of the error. Firstly then the source code error. Open the
<annotation>
<p>
The purpose of this document is to illustrate handling complex
layout patterns in the Extended Stylesheet Language (XSL).
To simulate a real text, I have written an operation instruction
for a hammer. The genre of operation instructions turned out
to be quite convenient for showing most standard formatting
properties. Features used in this text include:
</b>
The closing [error] javax.xml.transform.TransformerException: \ org.xml.sax.SAXParseException: \ unexpected characters in element end tag (expected "p") Again the lines are split using the \ character, where on the screen they are on a single line. The message is clear. The software expected an end tag of
If you have no other help, then use the tools provided with XEP. Open up an MSDOS window (Command prompt), or a shell, and selecting the correct paths, type in the following, repeating what the use in Using the command line section above. >java -jar \xep\lib\saxon.jar -o hammer.fo hammer.xml hammer.xsl This time the error reporting is clear and concise >java -jar \xep4\lib\saxon.jar -o hammer.fo hammer.xml hammer.xsl \
Error on line 23 column 7 of
file: .. /hammer.xml: \
Error reported by XML parser: \
unexpected characters in element end tag (expected "p")
Transformation failed: Run-time errors were reported
Your display will vary a little from this, dependant on the
location of your files, but the information is clear. Somewhere on
line 23, the end tag is suspect. Now remove
the error, by replacing the This demonstrates the increased detail available from a two step process, which is just a nuisance on a correct file. If you ran the command line transformation, using saxon,
then you will have a file named In summary. When converting from XML to PDF (or PostScript), errors may be detected in either of the two stages of the transformation. It is often easier to isolate from which stage the error is originating. Now to inject and detect an error in the second stage, the XSL FO (XSLFO) to PDF stage. Open up the <fo:block space-before.optimum="6pt" text-align='centre'>
The purpose of this document is to illustrate handling complex
layout patterns in the Extended Stylesheet Language (XSL).
To simulate a real text, I have written an operation instruction
for a hammer. The genre of operation instructions turned out
to be quite convenient for showing most standard formatting
properties. Features used in this text include:
</fo:block>
An error has been introduced, specifying that the text should be aligned centre, which is a misspelling according to the official recommendation, which uses the American spelling (center). A perfectly innocent typographical error. Now to find it. NoteIf you regenerate the pdf file, this intermediate XSL FO (XSLFO) file will be overwritten, as mentioned above. If you introduce the error as shown, then run the command shown below, the validate program should find it. >\xep\validate hammer.fo file: ... hammer.fo: line 2 Attribute 'text-align' cannot have a value of "centre". hammer.fo: 1 error The validate script, located in the distributeion directory has a single purpose, to spot these errors. The output could not be clearer, the text-align property cannot take a value of centre. To remove the error, either change the value to center, or remove the attribute and its value. Re-run the validator, and a successful validation will
result. Since the normal source of such errors is the XSLT
stylesheet, that is where you would normally locate and remove
these errors, since the purpose of the stylesheet is to convert
the source XML into the form you have just seen in
That is a view of finding errors in the two stages. Although not normally done in two separate stages like that, it is worth remembering that it can be done this way, since it is often easier to locate errors, and the objective is to produce the output efficiently. Since this document is only an introduction, no detail is given of the full suite of options. That is available in the reference. It is worth knowing of other applications of XEP 4.0 The RenderX website has a page devoted to alternative ways of configuring XEP 4.0 It is worthwhile appreciating these, they may be in use now, or in the future, in your organisation. Be aware that XEP 4.0 may be readily integrated into all these products.
|
|||||
RenderX®, © 2005-2008 • Contact Us • Privacy Policy • Terms of Service • Site design by Dmitry Kirsanov Studio |
|||||