DocBook and Pandoc task

Description

Pandoc - a universal document converter - is a great and multi-platform tool. It may be useful:

  • to complete the docbook xsl stylesheets.Some formats, like docx, odt, … are well supported by pandoc.
  • to reverse some format like html, docx, odt, … to docbook (and/or markdown).

You may use ant + pandoc using:

Use case

Docbook to docx

  • Use the task to xinclude and preprocess docbook.
  • Use pandoc to generate docx.

docbook file

<?xml version="1.0" encoding="utf-8"?>
<book xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude">
  <title>docbook + pandoc</title>
  <subtitle>Use case ${version}</subtitle>
  
  <xi:include href="<some-docbook.xml | some-markdown.md>" />

  <!--
  <chapter id="...">
    <title>...</title>
    <xi:include href="..." />
  </chapter>
  -->
</book>

ant file

<target name="docbook-to-docx">
  <dbk file="docbook.xml" tofile="tmp.xml" preprocessor="true" overwrite="true">
    <parameter name="version" value="1.0" />
  </dbk>
  <pandoc file="tmp.xml" tofile="out.docx" inputformat="docbook" format="docx"/>
</target>

Sources.