Adding back the NCX in EPUB 3


Why NCX again?

The use of an NCX file, most commonly toc.ncx, is not required in the EPUB 3 standard. However, preparing files for library agents I was required to include an NCX for backwards compatibility. So here are a few notes and links to example files for reference.

Things to remember

Aside from creating an NCX file, it is also necessary to add the attribute toc="ncx" to your spine element, like so,
<spine toc="ncx">
inside your OPF file and to include a link to the ncx inside the OPF's manifest tags as well, e.g.
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
Note: The actual value of the spine element's toc attribute is arbitrary, it must simply match the id of the item that is the toc.

The ncx will be ignored by EPUB 3 reading systems, which instead of relying on the spine toc attribute for navigation look for the "nav" property applied to an item inside the manifest tags of the OPF file, e.g.
<item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" properties="nav" />

Notes

1. In the NCX file, a navpoint must be unique in its number, order and content, and even nested navpoints cannot have the same content source.

2. The unique identifier used in the NCX must match the unique identifier in the OPF file. In the NCX file this appears in the head of the document like so:
<meta name="dtb:uid" content="6536f2b5-62b2-4659-bbef-27131f211d30"/>

2. The NCX file must not contain a type declaration:
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
   "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
So if the above is present in the file delete it.


Comments