一般epub文件內部結構圖
--ZIP Container--
mimetype
META-INF/
container.xml
OPS/
book.opf
chapter1.xhtml
ch1-pic.png
css/
style.css
myfont.otf
|
一般epub文件都是封裝在zip文件中,包函了上面的一般文件.
mimetype文件主要是指出這個zip文件的格式類型,文件中應該包括以下字符: application/epub+zip.
META-INF是一個目錄,目錄下包函了一個文件叫做container.xml,指出epub的內容,存放在哪個目錄下,一般都是指出opf文件的位置,因為opf文件已經指出了所有相關的資源的對應位置,直接可以定位並閱讀了.container.xml的例子如下:
<?xml version="1.0" encoding="UTF-8" ?> <container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> <rootfiles> <rootfile full-path="OPS/book.opf" media-type="application/oebps-package+xml"/> </rootfiles> </container> |
OPS是一個目錄.結構如下:
|
|
.其中有一個文件以.opf做為後綴,指出了epub文件的結構並包含了相關的epub電子書信息..opf的結構如下:
<?xml version="1.0"?> <package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId"> //epub相關信息 <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> <dc:title>Pride and Prejudice</dc:title> <dc:language>en</dc:language> <dc:identifier id="BookId" opf:scheme="ISBN">123456789X</dc:identifier> <dc:creator opf:file-as="Austen, Jane" opf:role="aut">Jane Austen</dc:creator> </metadata> //OPS目錄下面的所有文件,除了這個文件本身 <manifest> <item id="chapter1" href="chapter1.xhtml" media-type="application/xhtml+xml"/> <item id="stylesheet" href="style.css" media-type="text/css"/> <item id="ch1-pic" href="ch1-pic.png" media-type="image/png"/> <item id="myfont" href="css/myfont.otf" media-type="application/x-font-opentype"/> <item id="ncx" href="book.ncx" media-type="application/x-dtbncx+xml"/> </manifest> //能通過鏈接到達的文件,打算顯示給用戶看的,idref名字必需通過後綴能找到相應的文件 <spine toc="ncx"> <itemref idref="chapter1" /> </spine> //可選參數,導讀作用 <guide> <reference type="loi" title="List Of Illustrations" href="appendix.html#figures" /> </guide> </package |
.ncx文件相當於目錄,結構如下:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd"> <ncx version="2005-1" xml:lang="en" xmlns="http://www.daisy.org/z3986/2005/ncx/"> <head> <!-- The following four metadata items are required for all NCX documents, including those conforming to the relaxed constraints of OPS 2.0 --> <meta name="dtb:uid" content="123456789X"/> <!-- same as in .opf --> <meta name="dtb:depth" content="1"/> <!-- 1 or higher --> <meta name="dtb:totalPageCount" content="0"/> <!-- must be 0 --> <meta name="dtb:maxPageNumber" content="0"/> <!-- must be 0 --> </head> <docTitle> <text>Pride and Prejudice</text> </docTitle> <docAuthor> <text>Austen, Jane</text> </docAuthor> <navMap> <navPoint class="chapter" id="chapter1" playOrder="1"> <navLabel><text>Chapter 1</text></navLabel> <content src="chapter1.xhtml"/> </navPoint> </navMap> </ncx> |
由上面的一些文件,可以構成一個完整的epub文件了,但我們如何才能知道創建的文件上正確的呢?不用擔心,開源的東西一般都會提供一套相關的工具,下面的一個軟件是可以判斷epub文件是否合理的 http://code.google.com/p/epubcheck/ 下篇文章將介紹如何使用它.
有問題請聯系:QQ:49 27 8 6 8 1 6 附加信息:sam epub

