Monday, February 20, 2012

Kindle Formatting 2: Extracting the TOC

Prepare to Generate toc.ncx

Extract the toc entries from mynovel.htm

Copy and paste this and save into a text file called “toc-input.txt”

Prepare a skeleton ncx file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
<ncx version="2005-1" xml:lang="en" xmlns="">


<!-- The following four metadata items are required for all NCX documents,
including those conforming to the relaxed constraints of OPS 2.0 --> <meta name="dtb:uid" content="123456789X"/> <!-- same as in .opf -->

<meta name="dtb:depth" content="1"/> <!-- 1 or higher -->
<meta name="dtb:totalPageCount" content="0"/> <!-- must be 0 -->
<meta name="dtb:maxPageNumber" content="0"/> <!-- must be 0 -->

<!-- your output from the Java code goes here -->



  1. Hi Vadi, thanks for visiting. The java code, of course, will need tweaking to fit your needs. Also, I'm sure people who script, Python, would do it faster. Or use XSLT.