epub

epub from http://idpf.org/about-us is the recommended open format for eBook readers. The specifications are freely available however not in epub format. So I ended up reading the epub spec not on my ebook reader but on my desktop PC. Maybe the epub authors were not able to write epub? Epub is a container format that can hold different items. You can unzip a epub file (maybe you need to rename it first to *.zip) then you get a directory with:

Epub is specified using 3 specifications: the Open Publication Structure (OPS), Open Packaging Format (OPF) and Open Container Format (OCF)

To get free eBooks see: http://www.gutenberg.org/wiki/Main_Page

Open Container Format

This specification http://www.idpf.org/epub/20/spec/OCF_2.0.1_draft.docdescribes how the document is prepared as directory (File System Container or Abstract Container) that will be compressed to a single file (ZIP Container or Physical Container) using zip.

The file system container (or in simple words the directory where the epub is created) contains a file mimetype with a single text line identifying epub as epub:

application/epub+zip

There is also the mandatory META-INF subdirectory where just the only mandatory file is container.xml. It has a content as:

<?xml version="1.0" encoding='utf-8'?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
    <rootfiles>
        <rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
   </rootfiles>
</container>

Important is the rootfiles element with its attribute full-path. This describes the subdirectory and file containing the epub table of contents that serves as entry point of the epub document.

Open Packaging Format

The open packaging format is used to define the contents of a epub file. This file resides in the directory defined in the OPC data. A good name for such an XML file is therefore contents.opf. For details see: http://www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm

<?xml version='1.0' encoding='UTF-8'?>
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
  <metadata>
     <title/>
     <language/>
     <identifier/> 
  </metadata>  
  <manifest/>
  <spine toc="ncx"/>
  <guide/>
</package>

Metadata follows https://en.wikipedia.org/wiki/Dublin_Core to describe stuff about the document that are used to find classify and do all other things than what will be seen when reading the book. The mandatory meta data are title, language and an unique identifier that can be of different kind as ISBN number or an uuid (see: https://en.wikipedia.org/wiki/UUID. Using python an uuid can easily be created using time and computer info.

Manifest lists all files (html,css, jpeg, ncx, ... ) and their location, that make part of the epub. One of the files inside the manifest is

 <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>

This refers to the spine element and a file toc.ncx. The spine element contains the list of file id defined in the manifest element to defines the sequence of how the individual files form the document. The toc.ncx file is an other xml file that defines the global navigation structure used for navigation.

The guide element is optional and allows to set a cover, table of contents and other features.

Open Publication Structure

The Open Publication Structure http://www.idpf.org/epub/20/spec/OPS_2.0.1_draft.htm has the most pages of all the ebup specification, however it seems that it is not necessary to be bothered with it. Make sure the file inside the epub are clean xhtml data. If you want to know what this means red the mentioned spec.


Linurs startpage