KDP(電子出版)のメモ 急急如律令

Amazon Kindleダイレクト・パブリッシングでの電子出版や電子書籍の作成販売について、文章やイラストの作成や編集方法について書いています。

chainlpのepubをチェックする

chainlp

自炊によく使われるchainlpについていepub的にどうなのか調べてみました。

使ったもの

chainlp http://no722.cocolog-nifty.com/blog/chainlp/

pagina epubchecker http://www.pagina-online.de/produkte/epub-checker/

EpubArchiver http://d.hatena.ne.jp/sauberwind+sakuraSoftware/20130907

 

作業

 chainlpは画像のリサイズや、文字を見やすくするように色を濃くしてくれたり、余白削除するような機能があったりします。キンドル用にmobiに変換してみると、拡大できなかったので原因を調べてみる。

 EPUB出力された中を見てepubcheckをしてみたわけですが、ずらっといっぱいエラーが出てきました。

ちなみに出力したファイル名はchainlptest.epubです。

一つ目

chainlptest.epub: Mimetype entry missing or not the first in archive

 mimetypeがepubの初めに非圧縮で置いてないぞっていう。epubをはじめに直接いじりだしたときによく出る警告がでております。

中をのぞいてみると、一つ目の階層が

フォルダー:content、META-INF

ファイル:iTunesArtwork、metadata.opf、mimetype、toc.ncx

という風になっておりました。ふつうは、はじめのファイルはmimetypeだけかな。

 

2つ目のエラー

chainlptest.epub/mimetype: Mimetype file should contain only the string "application/epub+zip".

  これはすぐわかったmimetypeを開くと、”application/epub+zip”の後に改行が入ってた。それを消すとエラーが消えた。

WinRARで直接編集してたのをいったん解凍してから、EpubArchiverでepubに固めて*1

 

 当然まだまだエラーは残ってます。圧縮しなおしたときにファイル名がtest.epubに変わったよ。

test.epub/metadata.opf(13,50): character content of element "dc:identifier" invalid; must be a string with length at least 1 

metadata.opfにdc:identifierていう固有の番号がないってさー、該当行を見ていくと、

<dc:identifier opf:scheme="ISBN"></dc:identifier>ISBNが入ってないな。入力し忘れかもしれないので適当に10ケタの番号を入れてみた。そしたら消えた。

 次、

ERROR: test.epub/metadata.opf(16,102): attribute "properties" not allowed here; expected attribute "fallback", "fallback-style", "required-modules" or "required-namespace"

 

ERROR: test.epub/metadata.opf(167,41): attribute "page-progression-direction" not allowed here; expected attribute "id" or "toc"

 

ERROR: test.epub/metadata.opf(167,41): element "spine" missing required attribute "toc"

 

ERROR: test.epub/metadata.opf: unique-identifier attribute in package element must reference an existing identifier element id

これを見たとき、指定行じゃなくて宣言のほうに問題があるかなと思った。

ので、宣言文がepub2になってたのをepub3にしてみた。

<package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="calibre_id">

 

<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="calibre_id">

 エラーが増えたけど、違うところのエラーなので修正された気がする。

 

次、また変なのが出てきた。

ERROR: test.epub/metadata.opf(5,48): attribute "opf:role" not allowed here; expected attribute "dir", "id" or "xml:lang"

opf:roleは許可されていませんって出てるので消してみよう。opf:role="aut" を消した

 

次、なんか似たようなエラーがいっぱいなので、次々消していく。

ERROR: test.epub/metadata.opf(5,33): attribute "opf:file-as" not allowed here; expected attribute "dir", "id" or "xml:lang"

 

ERROR: test.epub/metadata.opf(6,54): attribute "opf:role" not allowed here; expected attribute "dir", "id" or "xml:lang"

 

ERROR: test.epub/metadata.opf(6,54): attribute "opf:file-as" not allowed here; expected attribute "dir", "id" or "xml:lang"

 

ERROR: test.epub/metadata.opf(7,53): attribute "opf:scheme" not allowed here; expected attribute "id"

 

ERROR: test.epub/metadata.opf(13,34): attribute "opf:scheme" not allowed here; expected attribute "id"

 opf:file-as="急急如律令"

opf:role="bkp"

  opf:file-as="ChainLP"

 opf:scheme="ChainLP"

 opf:scheme="ISBN"

を消してみた。

次、

ERROR: test.epub/metadata.opf(2,92): assertion failed: package element unique-identifier attribute does not resolve to a dc:identifier element (given reference was 'calibre_id')

 

ERROR: test.epub/metadata.opf(3,158): assertion failed: package dcterms:modified meta element must occur exactly once

 

ERROR: test.epub/metadata.opf(15,11): assertion failed: Exactly one manifest item must declare the 'nav' property (number of 'nav' items: 0).

 

ERROR: test.epub/metadata.opf(165,70): assertion failed: spine element toc attribute must be set when an NCX is included in the publication

 ズラッと定義違反ていうのが出てきました。

 unique-identifier="calibre_id" となってたところを

unique-identifier="BookID"

にしてみたが、変化なし。

<dc:identifier id="calibre_id"> を

<dc:identifier id="BookID"> にかえてみた。

ひとつ減った。

<dc:date>2013-11-21T21:29:58+09:00</dc:date> を

<meta property="dcterms:modified">2013-11-23T21:46:41Z</meta> に変えてみた。

ひとつ減った。つまり、日付の定義の仕方が違ったわけか。

navのプロパティーを指定しろ。

<item id="id2の後に properties="nav" これを追加。

ひとつ減った。

 

 <spine page-progression-direction="rtl"> を

<spine page-progression-direction="rtl" toc="ncx"> にした。

spineにtoc属性を付与しろとあったのでそうする。

metadata.opf のエラーがなくなる。ずらっと並ぶエラーを見ると本文ファイルxhtmlに同じような感じに出現しているので、grepで置き換え用と思う。Devasというソフトを使って一斉に書き換え。

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

を削除

ERROR: test.epub/content/index_P00001.xhtml(5,86): attribute "charset" not allowed here;

charsetという属性は許可されていませんときた。 charset="UTF-8" 削除した。

いっぱいあったのが一気になくなりました。

ERROR: test.epub/content/index_P00001.xhtml(7,7): assertion failed: Exactly one 'toc' nav element must be present

 

ERROR: test.epub/content/resources/index_0.css(15,3): The 'direction' property must not be included in an EPUB Style Sheet.

 

ERROR: test.epub/toc.ncx: External DTD entities are not allowed. Remove the DOCTYPE.

 

ERROR: test.epub/toc.ncx(13,10): element "navMap" incomplete; missing required element "navPoint"

 

ERROR: test.epub/toc.ncx: External DTD entities are not allowed. Remove the DOCTYPE.

 

WARNING: test.epub: item (iTunesArtwork) exists in the zip file, but is not declared in the OPF file

 index_0.cssから  direction: rtl;を削除

 <!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd"> を削除

<navMap></navMap>を下のように書き換え

<navMap>

<navPoint id="toc1" playOrder="1">

<navLabel>

<text>1</text>

</navLabel>

<content src="content/index_P00001.xhtml"/>

</navPoint>

</navMap>

 

 index_P00001.xhtmlを無理やりナビゲーション文章化したので、属性を追加。

<body>の後に

<nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc"></nav>を追加

それでやっぱり、ちゃんとナビゲーション文章を書けと突っ込まれる。

element "nav" incomplete; missing required element "ol"

 

99nyorituryo.hatenablog.com

を参考にナビゲーション文章のnav.xhtmlを別に作って入れることにする。

 

 metadata.opfの<manifest>に

    <item id="toc" properties="nav" href="content/nav.xhtml" media-type="application/xhtml+xml" />

 を追加。

    <item id="id2" href="content/index_P00001.xhtml" media-type="application/xhtml+xml" />

から  properties="nav" を削除

nav.xhtmlの内容。

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="ja" xml:lang="ja">

<head>

<title>chainlptest</title>

</head>

 

<body>

<nav epub:type="landmarks" id="landmarks" hidden="hidden">

<h2>Guide</h2>

<ol>

<li><a epub:type="bodymatter" href="index_P00001.xhtml">本文</a></li>

</ol>

</nav>

<nav epub:type="toc" id="nav" hidden="hidden">

<h1>目 次</h1>

<ol>

<li><a href="index_P00001.xhtml">一ページ</a></li>

</ol>

</nav>

</body>

</html>

最後に 

WARNING: test.epub: item (iTunesArtwork) exists in the zip file, but is not declared in the OPF file

iTunesArtworkが残っていました。ファイルがあるけどあるって書いてないよって内容。必要なさそうなので消す。

No errors or warnings detected

エラーがなくなった、ただし、これで正常に動くわけではない。

 途中で疲れてきた。ここまでにしておこう。

後で思ったこと、chainlpでzip圧縮で出力してから、aozoraepub3で出力したほうが早いような気がしてきた。

画像ファイルをzipで固めたファイルを下のサイトのように出力したほうが早いように思う。

99nyorituryo.hatenablog.com

タグ:epubchecker使い方 コマンド 日本語 ダウンロード windows エラー validate validator バリデート バリデーター バリデーション validation readium pdf zip iphone mac googleplay books

*1:注:もう一度epubcheck で何度もチェックしたりエラーメッセージをコピーしやすいようにpaginaEpub checkを使った。