View Full Version : Leading digits in file names okay?


sgirsberger
09-23-2011, 09:19 PM
Embarrassing question, but I need confirmation.

I have a lovely EPUB that works great on an iPad, a NOOK Color, an iPhone, and in the Kindle Previewer.

It passes the ePubChecker preflight with no warnings or errors.

However, it yields “bad value for attribute "id"” and “bad value for attribute “idref” in 66 lines of the content.opf file.

It also yields “bad value for attribute "id"” for 33 of the book's HTML files.

These files are named sequentially, 01.html, 02.html, etc. They're the individual chapter files. The other files in the book have functional names—copyright, preface, etc.

I have a bad feeling that the digits in the file names are causing the problem—is this correct? Or would it be an intervening path?

Here are samples of the ERROR syntax (path names omitted):

ERROR: . . . /OEBPS/content.opf(56): bad value for attribute "id"
ERROR: . . . /OEBPS/content.opf(103): bad value for attribute "idref"
ERROR: . . . /OEBPS/Text/01.html(12): bad value for attribute "id"

Your advice is greatly appreciated!

Jellby
09-24-2011, 03:06 AM
Filenames starting with digits are no problem, but ids cannot start with digits. So, if you (or something else) create the id value from the filename, you have to add something else:

This is wrong:
<item id="01" href="01.html" media-type="application/xhtml+xml" />

This is right:
<item id="file_01" href="01.html" media-type="application/xhtml+xml" />

Note that the filename in href does not change.

sgirsberger
09-25-2011, 09:19 AM
Thanks, Jellby. What I did was to batch-add the prefix “ch” to the numbered file names (now ch01.html, for example) using Applescript, which is similar to your solution, albeit not as easy! Then I did a search-and-replace in Text Wrangler for the old names in the EPUB files, replaced them with the new ones, and ran the EPUB back through the ePubChecker. The EPUB passed the check and preflight with no warnings or errors.

I like your solution better, so if/when I encounter this situation again, I will definitely follow this.