Validating ePub file

17 posts / 0 new
Last post

Hi All,

Does ePubcheck validates any ePub file with invalid folder Structure? I have a file where all files/folder listed below comes under the root folder of ePub package.

images, META-INF, chapter1.html, content.opf, mimetype, toc.ncx

And I dont see a OPS or OEBPS folder in this which supposed to be there as per the idpf specifications. When I try to validate this file via online epub checker, it throws me an exception saying like below :-

Oops, an error occured

This exception has been logged with id 6cm5hcdob

Please let me know your thoughts.

Thanks and Regards,
Ravi Kumar

The required structure inside the container is that the mimetype file must be first file in the zip container and that there must be a META-INF directory containing the container.xml file (which, in your case, must point to the content.opf file in the root).

There's no requirement that files be in any subfolder, but as containers may include multiple renditions it is a good practice to put each instance in its own folder (plus it just unclutters the root and makes it easier to inspect for issues). That's why you'll typically find the contents of an EPUB 2 book in an /OPS or /OEBPS subfolder and EPUB 3s in /EPUB.

So long as the location of the opf file is correctly identified, and all the resources listed in the manifest are correctly referenced relative to the position of that file in the container, the structure should not be an issue.

It's impossible to know what error you're encountering, except that it's caused some exception the web service doesn't appear able to handle. In a case like this, the best thing to do is download epubcheck and run it locally to see what it has to say. It could be anything from a corrupt zip file to ...

Hi matt.garrish,

Thanks for your reply. I had done the same thing which you had suggested at the end (validating from epubcheck locally). And it showed me some errors rather than any exception like in the online validator. Here is that error which I had got by uploading that ePub book.

Length of the first filename in archive must be 8
, but was 11 !

/META-INF/container.xml: entry OPS/content.opf not
found in zip file

Check finished with warnings or errors!

Please let me know if you would like to add something to this again

Ravi Kumar

Please see my previous comment about the correct structure for the container. The mimetype file has to be the first in the container. By the error message, you have an 11 character file name first in your zip container, so it can't be the mimetype, which is only 8 characters. Verify that you have correctly zipped your contents in the correct order (and with no compression on the mimetype file).

You can run epubcheck on your unpacked content and have it validate and zip for you (on successful validation) by running as follows:

java -jar epubcheck.jar book.epub -mode exp -save

Also, it appears that the rootfile element in your container.xml file is referencing the content.opf file in an /OPS subdirectory off the root. You will have to change that if you intend to keep all your content in the container root. (It would be better to move the content files to a matching subdirectory, but as noted above is not required.)

Length of the first filename in archive must be 8, but was 9
Hello all.Can i help me please?but with table.Because i little speak and read english :/ or i want to messenger adress to you .after that we will speak on MSN.Thank you for all.

When you zip your EPUB, the mimetype file must be the first one you add (mimetype == 8 characters).

This message appears to be more confusing than helpful, since it doesn't explain itself very well. That it's followed by a second test that checks the file name and reports that the mimetype file must be the first (if it's not), would seem to make it redunant on top of being confusing.

Yes. But, We cannot create the zip package in such a way that "mimetype" file will come first. Because, its the WinRAR which always places folders in the beginning when we archive set of files and folders (It's OEBPS,mimetype and META-INF here). So, how can we solve this?

Ravi Kumar

Sure you can, but you have to do it manually. Create an empty zip archive file, open it in WinRAR, add the mimetype (setting the compression to store), and then add the other folders and files.

But this is why it's typically faster and easier to use a tool like epubcheck to do the archiving for you.

Thanks Garrish. It worked fine now after created the zip in the way you had suggested.

I am working in ePub 3 and used the epub:type attribute per client instruction. But, when validate the ePub file some of the attribute as validated the epubchecker validation tool. For e.g., when use the <span epub:type="pagebreak">, we do not see any error in the epubchecker. But, if we use <span epub:type="glossaryterm">, we shown the error message in epubchecker 3.0. Please see error message below.

ERROR: Grade06_Build1.epub/OPS/page0007.xhtml(24,75): Undefined property: glossaryterm

Could you please help on this matter anyone...

Right, because unprefixed terms have to be defined in the EPUB 3 Structural Semantics Vocabulary.

You're using "glossaryterm", but the vocabulary defines it as "glossterm". That's why epubcheck is throwing the error. You either need to use the term as defined in the vocabulary or create a custom prefix.

Thank you so much. Its worked fine. I will communicate this information to my client.

I found one more issue for validation, since I used the "section" as below code per client requirement:
<section epub:type="chapter" xml:id="c01">

Listed error message below:

ERROR: mimetype.epub/OPS/page0001.xhtml(12,40): attribute "xml:id" not allowed here; expected attribute...........

Thanks your help in advance,

The xml:id attribute is not supported in HTML5. It only includes support for xml:lang, xml:base and xml:space.

You have to use the HTML5 id attribute even in the XML serialization, as having two ID attributes would inevitably cause conflicts and incompatibilities.

This one always trips me up, and I probably have to go back and verify I haven't done this in the accessibility guidelines...

Thanks Garrish!

Sure you can, but you have to do it manually. Create an empty zip archive file, open it in WinRAR, add the mimetype (setting the compression to store), and then add the other folders and files.

But this is why it's typically faster and easier to use a tool like epubcheck to do the archiving for you

Secondary menu