XML Errors in Scrivener ePub Compilation

Hi,

today I tried to upload an ePub3 Book to Tolino and feiyr but they rejected the file because of severe XML errors. The errors seem so occur in the table of contents section that was generated by Scrivener. Here is one of the errors that I got from feiyr:

  • RSC-005 in body2.xhtml, Zeile 16, Position 64: Error while parsing file: value of attribute “id” is invalid; must be a string matching the regular expression “[^\s]+”

Any idea what is causing this? I checked the line in Sigil:

<p class="standard-links"><a id="Alles was du brauchst, ist weniger"></a><a href="body7.xhtml"><span class="standard-links">Alles was du brauchst, ist weniger</span></a></p>

Can anybody see, what is causing these errors? How do I avoid them?

Thanks and cheers

Robert

This does not appear to be a table of contents that Scrivener would create. For one thing it places the ToC into a file named ‘contents.xhtml’, but yours is coming from ‘body2.xhtml’. But the structure is all wrong as well. A real nav ToC line would look like:

<li><a href="body7.xhtml">Alles was du brauchst, ist weniger</a></li>

I’m wondering if maybe you have created a custom contents page, but its name does not match the ToC settings in the compiler tab for setting up contents? The default may be the English word “Contents”, which could be a factor here. You can change that to what you want to really call the section in the binder (and in ePub navigation). Not doing so would indeed treat the contents as a normal numbered ‘bodyX.xhtml’ section like you get. It wouldn’t be analysed as a navigation element, and thus wouldn’t establish the ebook’s internal navigation—it would only be a section with a list of links in it.

So that’s one problem, the other appears to be excessive formatting. The custom ToC section for ePub is not like normal content, it has strict rules that are described in the user manual PDF, under §22.3, Contents in Ebooks. Flip to the yellow tip box for the instructions to follow.

This is because, as noted, this is not only something your readers will see when flipping through pages, but it is metadata that defines how the book works—how the software reader will create a navigation menu, and how the next/prev chapter buttons or shortcuts work.

So you can’t have styled text in here (you seem to be using a “Standard Links” style), nor additional elements on the line. It must be purely a hyperlink to the section, from the very first character on the line to the very last. No bullets, no annotations, nothing fancy.

The last component that confuses me is how you are getting an <a id="..."></a> element in the output. I cannot think of a feature that would cause Scrivener to create something like that. It will insert section IDs, but it tries to embed them into the nearest block element rather than using a void anchor like that, and it uses generic labels to avoid validity problems like how titles might have bad characters (the comma in this case) for IDs. For example we might expect to see, <p class="standard-links" id="doc2">...</p>.

1 Like

Well I used exactly the process of creating a ToC that is described in this Youtube video:

https://www.youtube.com/watch?v=2d9kIrb4YqI

That created exactly these lines.

This looks like a good tutorial for creating a PDF, and I might have missed it but I don’t see anything about ePubs. This kind of table of contents, with indents and tab stops and dot leaders and page numbers… none of that is of use in an ePub and will mess up the navigation page.

Refer to §22.1, under bullet point 2, for which menu command you should be using to create an ebook ToC section.

(And also: bear in mind that if you do nothing to make a ToC, with ePub you will get one automatically, based on your section/page breaks. You only need to make your own custom ToC page if you don’t want all of your page breaks to become navigation points.)


Update: okay, yes I do see the invalid anchor ID output when using links like this. That is a bug, and I don’t understand why it is generating an ID in front of every hyperlink like this, using the name of the link target text as the ID. That makes no conceptual sense for why anyone would want that, and it is unsafe to do.

2 Likes

means: NOT, one or more, whitespace.
So: Remove spaces from the anchor with the ID.

@AmberV is right for the official contents.xhtml, but an extra ToC, visible in the book itself, can have any formatting you like, but you’re responsible for working links.
Validation of your e-book should take care of any error with links.

Having ID’s in the links in a ToC is a bit strange, for it’s a destination more than a starting point.
One would expect the destination document to have an anchor with an ID.

the XHTML looks generated, the spans are rather superfluous and the classname is repeated unnecessary. You could do without the Paragraph tag too:

<a id="AllesWasDuBrauchstIstWeniger" class="standard-links" href="body7.xhtml#anchorWithID">Alles was du brauchst, ist weniger</a>

Hope this helps

2 Likes

That’s true, though if all you want is fancy formatting, it is valid to add CSS to design the official ToC page in a book. (And note that thread goes into the same pitfall of using a print ToC in an eBook.)

2 Likes

Sorry - but I tried everything that is written in the manual. Especially section 22.

It simply doesn’t work. The EPUP gets rejected by Tolino and Feiyr every time. It throws XML errors for all Toc lines.

I’m giving up on Scrivener. That is not how a professional program for authors should work. The most important function - the compile process - seems to be broken and creates unusable files.

That is really annoying!

Regards

Robert

It’s not uncommon to exercise more control over the result by opening the ePub in epub-editors like Sigil or Calibre.
The validation plug-in will show you error messages with line and position numbers, so you can solve them.

If you post your error messages here, we can help you get past them, as well.

3 Likes

That is very kind. But I’m not a coder - I’m an author. That’s why I bought Scrivener. I don’t want to mess around with XML files. That is the job of the software that I bought.

I will now give a competitor a try and see if they better understand that a clean and error free creation of an epup file is a standard task for this kind of program.

Thanks again for your offer but I have to find a better tool for this kind of work.

Cheers

Robert

Well, hope all goes well with your journey into publishing as an author. May I ask what product you are moving to?

The most important functions of Scrivener are the functions that allowed you to create a complete manuscript in the first place.

3 Likes