Skip to content

Commit 63b0718

Browse files
author
Sanders Kleinfeld
committed
Merge pull request #29 from oreillymedia/xmlschema
Revised <nav> handling that is in line with EPUB 3 spec
2 parents 653a090 + ccfc466 commit 63b0718

File tree

2 files changed

+67
-25
lines changed

2 files changed

+67
-25
lines changed

htmlbook.xsd

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,16 @@
307307
<!-- Not imposing any HTMLBook specific constraints on menu content; deferring to HTML5 spec -->
308308
<xs:element name="menu" type="any_elems_attrs"/>
309309

310-
<!--ToDo: Open question: Allow h1-h6 at beginning (or even middle) of navs? -->
311-
<xs:element name="nav" type="block_xor_inline_children"/>
310+
<!--Follows the EPUB 3 spec for nav elements; see http://www.idpf.org/epub/30/spec/epub30-contentdocs.html#sec-xhtml-nav -->
311+
<xs:element name="nav">
312+
<xs:complexType>
313+
<xs:sequence>
314+
<xs:group ref="headings" minOccurs="0"/>
315+
<xs:element name="ol" type="nav_doc_ol"/>
316+
</xs:sequence>
317+
<xs:attributeGroup ref="globals"/>
318+
</xs:complexType>
319+
</xs:element>
312320

313321
<xs:element name="object">
314322
<xs:complexType mixed="true">
@@ -328,26 +336,7 @@
328336
<xs:sequence>
329337
<xs:element ref="li" minOccurs="0" maxOccurs="unbounded"/>
330338
</xs:sequence>
331-
<xs:attribute name="reversed">
332-
<xs:simpleType>
333-
<xs:restriction base="xs:string">
334-
<!-- Must be a case-insensitive match for "reversed" or empty string -->
335-
<xs:pattern value="([Rr][Ee][Vv][Ee][Rr][Ss][Ee][Dd])?"/>
336-
</xs:restriction>
337-
</xs:simpleType>
338-
</xs:attribute>
339-
<xs:attribute name="start" type="xs:integer"/>
340-
<xs:attribute name="type">
341-
<xs:simpleType>
342-
<xs:restriction base="xs:token">
343-
<xs:enumeration value="decimal"/>
344-
<xs:enumeration value="lower-alpha"/>
345-
<xs:enumeration value="upper-alpha"/>
346-
<xs:enumeration value="lower-roman"/>
347-
<xs:enumeration value="upper-roman"/>
348-
</xs:restriction>
349-
</xs:simpleType>
350-
</xs:attribute>
339+
<xs:attributeGroup ref="ol_attrs"/>
351340
<xs:attributeGroup ref="globals"/>
352341
</xs:complexType>
353342
</xs:element>
@@ -1249,6 +1238,26 @@
12491238
<xs:attribute name="class" use="required" type="subheadingtype"/>
12501239
<xs:attributeGroup ref="globals_minus_class"/>
12511240
</xs:complexType>
1241+
1242+
<!-- Custom types for Nav Document (following EPUB 3 spec; see http://www.idpf.org/epub/30/spec/epub30-contentdocs.html#sec-xhtml-nav) -->
1243+
<xs:complexType name="nav_doc_ol">
1244+
<xs:sequence>
1245+
<xs:element name="li" type="nav_doc_li" minOccurs="0" maxOccurs="unbounded"/>
1246+
</xs:sequence>
1247+
<xs:attributeGroup ref="ol_attrs"/>
1248+
<xs:attributeGroup ref="globals"/>
1249+
</xs:complexType>
1250+
1251+
<xs:complexType name="nav_doc_li" mixed="true">
1252+
<xs:choice>
1253+
<xs:element ref="span"/>
1254+
<xs:sequence>
1255+
<xs:element ref="a"/>
1256+
<xs:element name="ol" minOccurs="0" type="nav_doc_ol"/>
1257+
</xs:sequence>
1258+
</xs:choice>
1259+
<xs:attributeGroup ref="globals"/>
1260+
</xs:complexType>
12521261

12531262
<!-- General handling for elements that can accept only inline children -->
12541263
<xs:complexType name="inline_children_only" mixed="true">
@@ -1448,6 +1457,30 @@
14481457
<xs:attribute name="class" type="xs:NMTOKENS"/>
14491458
</xs:attributeGroup>
14501459

1460+
<!-- Attributes used by <ol> elements -->
1461+
<xs:attributeGroup name="ol_attrs">
1462+
<xs:attribute name="reversed">
1463+
<xs:simpleType>
1464+
<xs:restriction base="xs:string">
1465+
<!-- Must be a case-insensitive match for "reversed" or empty string -->
1466+
<xs:pattern value="([Rr][Ee][Vv][Ee][Rr][Ss][Ee][Dd])?"/>
1467+
</xs:restriction>
1468+
</xs:simpleType>
1469+
</xs:attribute>
1470+
<xs:attribute name="start" type="xs:integer"/>
1471+
<xs:attribute name="type">
1472+
<xs:simpleType>
1473+
<xs:restriction base="xs:token">
1474+
<xs:enumeration value="decimal"/>
1475+
<xs:enumeration value="lower-alpha"/>
1476+
<xs:enumeration value="upper-alpha"/>
1477+
<xs:enumeration value="lower-roman"/>
1478+
<xs:enumeration value="upper-roman"/>
1479+
</xs:restriction>
1480+
</xs:simpleType>
1481+
</xs:attribute>
1482+
</xs:attributeGroup>
1483+
14511484
<!-- Media attributes used by both <audio> and <video> elements -->
14521485
<xs:attributeGroup name="generalmediaattributes">
14531486
<xs:attribute name="src" type="xs:anyURI"/>

samples/test_schema.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,23 @@ <h5>Test</h5>
171171

172172
<!-- And a nav -->
173173
<nav id="navigation">
174-
<p id="first_para" class="first_para"><em>Hello</em></p>
175-
<p>Hello again</p>
174+
<h1>Table of Contents</h1>
175+
<ol id="first_list">
176+
<li><a href="blah"></a></li>
177+
<li><span>This is allowed too</span></li>
178+
<li id="subtoc" ><a href="blah2"/>
179+
<ol reversed="reverseD">
180+
<li><a href="ch02.html">Another link</a></li>
181+
</ol>
182+
</li>
183+
</ol>
176184
</nav>
177185

178186
<!-- Don't forget an ordered list -->
179-
<ol id="orderedlist" start="4" type="lower-roman" reversed="ReVersed" spellcheck="true">
187+
<ol id="orderedlist" start="3" type="decimal" reversed="ReVersed" spellcheck="true">
180188
<li><p>This list item</p><p>Has multiple paragraphs</p></li>
181189
<li>This one is has just <em>one paragraph</em>, so no need to use block elements</li>
190+
<li>Just plain text</li>
182191
</ol>
183192

184193
<!-- And an unordered list -->

0 commit comments

Comments
 (0)