返回首页
当前位置: 主页 > 手机mobile >

Epub電子書格式解析

时间:2010-08-02 11:45来源:未知 作者:sam.huang 点击:
一般epub文件內部結構圖 --ZIP Container--mimetypeMETA-INF/ container.xmlOPS/ book.opf chapter1.xhtml ch1-pic.png css/ style.css myfont.otf 一般epub文件都是封裝在zip文件中,包函了上面的一般文件. mimetype文件主要
  

 一般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是一個目錄.結構如下:

 

  1. OPS/ 
  2.    .opf (xml 文件) 指出資源的位置與epub具體信息 
  3.    .ncx (xml 文件) 相當於書的目錄 
  4.    一堆資源文件,主要是opf中包含的. 

.其中有一個文件以.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

顶一下
(1)
50%
踩一下
(1)
50%
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
发布者资料
amw 查看详细资料 发送留言 加为好友 用户等级:高级会员 注册时间:2009-03-30 13:03 最后登录:2012-01-17 11:01
推荐内容