epub格式电子书剖析

epub格式电子书遵循IDPF推出的OCF规范,OCF规范遵循ZIP压缩技术,即epub电子书本身就是一个ZIP文件,我们将epub格式电子书的后缀.epub修改为.zip后,可以通过解压缩软件(例如winrar、winzip)进行浏览或解压处理。一个未经加密处理的epub电子书以三个部分组成,其文件结构如下图所示:

epub格式电子书剖析之一:文档构成

1、文件:mimetype

每一本epub电子书均包含一个名为mimetype的文件,且内容不变,用以说明epub的文件格式。文件内容如下:

application/epub+zip//注释,表示可以用epub工具和ZIP工具打开

2、目录:META-INF

依据OCF规范,META-INF用于存放容器信息,默认情况下(即加密处理),该目录包含一个文件,即container.xml,文件内容如下:

<?xml version='1.0' encoding='utf-8'?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml" />
</rootfiles>
</container>

container.xml的主要功能用于告诉阅读器,电子书的根文件(rootfile)的路径(红色部分)和打开放式,一般来讲,该container.xml文件也不需要作任何修改,除非你改变了根文件的路径和文件名称。

除container.xml文件之外,OCF还规定了以下几个文件:

(1)[manifest.xml],文件列表
(2)[metadata.xml],元数据
(3)[signatures.xml],数字签名
(4)[encryption.xml],加密
(5)[rights.xml],权限管理
对于epub电子书而言,这些文件都是可选的。

3、目录:OEBPS

OEBPS目录用于存放OPS文档、OPF文档、CSS文档、NCX文档,如果是制作中文电子书,则还包括ttf文档(即字体文档),OEBPS目录也可以建立相应的子目录,例如建立chapter目录,把各章节的OPS文档放在chapter目录之中。下图一本epub电子书OEBPS文档的实例图:

epub格式电子书剖析之一:文档构成

其中content.opf文件和toc.ncx文件为必需,其它文件可根据电子书的具体情况而定。

OPF文件构成:

OPF文档是epub电子书的核心文件,且是一个标准的XML文件,依据OPF规范,主要由五个部分组成:

1、<metadata>,元数据信息,由两个子元素组成:

  • <dc-metadata>,其元素构成采用dubline core(DC)的15项核心元素,包括:
    • <title>:题名
    • <creator>:责任者
    • <subject>:主题词或关键词
    • <description>:内容描述
    • <contributor>:贡献者或其它次要责任者
    • <date>:日期
    • <type>:类型
    • <format>:格式
    • <identifier>:标识符
    • <source>:来源
    • <language>:语种
    • <relation>:相关信息
    • <coverage>:履盖范围
    • <rights>:权限描述
  • <x-metadata>,即扩展元素。如果有些信息在上述元素中无法描述,则在此元素中进行扩展。

2、<menifest>,文件列表,由于列出OEBPS文档及相关的文档,有一个子元素构成,

  • <item id="" href="" media-type="">,该元素由三个属性构成:
    • id:表示文件的ID号
    • href:文件的相对路径
    • media-type:文件的媒体类型
    • 例如:<item id="chap01" href="chap01.xhtml" media-type="application/xhtml+xml"/>

3、<spine toc="ncx">,脊骨,其主要功能是提供书籍的线性阅读次序。由一个子元素构成:

  • <itemref idref="">,由一个属性构成:
    • idref:即参照menifest列出的ID
    • 例如:<itemref idref="chap01"/>

4、<guide>,指南,依次列出电子书的特定页面, 例如封面、目录、序言等, 属性值指向文件保存地址。一般情况下,epub电子书可以不用该元素。

5、<tour>,导读。可以根据不同的读者水平或者阅读目的, 按一定次序, 选择电子书中的部分页面组成导读。一般情况下,epub电子书可以不用该元素。

content.opf实例:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE package PUBLIC "+//ISBN 978-7-308-05831-5//DTD OEB 1.2 Package//EN" "http://openebook.org/dtds/oeb-1.2/oebpkg12.dtd">
<package unique-identifier="bookid" xmlns:opf="http://www.idpf.org/2007/opf" xmlns="http://www.idpf.org/2007/opf" version="2.0">
<metadata>
<dc-metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<dc:title>数字档案馆理论与技术研究</dc:title>
<dc:creator>金更达</dc:creator>
<dc:subject>数字档案馆</dc:subject>
<dc:subject>电子文件管理</dc:subject>
<dc:subject>元数据</dc:subject>
<dc:subject>数字化</dc:subject>
<dc:subject>档案化</dc:subject>
<dc:description>当……<dc:description>
<dc:publisher>机械工业出版社</dc:publisher>
<dc:contributor/>
<dc:date>2007-09</dc:date>
<dc:type>普通图书</dc:type>
<dc:format>Text/html(.html,.htm)</dc:format>
<dc:identifier id="bookid" opf:scheme="ISBN">isbn:978-7-111-04961-6</dc:identifier>
<dc:source/>
<dc:language>chi</dc:language>
<dc:relation/>
<dc:coverage/>
<dc:rights>机械工业出版社版权所有</dc:rights>
</dc-metadata>
<x-metadata/>
</metadata>
<manifest>
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
<item id="style" href="style.css" media-type="text/css"/>
<item id="cover" href="cover.htm" media-type="text/html"/>
<item id="tableofc" href="toc.xhtml" media-type="application/xhtml+xml"/>
<item id="forword" href="forword.xhtml" media-type="application/xhtml+xml"/>
<item id="chap01" href="chap01.xhtml" media-type="application/xhtml+xml"/>
<item id="chap02" href="chap02.xhtml" media-type="application/xhtml+xml"/>
<item id="chap03" href="chap03.xhtml" media-type="application/xhtml+xml"/>
<item id="chap04" href="chap04.xhtml" media-type="application/xhtml+xml"/>
<item id="chap05" href="chap05.xhtml" media-type="application/xhtml+xml"/>
<item id="chap06" href="chap06.xhtml" media-type="application/xhtml+xml"/>
<item id="chap07" href="chap07.xhtml" media-type="application/xhtml+xml"/>
<item id="chap08" href="chap08.xhtml" media-type="application/xhtml+xml"/>
<item id="chap09" href="chap09.xhtml" media-type="application/xhtml+xml"/>
<item id="chap10" href="chap10.xhtml" media-type="application/xhtml+xml"/>
<item id="reference" href="reference.xhtml" media-type="application/xhtml+xml"/>
</manifest>
<spine toc="ncx">
<itemref idref="cover"/>
<itemref idref="tableofc"/>
<itemref idref="forword"/>
<itemref idref="chap01"/>
<itemref idref="chap02"/>
<itemref idref="chap03"/>
<itemref idref="chap04"/>
<itemref idref="chap05"/>
<itemref idref="chap06"/>
<itemref idref="chap07"/>
<itemref idref="chap08"/>
<itemref idref="chap09"/>
<itemref idref="chap10"/>
<itemref idref="reference"/>
</spine>
<guide/>
</package>

NCX文件构成:

ncx文件是epub电子书的又一个核心文件,用于制作电子书的目录,其文件的命名通常为toc.ncx。

ncx文件是一个XML文件,该标准由DAISY Consortium发布(参见http://www.daisy.org)。

下列是一个toc.ncx文件的实例,其中红色部分为必需。<navMap>元素列出了目录的名称和链接地址。其子元素<navPoint>支持嵌套。

<?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" 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=" "/>
<meta name="dtb:depth" content="-1"/>
<meta name="dtb:totalPageCount" content="0"/>
<meta name="dtb:maxPageNumber" content="0"/>
</head>
<docTitle>
<text>数字档案馆理论与技术研究</text>
</docTitle>
<docAuthor>
<text>金更达</text>
</docAuthor>
<navMap>
<navPoint id="navpoint-1" playOrder="1">
<navLabel>
<text>封面</text>
</navLabel>
<content src="cover.htm"/>
</navPoint>
<navPoint id="navpoint-2" playOrder="2">
<navLabel>
<text>序</text>
</navLabel>
<content src="forword.xhtml"/>
</navPoint>
<navPoint id="navpoint-3" playOrder="3">
<navLabel>
<text>目录</text>
</navLabel>
<content src="toc.xhtml"/>
</navPoint>
<navPoint id="navpoint-4" playOrder="4">
<navLabel>
<text>第一章 绪论</text>
</navLabel>
<content src="chap01.xhtml"/>
<navPoint id="navpoint-5" playOrder="5">
<navLabel>
<text>第一节 数字档案馆:新世纪档案事业的发展方向</text>
</navLabel>
<content src="chap01.xhtml#_Toc169344163"/>
</navPoint>
<navPoint id="navpoint-6" playOrder="6">
<navLabel>
<text>第二节 数字档案馆:新世纪档案工作的严峻挑战</text>
</navLabel>
<content src="chap01.xhtml#_Toc169344164"/>
</navPoint>
<navPoint id="navpoint-7" playOrder="7">
<navLabel>
<text>第三节 数字档案馆系统研究的理论价值与现实意义</text>
</navLabel>
<content src="chap01.xhtml#_Toc169344165"/>
</navPoint>
</navPoint>
</navMap>
</ncx>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值