DocBook to ePub

Thibaut Cuvelier tcuvelier at lyx.org
Thu Feb 4 22:21:30 UTC 2021


On Sun, 31 Jan 2021 at 10:24, Stephan Witt <st.witt at gmx.net> wrote:

> Am 30.01.2021 um 04:56 schrieb Thibaut Cuvelier <tcuvelier at lyx.org>:
> >
> > On Sat, 30 Jan 2021 at 01:30, Stephan Witt <st.witt at gmx.net> wrote:
> > Am 29.01.2021 um 18:38 schrieb Thibaut Cuvelier <tcuvelier at lyx.org>:
> > >
> > > Dear list,
> > >
> > > As promised, I started working on ePub output, building upon the new
> DocBook output.
> > >
> > > Here is a script that performs the complete process of taking a
> DocBook file and generating the ePub. It has several dependencies:
> > >
> > > - an XSLT processor:
> > >       • not xsltproc (http://xmlsoft.org/xslt/xsltproc2.html):
> available for most Linux distributions, I guess it is available by default
> on macOS, must be bundled for Windows. I tried several versions for
> Windows, but an old bug that should have been fixed in 1.1.24 (roughly
> 2010) is still there:
> > >               • I/O error : No such file or directory
> > >               • xsltDocumentElem: unable to save to
> C:/Users/Thibaut/AppData/Local/Temp/tmp6c2i6a7h/OEBPS/package.opf
> > >       • Saxon 6 (available for most Linux distributions, must be
> bundled for Windows and macOS, requires Java). It's outdated software
> (circa 2005), but newer versions are not 100% backward compatible, so it is
> still very widely used. Other DocBook stylesheets would work on newer
> Saxon, but they are not as reliable as the old ones (like
> https://github.com/docbook/xslTNG).
> > >       • not MSXML6 (Windows-only, mostly built-it, but not compatible
> with the DocBook stylesheets — it wrongly errors with chunking) or .Net
> XSLT engine (nxslt/nxslt2).
> > > - the official DocBook XSLT stylesheets. Three parts are required:
> XHTML, XHTML5, and ePub. For now, I copied the needed parts in a patch. On
> some Linux distributions, this could be replaced by a version installed by
> the package manager (Ubuntu 20.04 has a near-up-to-date version, although
> the latest one has been released in 2016:
> https://github.com/docbook/xslt10-stylesheets/releases/tag/release%2F1.79.2;
> Fedora is up-to-date).
> > >
> > > The integration into LyX should be complete, minus testing on Linux
> and others and packaging issues: the dependencies must be included for
> Windows and macOS, not for all Linux distros.
> >
> > On macOS 10.14 (Mojave) I have:
> >
> > $ xsltproc -V
> > Using libxml 20904, libxslt 10129 and libexslt 817
> > xsltproc was compiled against libxml 20904, libxslt 10129 and libexslt
> 817
> > libxslt 10129 was compiled against libxml 20904
> > libexslt 817 was compiled against libxml 20904
> >
> > Why not?
> >
> > I was not able to make xsltproc work on Windows with these stylesheets,
> it gave many errors when creating new files. What if you try with the
> following docbook2epub.py script (it goes in lib/scripts)?
>
> I’ve applied all (?) your patches and used the LyX made of it to export to
> ePub:
>
> support/Systemcall.cpp (291): Systemcall: 'python scripts/docbook2epub.py
> "java" "Intro.xml" "Intro.epub"' finished with exit code 2
> Error: Die Datei kann nicht konvertiert werden
> ----------------------------------------
> Bei der Ausführung von
> python $$s/scripts/docbook2epub.py "java" "Intro.xml" "Intro.epub"
> ist ein Fehler aufgetreten
>
> Can you please be more precise what to try? Ideally I can run some
> commands in terminal to diagnose the ePub export tool chain.
> I don’t like to run them from LyX at first.
>

If you want to try it outside LyX, first export the document as DocBook 5
(say, doc.xml); if Java is available in the PATH, run (with either Python 2
or 3, although it's only really tested with 3.8):

python scripts/docbook2epub.py "java" "doc.xml" "doc.epub"

Otherwise, you should have many more details by having a look at the
console, if one is attached to the LyX process.

Mostly, there are two sources of error: either the transformation into HTML
or the ZIP-archive creation. Basically, the script is just running the
following three commands:

mkdir …/tmpfolder
java -jar …/saxon6.5.5.jar …/doc.xml …/docbook/epub3/chunk.xsl
base.dir=…/tmpfolder
zip …/doc.epub …/tmpfolder/*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20210204/697af6f8/attachment.html>


More information about the lyx-devel mailing list