Skip to content

Test the toolchain

shawngiese edited this page Jan 6, 2021 · 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 asciidoc 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. For example:

C:\asciidoc\xslttools64\xsltproc.exe docbook-xsl-1.79.1\html\DocBook.xsl book.xml > book.html

Now, you should have a new HTML file in your asciidoc 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:\asciidoc\xslttools64\xsltproc.exe docbook-xsl-1.79.1\fo\DocBook.xsl book.xml > book.fo
Making portrait pages on USletter paper (8.5inx11in)
C:\cd fop-1.0
C:\asciidoc\fop-2.5>fop \asciidoc\book.fo -pdf \asciidoc\book.pdf

Now, you should have a new PDF file in your asciidoc 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 or web browser 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 folder that you are using. The other folders in this GitHub repository add folders for each book you write, a common folder for shared content, and any customizations you have, such as for HTML or PDF output.

Other pages:

Clone this wiki locally