epub-parser 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +7 -0
- data/README.markdown +4 -0
- data/docs/Publication.markdown +18 -0
- data/lib/epub/cfi.rb +22 -22
- data/lib/epub/ocf/physical_container.rb +2 -0
- data/lib/epub/ocf/physical_container/archive_zip.rb +3 -1
- data/lib/epub/parser/ocf.rb +3 -2
- data/lib/epub/parser/publication.rb +0 -1
- data/lib/epub/parser/version.rb +1 -1
- data/lib/epub/publication/package/manifest.rb +13 -2
- metadata +2 -6
- data/schemas/epub-nav-30.rnc +0 -10
- data/schemas/epub-nav-30.sch +0 -72
- data/schemas/epub-xhtml-30.sch +0 -377
- data/schemas/ocf-container-30.rnc +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccf4841189745cdaa96e82b64a3493e4a3dc2421
|
4
|
+
data.tar.gz: e2c83bc88d36a63957b313136372568506377ae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e635c138b09d454c17fd8f93b59b04403e828c73a4a0be14dc7d133501bc219a6d41a7d1108091b4bc845276ab33e7905d5ba7caed9403904cb6a71058c59dcf
|
7
|
+
data.tar.gz: 12fe31458bfcfd89e8dd6fee555473f02370c613893ee681b2a7d9b6d2db70640bdb1403140300057016c4595976d678509ab812de070e25b63b8e6dac17ee70
|
data/CHANGELOG.markdown
CHANGED
data/README.markdown
CHANGED
@@ -151,6 +151,10 @@ If you find other gems, please tell me or request a pull request.
|
|
151
151
|
RECENT CHANGES
|
152
152
|
--------------
|
153
153
|
|
154
|
+
### 0.2.5
|
155
|
+
|
156
|
+
* [BUG FIX]RaiseDon't load Zip/Ruby if unneccessary
|
157
|
+
|
154
158
|
### 0.2.4
|
155
159
|
|
156
160
|
* Bug fix for `EPUB::CFI::Location#<=>`
|
data/docs/Publication.markdown
CHANGED
@@ -34,6 +34,24 @@ You can access them by:
|
|
34
34
|
Manifest
|
35
35
|
--------
|
36
36
|
|
37
|
+
{EPUB::Publication::Package::Manifest Manifest} lists all the files in the package with some basic information such as filepath, media type and so on. Those files is represented as {EPUB::Publication::Package::Manifest::Item Item}s and see {file:docs/Item.markdown} for details.
|
38
|
+
|
39
|
+
You can access manifest by:
|
40
|
+
|
41
|
+
manifest = book.package.manifest # => EPUB::Publication::Package::Manifest
|
42
|
+
|
43
|
+
And can access items it manages via some methods:
|
44
|
+
|
45
|
+
manifest.items # => an array of Items
|
46
|
+
manifest.cover_image # => Item which represents cover images, which includes the string "cover-image" in its property attribute.
|
47
|
+
manifest.each_item do |item|
|
48
|
+
# do something with item
|
49
|
+
end
|
50
|
+
manifest.navs # => an array of Items which include the string "nav" in its property attribute.
|
51
|
+
manifest.nav # => The first Item in manifest.navs.
|
52
|
+
|
53
|
+
For complete list of methods, see API reference: {EPUB::Publication::Package::Manifest}
|
54
|
+
|
37
55
|
Spine
|
38
56
|
-----
|
39
57
|
|
data/lib/epub/cfi.rb
CHANGED
@@ -85,11 +85,11 @@ module EPUB
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def to_s
|
88
|
-
@string_cache ||= (steps.join + offset.to_s)
|
88
|
+
@string_cache ||= (steps.join + offset.to_s)
|
89
89
|
end
|
90
90
|
|
91
91
|
def to_fragment
|
92
|
-
@fragment_cache ||= "epubcfi(#{self})"
|
92
|
+
@fragment_cache ||= "epubcfi(#{self})"
|
93
93
|
end
|
94
94
|
|
95
95
|
def <=>(other)
|
@@ -173,11 +173,11 @@ module EPUB
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def to_s
|
176
|
-
@string_cache ||= (first.to_fragment + (exclude_end? ? '...' : '..') + last.to_fragment)
|
176
|
+
@string_cache ||= (first.to_fragment + (exclude_end? ? '...' : '..') + last.to_fragment)
|
177
177
|
end
|
178
178
|
|
179
179
|
def to_fragment
|
180
|
-
@fragment_cache ||= "epubcfi(#{@parent},#{@start},#{@end})"
|
180
|
+
@fragment_cache ||= "epubcfi(#{@parent},#{@start},#{@end})"
|
181
181
|
end
|
182
182
|
end
|
183
183
|
|
@@ -196,7 +196,7 @@ module EPUB
|
|
196
196
|
end
|
197
197
|
|
198
198
|
def to_s
|
199
|
-
@string_cache ||= "/#{value}#{assertion}"
|
199
|
+
@string_cache ||= "/#{value}#{assertion}" # need escape?
|
200
200
|
end
|
201
201
|
|
202
202
|
def <=>(other)
|
@@ -222,14 +222,14 @@ module EPUB
|
|
222
222
|
|
223
223
|
def to_s
|
224
224
|
return @string_cache if @string_cache
|
225
|
-
|
226
|
-
|
225
|
+
string_cache = '['
|
226
|
+
string_cache << CFI.escape(id) if id
|
227
227
|
parameters.each_pair do |key, values|
|
228
228
|
value = values.join(',')
|
229
|
-
|
229
|
+
string_cache << ";#{CFI.escape(key)}=#{CFI.escape(value)}"
|
230
230
|
end
|
231
|
-
|
232
|
-
@string_cache
|
231
|
+
string_cache << ']'
|
232
|
+
@string_cache = string_cache
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
@@ -243,15 +243,15 @@ module EPUB
|
|
243
243
|
|
244
244
|
def to_s
|
245
245
|
return @string_cache if @string_cache
|
246
|
-
|
247
|
-
|
248
|
-
|
246
|
+
string_cache = '['
|
247
|
+
string_cache << CFI.escape(preceded) if preceded
|
248
|
+
string_cache << ',' << CFI.escape(followed) if followed
|
249
249
|
parameters.each_pair do |key, values|
|
250
250
|
value = values.join(',')
|
251
|
-
|
251
|
+
string_cache << ";#{CFI.escape(key)}=#{CFI.escape(value)}"
|
252
252
|
end
|
253
|
-
|
254
|
-
@string_cache
|
253
|
+
string_cache << ']'
|
254
|
+
@string_cache = string_cache
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
@@ -265,7 +265,7 @@ module EPUB
|
|
265
265
|
end
|
266
266
|
|
267
267
|
def to_s
|
268
|
-
@string_cache ||= ":#{value}#{assertion}"
|
268
|
+
@string_cache ||= ":#{value}#{assertion}" # need escape?
|
269
269
|
end
|
270
270
|
|
271
271
|
def <=>(other)
|
@@ -281,15 +281,15 @@ module EPUB
|
|
281
281
|
raise RangeError, "dimension must be in 0..100 but passed #{y}" unless (0.0..100.0).cover?(y) if y
|
282
282
|
warn "Assertion is passed to #{__class__} but cannot know how to handle with it: #{assertion}" if assertion
|
283
283
|
@temporal, @x, @y, @assertion = temporal, x, y, assertion
|
284
|
-
@string_cache
|
284
|
+
@string_cache = nil
|
285
285
|
end
|
286
286
|
|
287
287
|
def to_s
|
288
288
|
return @string_cache if @string_cache
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
@string_cache
|
289
|
+
string_cache = ''
|
290
|
+
string_cache << "~#{temporal}" if temporal
|
291
|
+
string_cache << "@#{x}:#{y}" if x or y
|
292
|
+
@string_cache = string_cache
|
293
293
|
end
|
294
294
|
|
295
295
|
# @note should split the class to spatial offset and temporal-spatial offset?
|
@@ -22,8 +22,8 @@ module EPUB
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def read(path_name)
|
25
|
-
target_index = @entries[path_name]
|
26
25
|
if @archive
|
26
|
+
target_index = @entries[path_name]
|
27
27
|
@archive.each.with_index do |entry, index|
|
28
28
|
if target_index
|
29
29
|
if target_index == index
|
@@ -41,6 +41,8 @@ module EPUB
|
|
41
41
|
return entry.file_data.read
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
raise NoEntry
|
44
46
|
else
|
45
47
|
open {|container| container.read(path_name)}
|
46
48
|
end
|
data/lib/epub/parser/ocf.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'epub/constants'
|
2
2
|
require 'epub/ocf'
|
3
3
|
require 'epub/ocf/physical_container'
|
4
|
-
require 'zipruby'
|
5
4
|
require 'nokogiri'
|
6
5
|
|
7
6
|
module EPUB
|
@@ -27,7 +26,9 @@ module EPUB
|
|
27
26
|
begin
|
28
27
|
data = @container.read(File.join(DIRECTORY, "#{m}.xml"))
|
29
28
|
@ocf.__send__ "#{m}=", __send__("parse_#{m}", data)
|
30
|
-
rescue ::
|
29
|
+
rescue EPUB::OCF::PhysicalContainer::NoEntry, ::Errno::ENOENT, OpenURI::HTTPError
|
30
|
+
rescue => error
|
31
|
+
raise error unless (Object.const_defined? :Zip and ::Zip.const_defined? :Error and error.kind_of? ::Zip::Error)
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
data/lib/epub/parser/version.rb
CHANGED
@@ -17,7 +17,8 @@ module EPUB
|
|
17
17
|
@items = {}
|
18
18
|
end
|
19
19
|
|
20
|
-
# @
|
20
|
+
# @param item [Item]
|
21
|
+
# @return [Manifest] self
|
21
22
|
def <<(item)
|
22
23
|
item.manifest = self
|
23
24
|
@items[item.id] = item
|
@@ -34,18 +35,26 @@ module EPUB
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
38
|
+
# @return [Array<Item>] item which includes "nav" as one of +properties+. It represents this item is a navigation of book.
|
37
39
|
def navs
|
38
40
|
items.select(&:nav?)
|
39
41
|
end
|
40
42
|
|
43
|
+
# @return [Item, nil] the first item of #navs
|
41
44
|
def nav
|
42
45
|
navs.first
|
43
46
|
end
|
44
47
|
|
48
|
+
# @return [Item, nil] item which includes "cover-image" as one of +properties+. It represents this item is cover image.
|
45
49
|
def cover_image
|
46
|
-
items.
|
50
|
+
items.find(&:cover_image?)
|
47
51
|
end
|
48
52
|
|
53
|
+
# @overload each_item
|
54
|
+
# @yield [item]
|
55
|
+
# @yieldparam [Item]
|
56
|
+
# @overload each_item
|
57
|
+
# @return [Enumerator]
|
49
58
|
def each_item
|
50
59
|
if block_given?
|
51
60
|
@items.each_value do |item|
|
@@ -60,6 +69,8 @@ module EPUB
|
|
60
69
|
@items.values
|
61
70
|
end
|
62
71
|
|
72
|
+
# @param item_id [String]
|
73
|
+
# @return [Item, nil]
|
63
74
|
def [](item_id)
|
64
75
|
@items[item_id]
|
65
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epub-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KITAITI Makoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -338,10 +338,6 @@ files:
|
|
338
338
|
- lib/epub/searcher/result.rb
|
339
339
|
- lib/epub/searcher/xhtml.rb
|
340
340
|
- man/epubinfo.1.ronn
|
341
|
-
- schemas/epub-nav-30.rnc
|
342
|
-
- schemas/epub-nav-30.sch
|
343
|
-
- schemas/epub-xhtml-30.sch
|
344
|
-
- schemas/ocf-container-30.rnc
|
345
341
|
- test/fixtures/book/META-INF/container.xml
|
346
342
|
- test/fixtures/book/OPS/%E6%97%A5%E6%9C%AC%E8%AA%9E.xhtml
|
347
343
|
- test/fixtures/book/OPS/case-sensitive.xhtml
|
data/schemas/epub-nav-30.rnc
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
default namespace = "http://www.w3.org/1999/xhtml"
|
4
|
-
namespace epub = "http://www.idpf.org/2007/ops"
|
5
|
-
|
6
|
-
include "epub-xhtml-30.rnc" {
|
7
|
-
html5.nav.content = html5.headings.class?, html5.ol
|
8
|
-
html5.oli.content = html5.a.phrasing | ((html5.a.phrasing | html5.span), html5.ol)
|
9
|
-
}
|
10
|
-
|
data/schemas/epub-nav-30.sch
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
|
3
|
-
|
4
|
-
<ns uri="http://www.w3.org/1999/xhtml" prefix="html"/>
|
5
|
-
<ns uri="http://www.idpf.org/2007/ops" prefix="epub"/>
|
6
|
-
|
7
|
-
<pattern id="nav-ocurrence">
|
8
|
-
<rule context="html:body">
|
9
|
-
<assert test="count(.//html:nav[@epub:type='toc']) = 1">Exactly one 'toc' nav element
|
10
|
-
must be present</assert>
|
11
|
-
<assert test="count(.//html:nav[@epub:type='page-list']) < 2">Multiple occurrences of
|
12
|
-
the 'page-list' nav element</assert>
|
13
|
-
<assert test="count(.//html:nav[@epub:type='landmarks']) < 2">Multiple occurrences of
|
14
|
-
the 'landmarks' nav element</assert>
|
15
|
-
</rule>
|
16
|
-
</pattern>
|
17
|
-
|
18
|
-
<pattern id="span-no-sublist">
|
19
|
-
<rule context="html:body//html:nav//html:span">
|
20
|
-
<assert test="count(.//ol) = 0"> The span element must only be used as heading for flat
|
21
|
-
sublists (not hierarchical navigation structures) </assert>
|
22
|
-
</rule>
|
23
|
-
</pattern>
|
24
|
-
|
25
|
-
<pattern id="landmarks">
|
26
|
-
<rule context="html:nav[@epub:type='landmarks']//html:ol//html:a">
|
27
|
-
<assert test="@epub:type">Missing epub:type attribute on anchor inside 'landmarks' nav
|
28
|
-
element</assert>
|
29
|
-
</rule>
|
30
|
-
</pattern>
|
31
|
-
|
32
|
-
<pattern id="link-labels">
|
33
|
-
<rule context="html:nav//html:ol//html:a">
|
34
|
-
<assert test="string-length(normalize-space(string(.))) > 0">Anchors within nav elements
|
35
|
-
must contain text</assert>
|
36
|
-
</rule>
|
37
|
-
</pattern>
|
38
|
-
|
39
|
-
<pattern id="span-labels">
|
40
|
-
<rule context="html:nav//html:ol//html:span">
|
41
|
-
<assert test="string-length(normalize-space(string(.))) > 0">Spans within nav elements
|
42
|
-
must contain text</assert>
|
43
|
-
</rule>
|
44
|
-
</pattern>
|
45
|
-
|
46
|
-
<pattern id="req-heading">
|
47
|
-
<rule
|
48
|
-
context="html:nav[not(@epub:type = 'toc') and not (@epub:type = 'page-list') and not (@epub:type = 'landmarks')]">
|
49
|
-
<let name="fc" value="local-name(./*[1])"/>
|
50
|
-
<assert test="(starts-with($fc,'h') and string-length($fc) = 2) or ($fc = 'hgroup')">nav
|
51
|
-
elements other than 'toc', 'page-list' and 'landmarks' must contain a heading as the
|
52
|
-
first child</assert>
|
53
|
-
</rule>
|
54
|
-
</pattern>
|
55
|
-
|
56
|
-
<pattern id="heading-content">
|
57
|
-
<rule context="html:h1|html:h2|html:h3|html:h4|html:h5|html:h6|html:hgroup">
|
58
|
-
<assert test="string-length(normalize-space(string(.))) > 0">Heading elements must
|
59
|
-
contain text</assert>
|
60
|
-
</rule>
|
61
|
-
</pattern>
|
62
|
-
|
63
|
-
|
64
|
-
<!-- warnings mode <pattern id="page-list-flat">
|
65
|
-
<rule context="html:body//html:nav[@epub:type='page-list']">
|
66
|
-
<assert test="count(.//html:ol) = 1">The page-list navigation structure should be a
|
67
|
-
list, not a nested hierarchy</assert>
|
68
|
-
</rule>
|
69
|
-
</pattern>
|
70
|
-
-->
|
71
|
-
|
72
|
-
</schema>
|
data/schemas/epub-xhtml-30.sch
DELETED
@@ -1,377 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
|
3
|
-
|
4
|
-
<ns uri="http://www.w3.org/1999/xhtml" prefix="h"/>
|
5
|
-
<ns uri="http://www.idpf.org/2007/ops" prefix="epub"/>
|
6
|
-
<ns uri="http://www.w3.org/1998/Math/MathML" prefix="math"/>
|
7
|
-
<ns uri="http://www.w3.org/2001/10/synthesis" prefix="ssml"/>
|
8
|
-
<ns uri="http://www.w3.org/2001/xml-events" prefix="ev"/>
|
9
|
-
<ns uri="http://www.w3.org/2000/svg" prefix="svg" />
|
10
|
-
|
11
|
-
<let name="id-set" value="//*[@id]"/>
|
12
|
-
|
13
|
-
<pattern id="ancestor-area-map" is-a="required-ancestor">
|
14
|
-
<param name="descendant" value="h:area"/>
|
15
|
-
<param name="ancestor" value="h:map"/>
|
16
|
-
</pattern>
|
17
|
-
|
18
|
-
<pattern id="ancestor-imgismap-ahref" is-a="required-ancestor">
|
19
|
-
<param name="descendant" value="h:img[@ismap]"/>
|
20
|
-
<param name="ancestor" value="h:a[@href]"/>
|
21
|
-
</pattern>
|
22
|
-
|
23
|
-
<pattern id="descendant-a-interactive" is-a="no-interactive-content-descendants">
|
24
|
-
<param name="ancestor" value="h:a"/>
|
25
|
-
</pattern>
|
26
|
-
|
27
|
-
<pattern id="descendant-button-interactive" is-a="no-interactive-content-descendants">
|
28
|
-
<param name="ancestor" value="h:button"/>
|
29
|
-
</pattern>
|
30
|
-
|
31
|
-
<pattern id="descendant-audio-audio" is-a="disallowed-descendants">
|
32
|
-
<param name="ancestor" value="h:audio"/>
|
33
|
-
<param name="descendant" value="h:audio"/>
|
34
|
-
</pattern>
|
35
|
-
|
36
|
-
<pattern id="descendant-audio-video" is-a="disallowed-descendants">
|
37
|
-
<param name="ancestor" value="h:audio"/>
|
38
|
-
<param name="descendant" value="h:video"/>
|
39
|
-
</pattern>
|
40
|
-
|
41
|
-
<pattern id="descendant-video-video" is-a="disallowed-descendants">
|
42
|
-
<param name="ancestor" value="h:video"/>
|
43
|
-
<param name="descendant" value="h:video"/>
|
44
|
-
</pattern>
|
45
|
-
|
46
|
-
<pattern id="descendant-video-audio" is-a="disallowed-descendants">
|
47
|
-
<param name="ancestor" value="h:video"/>
|
48
|
-
<param name="descendant" value="h:audio"/>
|
49
|
-
</pattern>
|
50
|
-
|
51
|
-
<pattern id="descendant-address-address" is-a="disallowed-descendants">
|
52
|
-
<param name="ancestor" value="h:address"/>
|
53
|
-
<param name="descendant" value="h:address"/>
|
54
|
-
</pattern>
|
55
|
-
|
56
|
-
<pattern id="descendant-address-header" is-a="disallowed-descendants">
|
57
|
-
<param name="ancestor" value="h:address"/>
|
58
|
-
<param name="descendant" value="h:header"/>
|
59
|
-
</pattern>
|
60
|
-
|
61
|
-
<pattern id="descendant-address-footer" is-a="disallowed-descendants">
|
62
|
-
<param name="ancestor" value="h:address"/>
|
63
|
-
<param name="descendant" value="h:footer"/>
|
64
|
-
</pattern>
|
65
|
-
|
66
|
-
<pattern id="descendant-form-form" is-a="disallowed-descendants">
|
67
|
-
<param name="ancestor" value="h:form"/>
|
68
|
-
<param name="descendant" value="h:form"/>
|
69
|
-
</pattern>
|
70
|
-
|
71
|
-
<pattern id="descendant-progress-progress" is-a="disallowed-descendants">
|
72
|
-
<param name="ancestor" value="h:progress"/>
|
73
|
-
<param name="descendant" value="h:progress"/>
|
74
|
-
</pattern>
|
75
|
-
|
76
|
-
<pattern id="descendant-meter-meter" is-a="disallowed-descendants">
|
77
|
-
<param name="ancestor" value="h:meter"/>
|
78
|
-
<param name="descendant" value="h:meter"/>
|
79
|
-
</pattern>
|
80
|
-
|
81
|
-
<pattern id="descendant-dfn-dfn" is-a="disallowed-descendants">
|
82
|
-
<param name="ancestor" value="h:dfn"/>
|
83
|
-
<param name="descendant" value="h:dfn"/>
|
84
|
-
</pattern>
|
85
|
-
|
86
|
-
<pattern id="descendant-time-time" is-a="disallowed-descendants">
|
87
|
-
<param name="ancestor" value="h:time"/>
|
88
|
-
<param name="descendant" value="h:time"/>
|
89
|
-
</pattern>
|
90
|
-
|
91
|
-
<pattern id="descendant-caption-table" is-a="disallowed-descendants">
|
92
|
-
<param name="ancestor" value="h:caption"/>
|
93
|
-
<param name="descendant" value="h:table"/>
|
94
|
-
</pattern>
|
95
|
-
|
96
|
-
<pattern id="descendant-header-header" is-a="disallowed-descendants">
|
97
|
-
<param name="ancestor" value="h:header"/>
|
98
|
-
<param name="descendant" value="h:header"/>
|
99
|
-
</pattern>
|
100
|
-
|
101
|
-
<pattern id="descendant-header-footer" is-a="disallowed-descendants">
|
102
|
-
<param name="ancestor" value="h:header"/>
|
103
|
-
<param name="descendant" value="h:footer"/>
|
104
|
-
</pattern>
|
105
|
-
|
106
|
-
<pattern id="descendant-footer-footer" is-a="disallowed-descendants">
|
107
|
-
<param name="ancestor" value="h:footer"/>
|
108
|
-
<param name="descendant" value="h:footer"/>
|
109
|
-
</pattern>
|
110
|
-
|
111
|
-
<pattern id="descendant-footer-header" is-a="disallowed-descendants">
|
112
|
-
<param name="ancestor" value="h:footer"/>
|
113
|
-
<param name="descendant" value="h:header"/>
|
114
|
-
</pattern>
|
115
|
-
|
116
|
-
<pattern id="descendant-label-label" is-a="disallowed-descendants">
|
117
|
-
<param name="ancestor" value="h:label"/>
|
118
|
-
<param name="descendant" value="h:label"/>
|
119
|
-
</pattern>
|
120
|
-
|
121
|
-
<pattern id="descendant-annotation-xml-math" is-a="disallowed-descendants">
|
122
|
-
<param name="ancestor" value="math:annotation-xml[@encoding='application/xhtml+xml' and @name='alternate-representation']"/>
|
123
|
-
<param name="descendant" value="math:*"/>
|
124
|
-
</pattern>
|
125
|
-
|
126
|
-
<pattern id="descendant-svgtitle-svg" is-a="disallowed-descendants">
|
127
|
-
<param name="ancestor" value="svg:title"/>
|
128
|
-
<param name="descendant" value="svg:*"/>
|
129
|
-
</pattern>
|
130
|
-
|
131
|
-
<pattern id="bdo-dir" is-a="required-attr">
|
132
|
-
<param name="elem" value="h:bdo"/>
|
133
|
-
<param name="attr" value="dir"/>
|
134
|
-
</pattern>
|
135
|
-
|
136
|
-
<pattern id="idrefs-aria-describedby" is-a="idrefs-any">
|
137
|
-
<param name="element" value="*"/>
|
138
|
-
<param name="idrefs-attr-name" value="aria-describedby"/>
|
139
|
-
</pattern>
|
140
|
-
|
141
|
-
<pattern id="idrefs-output-for" is-a="idrefs-any">
|
142
|
-
<param name="element" value="h:output"/>
|
143
|
-
<param name="idrefs-attr-name" value="for"/>
|
144
|
-
</pattern>
|
145
|
-
|
146
|
-
<pattern id="idrefs-aria-flowto" is-a="idrefs-any">
|
147
|
-
<param name="element" value="*"/>
|
148
|
-
<param name="idrefs-attr-name" value="aria-flowto"/>
|
149
|
-
</pattern>
|
150
|
-
|
151
|
-
<pattern id="idrefs-aria-labelledby" is-a="idrefs-any">
|
152
|
-
<param name="element" value="*"/>
|
153
|
-
<param name="idrefs-attr-name" value="aria-labelledby"/>
|
154
|
-
</pattern>
|
155
|
-
|
156
|
-
<pattern id="idrefs-aria-owns" is-a="idrefs-any">
|
157
|
-
<param name="element" value="*"/>
|
158
|
-
<param name="idrefs-attr-name" value="aria-owns"/>
|
159
|
-
</pattern>
|
160
|
-
|
161
|
-
<pattern id="idrefs-aria-controls" is-a="idrefs-any">
|
162
|
-
<param name="element" value="*"/>
|
163
|
-
<param name="idrefs-attr-name" value="aria-controls"/>
|
164
|
-
</pattern>
|
165
|
-
|
166
|
-
<pattern id="idref-mathml-xref" is-a="idref-any">
|
167
|
-
<param name="element" value="math:*"/>
|
168
|
-
<param name="idref-attr-name" value="xref"/>
|
169
|
-
</pattern>
|
170
|
-
|
171
|
-
<pattern id="idref-mathml-indenttarget" is-a="idref-any">
|
172
|
-
<param name="element" value="math:*"/>
|
173
|
-
<param name="idref-attr-name" value="indenttarget"/>
|
174
|
-
</pattern>
|
175
|
-
|
176
|
-
<pattern id="idref-contextmenu" is-a="idref-named">
|
177
|
-
<param name="element" value="h:*"/>
|
178
|
-
<param name="idref-attr-name" value="contextmenu"/>
|
179
|
-
<param name="target-name" value="h:menu"/>
|
180
|
-
</pattern>
|
181
|
-
|
182
|
-
<pattern id="idref-input-list" is-a="idref-named">
|
183
|
-
<param name="element" value="h:input"/>
|
184
|
-
<param name="idref-attr-name" value="list"/>
|
185
|
-
<param name="target-name" value="h:datalist"/>
|
186
|
-
</pattern>
|
187
|
-
|
188
|
-
<pattern id="idref-forms-form" is-a="idref-named">
|
189
|
-
<param name="element" value="h:*"/>
|
190
|
-
<param name="idref-attr-name" value="form"/>
|
191
|
-
<param name="target-name" value="h:form"/>
|
192
|
-
</pattern>
|
193
|
-
|
194
|
-
<pattern id="idref-aria-activedescendant">
|
195
|
-
<rule context="*[@aria-activedescendant]">
|
196
|
-
<assert test="descendant::*[@id = current()/@aria-activedescendant]"
|
197
|
-
>The aria-activedescendant attribute must refer to a descendant element.</assert>
|
198
|
-
</rule>
|
199
|
-
</pattern>
|
200
|
-
|
201
|
-
<pattern id="idref-label-for">
|
202
|
-
<rule context="h:label[@for]">
|
203
|
-
<assert
|
204
|
-
test="some $elem in $id-set satisfies $elem/@id eq current()/@for and
|
205
|
-
(local-name($elem) eq 'button'
|
206
|
-
or (local-name($elem) eq 'input' and not($elem/@type='hidden'))
|
207
|
-
or local-name($elem) eq 'keygen'
|
208
|
-
or local-name($elem) eq 'meter'
|
209
|
-
or local-name($elem) eq 'output'
|
210
|
-
or local-name($elem) eq 'progress'
|
211
|
-
or local-name($elem) eq 'select'
|
212
|
-
or local-name($elem) eq 'textarea')"
|
213
|
-
>The for attribute does not refer to an allowed target element (expecting: button|keygen|meter|output|progress|select|textarea|input[not(@type='hidden')]).</assert>
|
214
|
-
</rule>
|
215
|
-
</pattern>
|
216
|
-
|
217
|
-
<pattern id="idrefs-headers">
|
218
|
-
<rule context="h:*[@headers]">
|
219
|
-
<let name="table" value="ancestor::h:table"/>
|
220
|
-
<assert test="every $idref in tokenize(@headers, '\s+') satisfies (some $elem in $table//h:th satisfies ($elem/@id eq $idref))"
|
221
|
-
>The headers attribute must refer to th elements in the same table.</assert>
|
222
|
-
</rule>
|
223
|
-
</pattern>
|
224
|
-
|
225
|
-
<pattern id="idref-trigger-observer" is-a="idref-any">
|
226
|
-
<param name="element" value="epub:trigger"/>
|
227
|
-
<param name="idref-attr-name" value="ev:observer"/>
|
228
|
-
</pattern>
|
229
|
-
|
230
|
-
<pattern id="idref-trigger-ref" is-a="idref-any">
|
231
|
-
<param name="element" value="epub:trigger"/>
|
232
|
-
<param name="idref-attr-name" value="ref"/>
|
233
|
-
</pattern>
|
234
|
-
|
235
|
-
<pattern id="map.name" >
|
236
|
-
<rule context='h:map[@name]'>
|
237
|
-
<let name="name-set" value="//h:map[@name]"/>
|
238
|
-
<assert test="count($name-set[@name = current()/@name]) = 1">Duplicate map name '<value-of
|
239
|
-
select="current()/@name"/>'</assert>
|
240
|
-
</rule>
|
241
|
-
</pattern>
|
242
|
-
|
243
|
-
<pattern id="map.id" >
|
244
|
-
<rule context='h:map[@id and @name]'>
|
245
|
-
<assert test='@id = @name'
|
246
|
-
>The id attribute on the map element must have the same value as the name attribute.</assert>
|
247
|
-
</rule>
|
248
|
-
</pattern>
|
249
|
-
|
250
|
-
<pattern id='lang-xmllang'>
|
251
|
-
<rule context='h:*[@lang and @xml:lang]'>
|
252
|
-
<assert test="lower-case(@xml:lang) = lower-case(@lang)"
|
253
|
-
>The lang and xml:lang attributes must have the same value.</assert>
|
254
|
-
</rule>
|
255
|
-
</pattern>
|
256
|
-
|
257
|
-
<pattern id="id-unique">
|
258
|
-
<rule context="*[@id]">
|
259
|
-
<assert test="count($id-set[@id = current()/@id]) = 1">Duplicate ID '<value-of
|
260
|
-
select="current()/@id"/>'</assert>
|
261
|
-
</rule>
|
262
|
-
</pattern>
|
263
|
-
|
264
|
-
<pattern id="select-multiple">
|
265
|
-
<rule context="h:select[not(@multiple)]">
|
266
|
-
<report test='count(descendant::h:option[@selected]) > 1'
|
267
|
-
>A select element whose multiple attribute is not specified must not have more than one descendant option element with its selected attribute set.</report>
|
268
|
-
</rule>
|
269
|
-
</pattern>
|
270
|
-
|
271
|
-
<pattern id="track">
|
272
|
-
<rule context="h:track">
|
273
|
-
<report test="@label and normalize-space(@label) = ''"
|
274
|
-
>The track element label attribute value must not be the empty string.</report>
|
275
|
-
<report test="@default and preceding-sibling::h:track[@default]"
|
276
|
-
>There must not be more than one track child of a media element element with the default attribute specified.</report>
|
277
|
-
</rule>
|
278
|
-
</pattern>
|
279
|
-
|
280
|
-
<pattern id="ssml-ph">
|
281
|
-
<rule context="*[@ssml:ph]">
|
282
|
-
<report test="ancestor::*[@ssml:ph]"
|
283
|
-
>The ssml:ph attribute must not be specified on a descendant of an element that also carries this attribute.</report>
|
284
|
-
</rule>
|
285
|
-
</pattern>
|
286
|
-
|
287
|
-
<pattern id="style-scoped">
|
288
|
-
<rule context="h:style[ancestor::h:body]">
|
289
|
-
<assert test="every $elem in preceding-sibling::* satisfies local-name($elem) eq 'style'"
|
290
|
-
>The scoped style element must occur before any other flow content other than other style elements and inter-element whitespace.</assert>
|
291
|
-
</rule>
|
292
|
-
</pattern>
|
293
|
-
|
294
|
-
<pattern id="link-sizes">
|
295
|
-
<rule context="h:link[@sizes]">
|
296
|
-
<assert test="@rel='icon'"
|
297
|
-
>The sizes attribute must not be specified on link elements that do not have a rel attribute that specifies the icon keyword.</assert>
|
298
|
-
</rule>
|
299
|
-
</pattern>
|
300
|
-
|
301
|
-
<pattern id="meta-charset">
|
302
|
-
<rule context="h:meta[@charset]">
|
303
|
-
<assert test="count(preceding-sibling::h:meta[@charset]) = 0"
|
304
|
-
>There must not be more than one meta element with a charset attribute per document.</assert>
|
305
|
-
</rule>
|
306
|
-
</pattern>
|
307
|
-
|
308
|
-
<pattern id="article-pubdate">
|
309
|
-
<rule context="h:article[h:time]">
|
310
|
-
<assert test="count(./h:time[@pubdate]) < 2"
|
311
|
-
>For each article element, there must be no more than one time element child with a pubdate attribute</assert>
|
312
|
-
</rule>
|
313
|
-
</pattern>
|
314
|
-
|
315
|
-
<pattern id="document-pubdate">
|
316
|
-
<rule context="h:time[not (ancestor::h:article)]">
|
317
|
-
<assert test="count(//h:time[@pubdate and not (ancestor::h:article)]) < 2"
|
318
|
-
>For each Document, there must be no more than one time element with a pubdate
|
319
|
-
attribute that does not have an ancestor article element.</assert>
|
320
|
-
</rule>
|
321
|
-
</pattern>
|
322
|
-
|
323
|
-
<pattern abstract="true" id="idref-any">
|
324
|
-
<rule context="$element[@$idref-attr-name]">
|
325
|
-
<assert test="some $elem in $id-set satisfies $elem/@id eq current()/@$idref-attr-name"
|
326
|
-
>The <name path="@$idref-attr-name"/> attribute must refer to an element in the same document (the ID '<value-of
|
327
|
-
select="current()/@$idref-attr-name"/>' does not exist).</assert>
|
328
|
-
</rule>
|
329
|
-
</pattern>
|
330
|
-
|
331
|
-
<pattern abstract="true" id="idrefs-any">
|
332
|
-
<rule context="$element[@$idrefs-attr-name]">
|
333
|
-
<assert test="every $idref in tokenize(@$idrefs-attr-name,'\s+') satisfies (some $elem in $id-set satisfies ($elem/@id eq $idref))"
|
334
|
-
>The <name path="@$idrefs-attr-name"/> attribute must refer to elements in the same document (target ID missing)</assert>
|
335
|
-
</rule>
|
336
|
-
</pattern>
|
337
|
-
|
338
|
-
<pattern abstract="true" id="idref-named">
|
339
|
-
<rule context="$element[@$idref-attr-name]">
|
340
|
-
<assert test="//$target-name[@id = current()/@$idref-attr-name]">The <name
|
341
|
-
path="@$idref-attr-name"/> attribute does not refer to an allowed target element (expecting: <value-of
|
342
|
-
select="replace('$target-name','h:','')"/>).</assert>
|
343
|
-
</rule>
|
344
|
-
</pattern>
|
345
|
-
|
346
|
-
<pattern abstract="true" id="required-attr">
|
347
|
-
<rule context="$elem">
|
348
|
-
<assert test="@$attr"
|
349
|
-
>The <name/> element must have a <value-of select="'$attr'"/> attribute.</assert>
|
350
|
-
</rule>
|
351
|
-
</pattern>
|
352
|
-
|
353
|
-
<pattern abstract="true" id="disallowed-descendants">
|
354
|
-
<rule context="$descendant">
|
355
|
-
<report test="ancestor::$ancestor"
|
356
|
-
>The <name/> element must not appear inside <value-of select="local-name(ancestor::$ancestor)"/> elements.</report>
|
357
|
-
</rule>
|
358
|
-
</pattern>
|
359
|
-
|
360
|
-
<pattern abstract="true" id="required-ancestor">
|
361
|
-
<rule context='$descendant'>
|
362
|
-
<assert test='ancestor::$ancestor'
|
363
|
-
>The <value-of select="replace('$descendant','h:','')"/> element must have an ancestor <value-of select="replace('$ancestor','h:','')"/> element.</assert>
|
364
|
-
</rule>
|
365
|
-
</pattern>
|
366
|
-
|
367
|
-
<pattern abstract="true" id="no-interactive-content-descendants">
|
368
|
-
<rule context="h:a|h:audio[@controls]|h:button|h:details|h:embed|h:iframe|h:img[@usemap]|h:input[not(@type='hidden')]
|
369
|
-
|h:keygen|h:label|h:menu[@type='toolbar']|h:object[@usemap]|h:select|h:textarea|h:video[@controls]">
|
370
|
-
<report test="ancestor::$ancestor"
|
371
|
-
>The <name/> element must not appear inside <value-of select="local-name(ancestor::$ancestor)"/> elements.</report>
|
372
|
-
</rule>
|
373
|
-
</pattern>
|
374
|
-
|
375
|
-
<include href="./mod/epub-svg11-re.sch"/>
|
376
|
-
|
377
|
-
</schema>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
default namespace = "urn:oasis:names:tc:opendocument:xmlns:container"
|
3
|
-
include "./mod/datatypes.rnc"
|
4
|
-
|
5
|
-
start = ocf.container
|
6
|
-
|
7
|
-
ocf.container = element container {
|
8
|
-
attribute version { '1.0' } &
|
9
|
-
element rootfiles {
|
10
|
-
element rootfile {
|
11
|
-
attribute full-path { datatype.URI } &
|
12
|
-
attribute media-type { 'application/oebps-package+xml' }
|
13
|
-
}+
|
14
|
-
}
|
15
|
-
}
|
16
|
-
|