Make it possible to generate new book design
[project-aon.git] / common / xsl / epub-opf-spine.xsl
1 <?xml version="1.0"?>
2
3 <xsl:transform version="1.0"
4   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
6  <xsl:output method="xml"
7              encoding="UTF-8"
8              omit-xml-declaration="yes"/>
9  <xsl:strip-space elements="*" />
10
11  <!-- ====================== parameters ========================== -->
12
13  <xsl:param name="toc-id"><xsl:text>toc.ncx</xsl:text></xsl:param>
14   
15  <!-- ======================== Templates ========================= -->
16
17  <!-- ================= hierarchical sections ==================== -->
18
19  <xsl:template match="*" />
20
21  <xsl:template match="/gamebook">
22   <spine>
23    <xsl:attribute name="toc">
24     <xsl:value-of select="$toc-id"/>
25    </xsl:attribute>
26
27    <xsl:apply-templates select="section[@id='title']"/>
28   </spine>
29
30  </xsl:template>
31
32  <!-- ::::::::::::::::::: top-level section :::::::::::::::::::::: -->
33
34  <xsl:template match="/gamebook/section[@id='title']">
35   <itemref idref="title" media-type="application/xhtml+xml"/>
36   <itemref idref="toc"   media-type="application/xhtml+xml"/>
37
38   <xsl:apply-templates select="data/section"/>
39  </xsl:template>
40
41  <!-- ::::::::::: second-level sections :::::::::::::: -->
42
43  <xsl:template match="/gamebook/section/data/section">
44   <itemref>
45    <xsl:attribute name="idref">
46     <xsl:value-of select="@id"/>
47    </xsl:attribute>
48    <xsl:attribute name="media-type">
49     <xsl:text>application/xhtml+xml</xsl:text>
50    </xsl:attribute>
51   </itemref>
52
53   <xsl:apply-templates select="data/section"/>
54  </xsl:template>
55
56  <xsl:template match="/gamebook/section/data/section[@class='numbered']">
57  <!-- Put the numbered section list after the numbered sections so
58       the reader doesn't get sent there between the Kai Wisdom page
59       and Section 1. -->
60   <xsl:apply-templates select="data/section"/>
61
62   <itemref>
63    <xsl:attribute name="idref">
64     <xsl:value-of select="@id"/>
65    </xsl:attribute>
66    <xsl:attribute name="media-type">
67     <xsl:text>application/xhtml+xml</xsl:text>
68    </xsl:attribute>
69   </itemref>
70  </xsl:template>
71
72  <!-- :::::::::::: third-level sections ::::::::::::: -->
73
74  <xsl:template match="/gamebook/section/data/section/data/section">
75   <xsl:apply-templates select="data/section"/>
76  </xsl:template>
77
78  <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter-separate' or @class='mainmatter-separate' or @class='numbered' or @class='glossary-separate']">
79   <itemref>
80    <xsl:attribute name="idref">
81     <xsl:value-of select="@id"/>
82    </xsl:attribute>
83    <xsl:attribute name="media-type">
84     <xsl:text>application/xhtml+xml</xsl:text>
85    </xsl:attribute>
86   </itemref>
87
88   <xsl:apply-templates select="data/section"/>
89  </xsl:template>
90 </xsl:transform>