View Full Version : Epub works fine on Reader, fails epubcheck spectacularly


jmatthew
01-04-2011, 03:11 PM
Hi,

Complete noob here, but hoping someone can point me in the right direction, since my web searches haven't been fruitful.

My book is out in print, and I managed to create a kindle version, which has been available in the Kindle store for a good year (it's a choose-your-own-adventure, so requires page links and chapter breaks on almost every page)

I recently used Calibre to convert the kindle prc into an epub, and the result reads beautifully on my Sony Reader. However, it fails epubcheck SPECTACULARLY with 694 errors (the Nook bookstore seems to have no problem with this, but to get it in the iBook store it needs to pass).

The vast majority of the errors are:

element "a" from namespace "http://www.w3.org/1999/xhtml" not allowed in this context

(Although sometimes it's a p element or a div element). The docs read fine in a browser, so my html can't be all that messed up.

Any ideas? Thanks in advance for any advice!

Matt

KevinH
01-04-2011, 03:24 PM
Hi,

My guess (without being able to see the actual file) is that you have anchor tags < a > that exist inside the < body > tag but that are not inside any other < div > or <p > tags.

The xhtml spec basically says that inline tags can not be directly inside the body tag and should instead be inside a block tag of some sort (i.e p or div) tag.

Any easy way to fix this is to run tidy and set the command switches for strict xhtml and to have it wrap these tags with either a div or a p.

My guess for what it is worth.

Toxaris
01-05-2011, 05:42 AM
Run it through Flightcrew. That one gives more sensible error messages and is much better in the checks.
It should give better clues and help you solve the problems. Use Sigil to solve things, this will make life easier...

DMSmillie
01-05-2011, 06:03 AM
Browsers will often handle and display documents which contain HTML that doesn't comply with the HTML specifications, so not always an accurate indication of how compliant the HTML is, I'm afraid. And in order to pass epubcheck, the HTML in an EPUB file has to be spec compliant.

The nature of the book, with lots of links to the different "story choices" throughout the book, makes me suspect that a lot of the errors might relate to the use of empty A elements as bookmarks which aren't contained within a block level element (such as a heading, or paragraph, or div). For example:

<a name="section001"></a>
<p>Text here.</p>

If this is how your bookmarks are constructed, you can get rid of a lot of the errors by moving the bookmark name to the heading or paragraph immediately following the empty A element and getting rid of the A element (also, if you're currently using the "name" attribute, change that to an "id" attribute instead). For example:

<p id="section001">Text here.</p>

Existing links to that bookmark will still work fine.