Open a new XML document by typing C-x C-f
~/dbtest.xml. Insert the DocBook document type declaration via
the ->-> menu command. Insert some
elements into the document, e.g. starting with the chapter and sect1 tags.
Enter some para elements to hold some
text. Validate your document with the menu
command. Make sure you use the SGML declaration for XML documents
(xml.dcl).
Creating printable output from an XML document is a two-step
procedure in most cases: First we have to create an intermediate
XML file containing formatting objects (the FO file). This is done
with an XSLT processor and a suitable stylesheet. The second step
needs some sort of formatting objects processor to actually create
the printable output from the intermediate FO file. Let's first see
how we can create this FO file with our XSLT engines (you should of
course only run those engines that you actually installed). In case
you want to try all of them it is prudent to use different names
for the output files each time, as shown here (the backslashes at
the end of the lines denote continuation of the line - don't type
them in):
C:\user\myself>xsltproc C:\user\default\xml\stylesheets\docbook-xsl\fo\docbook.xsl \
dbtest.xml > dbtestxp.fo
|
C:\user\myself>java -cp "C:\Programs\java\xt.jar;C:\Programs\java\xp.jar"\
com.jclark.xsl.sax.Driver dbtest.xml \
C:\user\default\xml\stylesheets\docbook-xsl\fo\docbook.xsl > dbtestxt.fo
|
C:\user\myself>java -cp "C:\Programs\java\xalan.jar;C:\Programs\java\xerces.jar" \
org.apache.xalan.xslt.Process \
-in test.xml -xsl C:\user\default\xml\stylesheets\docbook-xsl\fo\docbook.xsl \
-out dbtestxc.fo
|
C:\user\myself>java -cp "C:\Programs\java\saxon.jar" \
com.icl.saxon.StyleSheet -o dbtestsx.fo dbtest.xml \
C:\user\default\xml\stylesheets\docbook-xsl\fo\docbook.xsl
|
Now we try to turn our FO file into a PDF file using the
PassiveTeX macros. Run the following command, substituting the FO
filename as appropriate:
C:\user\myself>pdfxmltex dbtest.fo
|
Alternatively we can use FOP to transform the XML document to
PDF with a single command (this is the exception to the two-step
rule, but you can guess from the classpath that FOP uses Xalan
internally):
C:\user\myself>java -cp "C:\Programs\java\fop.jar; \
C:\Programs\java\batik.jar;C:\Programs\java\jimi-1.0.jar; \
C:\Programs\java\xalan.jar; C:\Programs\java\xerces.jar; \
C:\Programs\java\logkit-1.0b4.jar;C:\Programs\java\avalon-framework-4.0.jar" \
org.apache.fop.apps.Fop -xsl \
"C:\user\default\xml\stylesheets\docbook-xsl-1.45\fo\docbook.xsl" \
-xml test.xml -pdf test.pdf
|
Finally we can try and see what the RTF output from the FO file
looks like (substitute the FO filename as appropriate):
C:\user\myself>java -cp "C:\Programs\java\jfor-0.5.1.jar; \
C:\Programs\java\xerces.jar" ch.codeconsult.jfor.main.CmdLineConverter \
dbtest.fo dbtest.rtf
|