reorganizing the repository
[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  <xsl:param name="addcover" />
15   
16  <!-- ======================== Templates ========================= -->
17
18  <!-- ================= hierarchical sections ==================== -->
19
20  <xsl:template match="*" />
21
22  <xsl:template match="/gamebook">
23   <spine>
24    <xsl:attribute name="toc">
25     <xsl:value-of select="$toc-id"/>
26    </xsl:attribute>
27
28    <xsl:apply-templates select="section[@id='title']"/>
29   </spine>
30
31  </xsl:template>
32
33  <!-- ::::::::::::::::::: top-level section :::::::::::::::::::::: -->
34
35  <xsl:template match="/gamebook/section[@id='title']">
36   <itemref idref="title" media-type="application/xhtml+xml"/>
37   <itemref idref="toc"   media-type="application/xhtml+xml"/>
38   <itemref idref="coverpage" media-type="application/xhtml+xml"/>
39
40   <xsl:apply-templates select="data/section"/>
41  </xsl:template>
42
43  <!-- ::::::::::: second-level sections :::::::::::::: -->
44
45  <xsl:template match="/gamebook/section/data/section">
46   <itemref>
47    <xsl:attribute name="idref">
48     <xsl:value-of select="@id"/>
49    </xsl:attribute>
50    <xsl:attribute name="media-type">
51     <xsl:text>application/xhtml+xml</xsl:text>
52    </xsl:attribute>
53   </itemref>
54
55   <xsl:apply-templates select="data/section"/>
56  </xsl:template>
57
58  <xsl:template match="/gamebook/section/data/section[@class='numbered']">
59  <!-- Put the numbered section list after the numbered sections so
60       the reader doesn't get sent there between the Kai Wisdom page
61       and Section 1. -->
62   <xsl:apply-templates select="data/section"/>
63
64   <itemref>
65    <xsl:attribute name="idref">
66     <xsl:value-of select="@id"/>
67    </xsl:attribute>
68    <xsl:attribute name="media-type">
69     <xsl:text>application/xhtml+xml</xsl:text>
70    </xsl:attribute>
71   </itemref>
72  </xsl:template>
73
74  <!-- :::::::::::: third-level sections ::::::::::::: -->
75
76  <xsl:template match="/gamebook/section/data/section/data/section">
77   <xsl:apply-templates select="data/section"/>
78  </xsl:template>
79
80  <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter-separate' or @class='mainmatter-separate' or @class='numbered' or @class='glossary-separate']">
81   <itemref>
82    <xsl:attribute name="idref">
83     <xsl:value-of select="@id"/>
84    </xsl:attribute>
85    <xsl:attribute name="media-type">
86     <xsl:text>application/xhtml+xml</xsl:text>
87    </xsl:attribute>
88   </itemref>
89
90   <xsl:apply-templates select="data/section"/>
91  </xsl:template>
92 </xsl:transform>