Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 07-10-2018, 11:48 PM   #1
Albright
Member
Albright began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Oct 2010
Device: Kindle 3
"Exactly one 'toc' nav element must be present"

Hi, folks. I'm working on some code for a client which crates EPUB 3 files. The books are working fine in iBooks and Calibre, but now we're trying to upload the file to Google's book store and getting stuck with the lingering error:

"EPUB/toc.xhtml:2, 203: Error while parsing file 'Exactly one 'toc' nav element must be present'."

But there is most definitely exactly one 'toc' nav element in the TOC file, and it matches the spec in other ways as well, as far as I can tell. I presume there's something different that I'm just not seeing, even after comparing this TOC file with a few others from other EPUB files, but I still can't see it and I'm about to start flipping tables.

Maybe it just needs to be seen with a fresh pair of eyes, so if someone could have a quick look at this and see if they can spot something wrong, I'd greatly appreciate it. It's quite long, but I presume the error lies somewhere near the beginning.

(The code below has been run through "xmllint --format" to make it more readable; the "real" file is a bit messier. But that shouldn't make a difference, right?)

Code:
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
  <head>
    <link type="text/css" rel="stylesheet" href="assets/css/epub.css"/>
  </head>
  <body>
    <nav xmlns:epub="epub" epub:type="toc" id="toc">
      <h1>Table of Contents</h1>
      <ol>
        <li id="cover">
          <a href="cover.xhtml">Cover Page</a>
        </li>
        <li id="toc-page">
          <a href="toc.xhtml">Table of Contents</a>
        </li>
        <li id="toc-1">
          <a href="1-version-history.xhtml">1.0 The Basics</a>
          <ol>
            <li id="toc-1-1">
              <a href="1-version-history.xhtml">1.1 Introduction</a>
              <ol>
                <li id="toc-1-1-1">
                  <a href="1-version-history.xhtml" id="toc-1-link">1.1.1 Version History</a>
                </li>
              </ol>
            </li>
          </ol>
        </li>
        <li id="toc-2">
          <a href="2-prologue.xhtml">2.0 Walkthrough</a>
          <ol>
            <li id="toc-2-1">
              <a href="2-prologue.xhtml">2.1 Story Walkthrough</a>
              <ol>
                <li id="toc-2-1-1">
                  <a href="2-prologue.xhtml" id="toc-2-link">2.1.1 Prologue</a>
                </li>
                <li id="toc-2-1-2">
                  <a href="3-elgarthe-village.xhtml" id="toc-3-link">2.1.2 Elgarthe Village</a>
                </li>
                <li id="toc-2-1-3">
                  <a href="4-hush-grove.xhtml" id="toc-4-link">2.1.3 Hush Grove</a>
                </li>
                <li id="toc-2-1-4">
                  <a href="5-moon-ridge.xhtml" id="toc-5-link">2.1.4 Moon Ridge</a>
                </li>
                <li id="toc-2-1-5">
                  <a href="6-ancient-ruins-merhl.xhtml" id="toc-6-link">2.1.5 Ancient Ruins Merhl</a>
                </li>
                <li id="toc-2-1-6">
                  <a href="7-mistral-gorge.xhtml" id="toc-7-link">2.1.6 Mistral Gorge</a>
                </li>
                <li id="toc-2-1-7">
                  <a href="8-imperial-capital-watt.xhtml" id="toc-8-link">2.1.7 Imperial Capital Watt</a>
                </li>
                <li id="toc-2-1-8">
                  <a href="9-maarport.xhtml" id="toc-9-link">2.1.8 Maarport</a>
                </li>
                <li id="toc-2-1-9">
                  <a href="10-ragness-ruins.xhtml" id="toc-10-link">2.1.9 Ragness Ruins</a>
                </li>
                <li id="toc-2-1-10">
                  <a href="11-los-labyrinth.xhtml" id="toc-11-link">2.1.10 Los Labyrinth</a>
                </li>
                <li id="toc-2-1-11">
                  <a href="12-sacred-rahet.xhtml" id="toc-12-link">2.1.11 Sacred Rahet</a>
                </li>
                <li id="toc-2-1-12">
                  <a href="13-imperial-command-base.xhtml" id="toc-13-link">2.1.12 Imperial Command Base</a>
                </li>
                <li id="toc-2-1-13">
                  <a href="14-shipsink.xhtml" id="toc-14-link">2.1.13 Shipsink</a>
                </li>
                <li id="toc-2-1-14">
                  <a href="15-salny-village.xhtml" id="toc-15-link">2.1.14 Salny Village</a>
                </li>
                <li id="toc-2-1-15">
                  <a href="16-sal-garthr.xhtml" id="toc-16-link">2.1.15 Sal Garthr</a>
                </li>
                <li id="toc-2-1-16">
                  <a href="17-scar-top.xhtml" id="toc-17-link">2.1.16 Scar Top</a>
                </li>
                <li id="toc-2-1-17">
                  <a href="18-yugebury.xhtml" id="toc-18-link">2.1.17 Yugebury</a>
                </li>
                <li id="toc-2-1-18">
                  <a href="19-holy-cave.xhtml" id="toc-19-link">2.1.18 Holy Cave</a>
                </li>
                <li id="toc-2-1-19">
                  <a href="20-wyllia.xhtml" id="toc-20-link">2.1.19 Wyllia</a>
                </li>
                <li id="toc-2-1-20">
                  <a href="21-marsh-end.xhtml" id="toc-21-link">2.1.20 Marsh End</a>
                </li>
                <li id="toc-2-1-21">
                  <a href="22-mirror-lake.xhtml" id="toc-22-link">2.1.21 Mirror Lake</a>
                </li>
                <li id="toc-2-1-22">
                  <a href="23-infiltrating-the-palace.xhtml" id="toc-23-link">2.1.22 Infiltrating the Palace</a>
                </li>
                <li id="toc-2-1-23">
                  <a href="24-mind-s-end.xhtml" id="toc-24-link">2.1.23 Mind's End</a>
                </li>
                <li id="toc-2-1-24">
                  <a href="25-escaping-the-capital.xhtml" id="toc-25-link">2.1.24 Escaping the Capital</a>
                </li>
                <li id="toc-2-1-25">
                  <a href="26-dhaka-venu.xhtml" id="toc-26-link">2.1.25 Dhaka Venu</a>
                </li>
                <li id="toc-2-1-26">
                  <a href="27-restoring-the-moon-s-power.xhtml" id="toc-27-link">2.1.26 Restoring the Moon's Power</a>
                </li>
                <li id="toc-2-1-27">
                  <a href="28-royal-capital-marche.xhtml" id="toc-28-link">2.1.27 Royal Capital Marche</a>
                </li>
                <li id="toc-2-1-28">
                  <a href="29-lunar-kiln.xhtml" id="toc-29-link">2.1.28 Lunar Kiln</a>
                </li>
                <li id="toc-2-1-29">
                  <a href="30-dhaka-venu-2.xhtml" id="toc-30-link">2.1.29 Dhaka Venu (2)</a>
                </li>
                <li id="toc-2-1-30">
                  <a href="31-fade-valley.xhtml" id="toc-31-link">2.1.30 Fade Valley</a>
                </li>
                <li id="toc-2-1-31">
                  <a href="32-fade-gorge.xhtml" id="toc-32-link">2.1.31 Fade Gorge</a>
                </li>
                <li id="toc-2-1-32">
                  <a href="33-pale-tower.xhtml" id="toc-33-link">2.1.32 Pale Tower</a>
                </li>
                <li id="toc-2-1-33">
                  <a href="34-fade-ridge.xhtml" id="toc-34-link">2.1.33 Fade Ridge</a>
                </li>
                <li id="toc-2-1-34">
                  <a href="35-return-to-the-real-world.xhtml" id="toc-35-link">2.1.34 Return to the Real World</a>
                </li>
                <li id="toc-2-1-35">
                  <a href="36-sacred-rahet-2.xhtml" id="toc-36-link">2.1.35 Sacred Rahet (2)</a>
                </li>
                <li id="toc-2-1-36">
                  <a href="37-lunar-kiln-2.xhtml" id="toc-37-link">2.1.36 Lunar Kiln (2)</a>
                </li>
                <li id="toc-2-1-37">
                  <a href="38-the-moon.xhtml" id="toc-38-link">2.1.37 The Moon</a>
                </li>
                <li id="toc-2-1-38">
                  <a href="39-post-game-content.xhtml" id="toc-39-link">2.1.38 Post Game Content</a>
                </li>
              </ol>
            </li>
            <li id="toc-2-2">
              <a href="40-kanata-s-sidequest.xhtml">2.2 Character Sidequests</a>
              <ol>
                <li id="toc-2-2-1">
                  <a href="40-kanata-s-sidequest.xhtml" id="toc-40-link">2.2.1 Kanata's Sidequest</a>
                </li>
                <li id="toc-2-2-2">
                  <a href="41-lumina-s-sidequest.xhtml" id="toc-41-link">2.2.2 Lumina's Sidequest</a>
                </li>
                <li id="toc-2-2-3">
                  <a href="42-locke-s-sidequest.xhtml" id="toc-42-link">2.2.3 Locke's Sidequest</a>
                </li>
                <li id="toc-2-2-4">
                  <a href="43-van-s-sidequest.xhtml" id="toc-43-link">2.2.4 Van's Sidequest</a>
                </li>
                <li id="toc-2-2-5">
                  <a href="44-obaro-s-sidequest.xhtml" id="toc-44-link">2.2.5 Obaro's Sidequest</a>
                </li>
                <li id="toc-2-2-6">
                  <a href="45-sherra-s-sidequest.xhtml" id="toc-45-link">2.2.6 Sherra's Sidequest</a>
                </li>
              </ol>
            </li>
            <li id="toc-2-3">
              <a href="46-kanata.xhtml">2.3 Characters</a>
              <ol>
                <li id="toc-2-3-1">
                  <a href="46-kanata.xhtml" id="toc-46-link">2.3.1 Kanata</a>
                </li>
                <li id="toc-2-3-2">
                  <a href="47-lumina.xhtml" id="toc-47-link">2.3.2 Lumina</a>
                </li>
                <li id="toc-2-3-3">
                  <a href="48-locke.xhtml" id="toc-48-link">2.3.3 Locke</a>
                </li>
                <li id="toc-2-3-4">
                  <a href="49-van.xhtml" id="toc-49-link">2.3.4 Van</a>
                </li>
                <li id="toc-2-3-5">
                  <a href="50-obaro.xhtml" id="toc-50-link">2.3.5 Obaro</a>
                </li>
                <li id="toc-2-3-6">
                  <a href="51-sherra.xhtml" id="toc-51-link">2.3.6 Sherra</a>
                </li>
                <li id="toc-2-3-7">
                  <a href="52-dianto.xhtml" id="toc-52-link">2.3.7 Dianto</a>
                </li>
                <li id="toc-2-3-8">
                  <a href="53-galdra.xhtml" id="toc-53-link">2.3.8 Galdra</a>
                </li>
              </ol>
            </li>
          </ol>
        </li>
        <li id="toc-3">
          <a href="54-roadmap.xhtml">3.0 Extras</a>
          <ol>
            <li id="toc-3-1">
              <a href="54-roadmap.xhtml">3.1 Trophy Guide</a>
              <ol>
                <li id="toc-3-1-1">
                  <a href="54-roadmap.xhtml" id="toc-54-link">3.1.1 Roadmap</a>
                </li>
                <li id="toc-3-1-2">
                  <a href="55-trophy-guide-1.xhtml" id="toc-55-link">3.1.2 Trophy Guide (1)</a>
                </li>
                <li id="toc-3-1-3">
                  <a href="56-trophy-guide-2.xhtml" id="toc-56-link">3.1.3 Trophy Guide (2)</a>
                </li>
              </ol>
            </li>
          </ol>
        </li>
      </ol>
    </nav>
  </body>
</html>
Albright is offline   Reply With Quote
Old 07-11-2018, 02:38 AM   #2
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Most likely the properties="nav" attribute is missing in the <manifest> section of the .opf file.
Double-check the entry for toc.xhtml and add it if it's missing.
Doitsu is offline   Reply With Quote
Advert
Old 07-11-2018, 11:31 AM   #3
Albright
Member
Albright began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Oct 2010
Device: Kindle 3
Quote:
Originally Posted by Doitsu View Post
Most likely the properties="nav" attribute is missing in the <manifest> section of the .opf file.
Double-check the entry for toc.xhtml and add it if it's missing.
Doitsu;

Thanks for the suggestion. Unfortunately, that doesn't seem to be the problem here. Here's the line for the TOC file in the manifest.

Code:
    <item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" properties="nav"/>
Also, both iBooks and Calibre have no problems finding the TOC file and using it to build their respective index menus.
Albright is offline   Reply With Quote
Old 07-11-2018, 12:00 PM   #4
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by Albright View Post
Unfortunately, that doesn't seem to be the problem here.
You might want to check your book with the IDPF validator, which might give you a more precise error message than the Google validator:

For example:

Quote:
ERROR (RSC-005) at "book.epub/OEBPS/content.opf" (line XX, col YY): Error while parsing file 'Exactly one manifest item must declare the 'nav' property (number of 'nav' items: 0)'.
No manifest item has a properties="nav" attribute.

Quote:
ERROR (RSC-005) at "book.epub/OEBPS/content.opf" (line XX, col YY): Error while parsing file 'Exactly one manifest item must declare the 'nav' property (number of 'nav' items: 2)'.
Two manifest items have a properties="nav" attribute.

If you don't get any error messages, there might be a problem with the Google validator.
Doitsu is offline   Reply With Quote
Old 07-11-2018, 02:58 PM   #5
Albright
Member
Albright began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Oct 2010
Device: Kindle 3
Doitsu:

Thanks again for your reply, but again, this is not an issue with the manifest. (Though, as far as I can tell, it's not an issue with the actual TOC, either…)

That IDPF validator is also complaining about "Exactly one 'toc' nav element must be present." It provides the line and character position of… the start of the nav element. Argh.

Starting to wonder if it's parsing the TOC file twice for some reason…
Albright is offline   Reply With Quote
Advert
Old 07-11-2018, 04:02 PM   #6
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by Albright View Post
That IDPF validator is also complaining about "Exactly one 'toc' nav element must be present."
If you remove the xmlns:epub="epub" attribute the error should go away.

Code:
<nav xmlns:epub="epub" epub:type="toc" id="toc">
Doitsu is offline   Reply With Quote
Old 07-11-2018, 04:57 PM   #7
Albright
Member
Albright began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Oct 2010
Device: Kindle 3
Holy crap. I didn't think that could possibly be the problem, and that bit was being added by my XML library anyway so I assumed it was correct…*but I tried it anyway using some simple string replacement on the serialized XML, and… it works. That's insane, but it works.

Thank you!
Albright is offline   Reply With Quote
Old 07-13-2018, 07:03 PM   #8
Sarmat89
Evangelist
Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.
 
Posts: 482
Karma: 2267928
Join Date: Nov 2015
Device: none
Quote:
Originally Posted by Albright View Post
I didn't think that could possibly be the problem, and that bit was being added by my XML library anyway
The correct namespace for "xmlns:epub" is "http://www.idpf.org/2007/ops". Your value "epub" is bogus, and you should fix it.

Technically, the validator looks for "{http://www.idpf.org/2007/ops}type" attribute, but your XML has "{epub}type" instead.

Last edited by Sarmat89; 07-13-2018 at 07:05 PM.
Sarmat89 is offline   Reply With Quote
Old 09-09-2021, 07:57 AM   #9
AlanHK
Guru
AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.
 
AlanHK's Avatar
 
Posts: 667
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
I know this thread is 3 years old. But it's one of the very few hits anywhere for this epubcheck error "Exactly one 'toc' nav element must be present"
So I thought I'd add this anecdote.

The error was indicated at the end of the "<body>" line of the nav file.

Eventually I worked out the problem was the epub namespace, but in the html line at the top, which was:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2011/epub" lang="en" xml:lang="en">


Changing this to
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="en" xml:lang="en">

and all was good.


I previously tried rebuilding the nav file, by using Sigil's "Edit TOC" and "Generate TOC" functions.

While these made new file, they preserved the original headers. That's usually a good thing, if like me you paste in CSS styles to make the nav look nice and use it as the visible Contents page. But doesn't fix any errors in the header.

Sigil won't let you delete the nav and make a completely new one. But if you open the epub as a zip and delete the nav file Sigil will create a new clean one from scratch on opening (interestingly, without any message that it is doing so). So that might be easier than trying to work out exactly where the syntax is wrong in the old one and quicker than extracting all the HTML, etc and importing all to a new epub.

Last edited by AlanHK; 09-09-2021 at 08:05 AM.
AlanHK is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Error while parsing file 'element "img" not allowed here" shotsfromthebar Editor 3 03-31-2017 03:53 AM
Ibooks epub 3 error : exactly one 'toc' nav element must be present Firebrand007 ePub 6 01-02-2015 10:00 PM
The element type "p" must be terminated by the matching end-tag "</p>". uieluck ePub 10 02-12-2013 07:04 PM
Engineering Thesis, "Readability of text in present eBooks readers"" japkooo General Discussions 4 10-26-2012 02:43 PM
Getting calibre to detect "Prologue" and "Epilogue" for TOC sherman Calibre 2 09-20-2010 02:21 AM


All times are GMT -4. The time now is 08:20 PM.


MobileRead.com is a privately owned, operated and funded community.