View Single Post
Old 02-14-2014, 11:03 PM   #12
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,430
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by rpspringuel View Post
Declaring the namespace isn't that hard. I just need to add xmlns:epub="http://www.idpf.org/2007/ops" in the right place.
Thats not the hard part, see below.

Quote:
Unfortunately the editor currently doesn't know what to do with this declaration though. If added to the metadata tag in the metadata file (where several other namespaces are declared) then the declaration is lost in a save/close/reopen cycle. Uses of the namespace in the text files are unaffected (: gets converted to u0003a). If I try to use one of the other namespaces that are declared in the same place (dc, opf, calibre) the character swap still happens. If I declare the epub namespace within the html tag of a text document, then the declaration is removed and the name space is stripped from the tags where it is used (i.e. epub:type="pagebreak" becomes type="pagebreak"). This behavior is all specific to editing azw3 files, editing ePub's exhibit none of these behaviors (ePub's even retain the : when the namespace hasn't been declared).
Since azw3 does not support the epub namespace or indeed the epub spec in any form, that's hardly surprising.

Quote:
As for the file being valid XML, isn't that a given? I understood azw3 to be an amazon specific compilation of ePub. Since ePub files have to be valid XML (or more specifically XHTML) shouldn't an azw3 file be valid XML? Am I missing something?
Ah the innocence of youth. The chances of encountering a valid XML file, let alone a valid XHTML file in the wild are about as high as the chances of encountering valid XHTML on the web. So if you want to use epub:type the onus is on you to make sure that the file you are outputting somehow magically becomes valid XML from tag soup. calibre has nearly 10,000 lines of code dedicated to the task of taking tag soup and outputting valid XML. SO unless your book has been previously processed by calibre and then not further processed by anything else, you are likely to be out of luck.

Quote:
Since this is based on the ePub standard (which also uses span tags) that would imply that using CSS selectors based on tag counts would not be recommended in this instance anyway.
The epub standard does not use span tags. The standard simply declares an attribute that can be placed on (almost) any tag. And the selectors I am referring to are selectors like first-child, last-child, nth-child which will break if you change the number of children by inserting a new tag.
kovidgoyal is offline   Reply With Quote