This repository has been archived by the owner on Nov 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_toc.ncx.xsl
executable file
·88 lines (79 loc) · 2.63 KB
/
make_toc.ncx.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Fabrication toc.ncx à partir de fichiers Pages -->
<!-- Pour intégration dans archive ePub -->
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sfa="http://developer.apple.com/namespaces/sfa"
xmlns:sf="http://developer.apple.com/namespaces/sf"
xmlns:sl="http://developer.apple.com/namespaces/sl"
xmlns="http://www.daisy.org/z3986/2005/ncx/"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
exclude-result-prefixes="xsi sfa sf sl">
<xsl:template name="make_toc.ncx" match="/">
<exsl:document
href="{$maindir}/toc.ncx"
doctype-public="-//NISO//DTD ncx 2005-1//EN"
doctype-system="http://www.daisy.org/z3986/2005/ncx-2005-1.dtd"
version="1.0"
indent="yes">
<ncx version="2005-1">
<xsl:call-template name="head"/>
<xsl:call-template name="docTitle"/>
<xsl:call-template name="navmap"/>
</ncx>
</exsl:document>
</xsl:template>
<xsl:template name="head">
<head>
<meta name="dtb:uid" content="ID"/>
<meta name="dtb:depth" content="2"/>
<meta name="dtb:totalPageCount" content="0"/>
<meta name="dtb:maxPageNumber" content="0"/>
</head>
</xsl:template>
<xsl:template name="docTitle">
<docTitle>
<xsl:choose>
<xsl:when test="$title='undefined'">
<text><xsl:value-of select="//sf:metadata/sf:title/sf:string/@sfa:string"/></text>
</xsl:when>
<xsl:otherwise>
<text><xsl:value-of select="$title"/></text>
</xsl:otherwise>
</xsl:choose>
</docTitle>
</xsl:template>
<xsl:template name="navmap">
<navMap>
<xsl:choose>
<xsl:when test="not(//sf:p[child::sf:toc-bookmark])">
<navPoint id="navPoint-1" playOrder="1">
<navLabel>
<text><xsl:value-of select="$title"/></text>
</navLabel>
<content src="{$basename}.html"/>
</navPoint>
</xsl:when>
<xsl:otherwise>
<navPoint id="navPoint-1" playOrder="1">
<navLabel>
<text>Introduction</text>
</navLabel>
<content src="intro.html"/>
</navPoint>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="//sf:p[sf:toc-bookmark]">
<xsl:variable name="count" select="position()+1"/>
<navPoint id="navPoint-{$count}" playOrder="{$count}">
<navLabel>
<text><xsl:call-template name="tocTitle"/></text>
</navLabel>
<content src="{sf:toc-bookmark/@sf:name}.html"/>
</navPoint>
</xsl:for-each>
</navMap>
</xsl:template>
</xsl:transform>