Skip to content

Test the toolchain

shawngiese edited this page Oct 31, 2012 · 4 revisions

Testing the toolchain

Now that you have prepared your toolchain, it is time to test creating documents. Create a simple DocBook file in XML. For example:

<?xml version="1.0" encoding="utf-8"?>
<book>
<info>
  <title>My First Book</title>
  <author>
    <personname><firstname>Jane</firstname><surname>Doe</surname></personname>
  </author>
  <copyright><year>2010</year><holder>Jane Doe</holder></copyright>
</info>
<preface>
	<title>Foreword</title>
</preface>
<chapter>
	<title>My Chapter</title>
	<section><title>First Section</title>
	<para>Important book content</para>
	<indexterm><primary>books</primary></indexterm>
</section>
</chapter>
<glossary>
<glossentry>
	<glossterm>Extensible Markup Language</glossterm>
      <acronym>XML</acronym>
      <glossdef>
       <para>Some reasonable definition here.</para>
      </glossdef>
    </glossentry>
</glossary>
<index></index>
</book>

Save this file to the DocBook directory that you created earlier. Give this file the name book.xml.

Now run xsltproc and tell it which stylesheet to use, which XML file that contains your book, and where to save the finished document. You must run xsltproc from the directory where it is located. For example:

C:\DocBook>xsltproc.exe DocBook-xsl-1.77.0\html\DocBook.xsl book.xml > book.html

Now, you should have a new HTML file in your DocBook directory called book.html. Open it up in your preferred web browser and you should see all of your content. Change some of the content in book.xml and try it again, for example, change the book title. See if you can generate other types of documents from your book.xml file, for example epub.

If you have installed and tested FOP, you can also create a PDF.

C:\DocBook>xsltproc.exe DocBook-xsl-1.77.1\fo\DocBook.xsl book.xml > book.fo
Making portrait pages on USletter paper (8.5inx11in)
C:\cd fop-1.0
C:\DocBook\fop-1.0>fop \DocBook\book.fo -pdf \DocBook\book.pdf

Now, you should have a new PDF file in your DocBook directory called book.pdf. The command for running FOP looks a little different since you run FOP inside its own directory are using ".\" to tell the software to go up one directory to where the XML file is located. There may be some warning messages generated by FOP but none of them should stop the creation of a nice, new PDF file.

Open the book.pdf in your Acrobat Reader and you should see all of your content. See if you can generate other types of documents from your book.fo file, for example rtf.

Congratulations, you now have a new DocBook toolchain. This is a good time to archive the DocBook folder that you are using.

Other pages:

Clone this wiki locally