-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtable-of-contents.xsl
130 lines (120 loc) · 7.52 KB
/
table-of-contents.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
xmlns:ead3="http://ead3.archivists.org/schema/" exclude-result-prefixes="xs ead3 fox"
version="2.0">
<!-- this file is imported by "ead3-to-pdf-ua.xsl" -->
<!-- to do: should this be a list, instead?
the table markup is quite bloated. -->
<xsl:template match="ead3:archdesc" mode="toc">
<fo:page-sequence master-reference="table-of-contents">
<!-- Page header -->
<fo:static-content flow-name="xsl-region-before">
<xsl:call-template name="header-right"/>
</fo:static-content>
<!-- Page footer-->
<fo:static-content flow-name="xsl-region-after">
<fo:block/>
</fo:static-content>
<!-- Content of page -->
<fo:flow flow-name="xsl-region-body" xsl:use-attribute-sets="header-serif">
<xsl:call-template name="section-start"/>
<fo:block xsl:use-attribute-sets="h3" id="toc">Table of Contents</fo:block>
<fo:block xsl:use-attribute-sets="toc-block">
<xsl:apply-templates select="ead3:did" mode="toc"/>
<xsl:if test="$include-paging-info">
<fo:block text-align-last="justify">
<fo:basic-link internal-destination="paging-info">
<xsl:value-of select="$paging-info-title"/>
<xsl:text> </xsl:text><fo:leader leader-pattern="dots"/><xsl:text> </xsl:text>
<fo:page-number-citation ref-id="paging-info"/>
</fo:basic-link>
</fo:block>
</xsl:if>
<xsl:if test="ead3:acqinfo, ead3:custodhist, ead3:accessrestrict, ead3:userestrict, ead3:prefercite
, ead3:processinfo, ead3:altformavail, ead3:relatedmaterial, ead3:separatedmaterial, ead3:accruals, ead3:appraisals
, ead3:originalsloc, ead3:otherfindaid, ead3:phystech, ead3:fileplan">
<fo:block text-align-last="justify">
<fo:basic-link internal-destination="admin-info">
<xsl:value-of select="$admin-info-title"/>
<xsl:text> </xsl:text><fo:leader leader-pattern="dots"/><xsl:text> </xsl:text>
<fo:page-number-citation ref-id="admin-info"/>
</fo:basic-link>
</fo:block>
<xsl:apply-templates select="ead3:acqinfo, ead3:custodhist, ead3:accessrestrict, ead3:userestrict, ead3:prefercite
, ead3:processinfo, ead3:altformavail, ead3:relatedmaterial, ead3:separatedmaterial, ead3:accruals, ead3:appraisals
, ead3:originalsloc, ead3:otherfindaid, ead3:phystech, ead3:fileplan" mode="toc">
<xsl:with-param name="margin-left" select="'10pt'"/>
</xsl:apply-templates>
</xsl:if>
<xsl:apply-templates select="ead3:bioghist, ead3:scopecontent
, ead3:odd[not(matches(lower-case(normalize-space(ead3:head)), $odd-headings-to-add-at-end))]
, ead3:bibliography, ead3:arrangement" mode="toc"/>
<!-- new, to make sure that there's no DSC in ToC in those cases where the container list is still unpublished -->
<xsl:apply-templates select="ead3:dsc[*[local-name()=('c', 'c01')]]" mode="toc"/>
<xsl:apply-templates select="ead3:odd[matches(lower-case(normalize-space(ead3:head)), $odd-headings-to-add-at-end)]
, ead3:index
, ead3:controlaccess" mode="toc"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</xsl:template>
<xsl:template match="ead3:did" mode="toc">
<fo:block text-align-last="justify">
<fo:basic-link internal-destination="contents">
<xsl:value-of select="$archdesc-did-title"/>
<xsl:text> </xsl:text><fo:leader leader-pattern="dots"/><xsl:text> </xsl:text>
<fo:page-number-citation ref-id="contents"/>
</fo:basic-link>
</fo:block>
</xsl:template>
<xsl:template match="ead3:*" mode="toc">
<xsl:param name="margin-left"/>
<xsl:variable name="id-for-link" select="if (@id) then @id else generate-id(.)"/>
<fo:block text-align-last="justify">
<xsl:if test="$margin-left">
<xsl:attribute name="margin-left" select="$margin-left"/>
</xsl:if>
<fo:basic-link internal-destination="{$id-for-link}">
<xsl:apply-templates select="ead3:head" mode="#current"/>
<xsl:text> </xsl:text><fo:leader leader-pattern="dots"/><xsl:text> </xsl:text>
<fo:page-number-citation ref-id="{$id-for-link}"/>
</fo:basic-link>
</fo:block>
</xsl:template>
<xsl:template match="ead3:dsc" mode="toc">
<fo:block text-align-last="justify">
<fo:basic-link internal-destination="dsc-contents">
<xsl:value-of select="$dsc-title"/>
<xsl:text> </xsl:text><fo:leader leader-pattern="dots"/><xsl:text> </xsl:text>
<fo:page-number-citation ref-id="dsc-contents"/>
</fo:basic-link>
</fo:block>
<xsl:apply-templates select="ead3:*[local-name()=('c01', 'c')][@level=$levels-to-include-in-toc or @otherlevel=$otherlevels-to-include-in-toc]"
mode="#current"/>
</xsl:template>
<xsl:template match="ead3:*[matches(local-name(), '^c0|^c1') or local-name()='c'][@level=$levels-to-include-in-toc or @otherlevel=$otherlevels-to-include-in-toc]" mode="toc">
<xsl:variable name="id-for-link" select="if (@id) then @id else generate-id(.)"/>
<!-- should change this into a function, since I re-use it, but haven't done that yet!-->
<xsl:variable name="depth" select="count(ancestor::*) - 2"/>
<xsl:variable name="margin-left" select="concat(xs:string($depth * 10), 'pt')"/>
<fo:block text-align-last="justify" margin-left="{$margin-left}">
<fo:basic-link internal-destination="{$id-for-link}">
<xsl:call-template name="combine-identifier-title-and-dates"/>
<xsl:text> </xsl:text><fo:leader leader-pattern="dots"/><xsl:text> </xsl:text>
<fo:page-number-citation ref-id="{$id-for-link}"/>
</fo:basic-link>
</fo:block>
<xsl:apply-templates select="ead3:*[matches(local-name(), '^c0|^c1') or local-name()='c'][@level=$levels-to-include-in-toc or @otherlevel=$otherlevels-to-include-in-toc]" mode="#current"/>
</xsl:template>
<xsl:template match="ead3:controlaccess" mode="toc">
<fo:block text-align-last="justify">
<fo:basic-link internal-destination="control-access">
<xsl:value-of select="$control-access-title"/>
<xsl:text> </xsl:text><fo:leader leader-pattern="dots"/><xsl:text> </xsl:text>
<fo:page-number-citation ref-id="control-access"/>
</fo:basic-link>
</fo:block>
</xsl:template>
</xsl:stylesheet>