jd/asciidoc-book-toolchain

Fail to compile if DTD is unreachable

Opened this issue · 2 comments

$ cd asciidoc-book-toolchain
$ make
a2x -fpdf -dbook --dblatex-opts="-d -p style-dblatex.xsl -b xetex --texstyle=style-dblatex.sty" book.txt
a2x: ERROR: "xmllint" --nonet --noout --valid "/Users/charles/Sites/books/tools/asciidoc-book-toolchain/book.xml" returned non-zero exit status 4
make: *** [book.pdf] Error 1
$ xmllint --nonet --noout --valid "/Users/charles/Sites/books/tools/asciidoc-book-toolchain/book.xml"
I/O error : Attempt to load network entity http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd
/Users/charles/Sites/books/tools/asciidoc-book-toolchain/book.xml:2: warning: failed to load external entity "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"
D DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"
                                                                               ^
/Users/charles/Sites/books/tools/asciidoc-book-toolchain/book.xml:6: validity error : Validation failed: no DTD found !
<book lang="en">
               ^
$ xmllint --version
xmllint: using libxml version 20902
   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib
$ a2x --version
a2x 8.6.9
$ cat book.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<?asciidoc-toc?>
<?asciidoc-numbered?>

<book lang="en">
<bookinfo>
    <title>My Awesome Book</title>
    <author>
        <firstname>Dave</firstname>
        <surname>Null</surname>
        <email>email@example.com</email>
    </author>
    <authorinitials>DN</authorinitials>
</bookinfo>
<preface id="_first_chapter_of_that_awesome_book">
<title>First chapter of that awesome book</title>
<simpara>Here&#8217;s some content. Everything is in <ulink url="http://www.methods.co.nz/asciidoc/">AsciiDoc</ulink> format.</simpara>
<simpara>If you like, you can even use some <ulink url="http://graphviz.org">Graphviz</ulink> inline.</simpara>
<figure><title>Some diagram</title>
<mediaobject>
  <imageobject>
  <imagedata fileref="book__1.png"/>
  </imageobject>
  <textobject><phrase>book__1.png</phrase></textobject>
</mediaobject>
</figure>
<simpara>Obviously you can also include code with some footline:</simpara>
<example>
<title>Some Python</title>
<programlisting language="python" linenumbering="unnumbered">class A(object):
    pass <co id="CO1-1"/></programlisting>
<calloutlist>
<callout arearefs="CO1-1">
<para>
This does nothing.
</para>
</callout>
</calloutlist>
</example>
<simpara>You can also include footnote <footnote><simpara>For real</simpara></footnote> in any page.</simpara>
<tip><simpara>Writing book is awesome!</simpara></tip>
<simpara>It also work with image, it&#8217;s quite simple:</simpara>
<informalfigure>
<mediaobject>
  <imageobject>
  <imagedata fileref="img/snake.png" contentwidth="100"/>
  </imageobject>
  <textobject><phrase>img/snake.png</phrase></textobject>
</mediaobject>
</informalfigure>
<note><simpara>The entire file format is described in the AsciiDoc documentation.</simpara></note>
</preface>
</book>
jd commented

It seems that it tries to load something over the Internet and is failing:

/Users/charles/Sites/books/tools/asciidoc-book-toolchain/book.xml:2: warning: failed to load external entity "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"

I guess it should use a local copy if available. Not sure how that's configurable.

volc commented

Yes it seems that the DTD file has to be available locally because the --nonet parameter prevents the validation (xmllint) to search the internet.

But the DTD file is not missing if docbook is installed and configured properly, so it seems.
On osx I used Homebrew to install asciidoc and the info for the required docbook dependency stated:

To use the DocBook package in your XML toolchain,
you need to add the following to your ~/.bashrc:

export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"

I added the variable to my profile and I was able to generate the html file.