comparison software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/toc.xsl @ 25:e9fe3186670c default tip

letzter Stand eingecheckt
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 21 May 2013 10:19:32 +0200
parents
children
comparison
equal deleted inserted replaced
23:e845310098ba 25:e9fe3186670c
1 <?xml version="1.0"?>
2
3 <xsl:stylesheet
4 version="2.0"
5 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6 xmlns:xlink="http://www.w3.org/1999/xlink"
7 xmlns:xhtml="http://www.w3.org/1999/xhtml"
8 exclude-result-prefixes="xsl xlink xhtml"
9 >
10
11 <xsl:output method="xml" encoding="utf-8" indent="yes"/>
12
13 <xsl:template match="/">
14 <xsl:variable name="toc" select="//*:div[@type = 'section' or @type = 'chapter' or @type = 'part']"/>
15 <xsl:variable name="figures" select="//*:figure"/>
16 <xsl:variable name="notes" select="//*:note|//*:handwritten"/>
17 <xsl:variable name="pages" select="//*:pb"/>
18 <xsl:variable name="places" select="//*:place"/>
19 <list>
20 <xsl:if test="not(empty($toc))">
21 <list type ="toc">
22 <xsl:attribute name="count"><xsl:value-of select="count($toc)"/></xsl:attribute>
23 <head>Table of contents</head>
24 <xsl:apply-templates select="$toc"/>
25 </list>
26 </xsl:if>
27 <xsl:if test="not(empty($figures))">
28 <list type="figures">
29 <xsl:attribute name="count"><xsl:value-of select="count($figures)"/></xsl:attribute>
30 <head>Figures</head>
31 <xsl:apply-templates select="$figures"/>
32 </list>
33 </xsl:if>
34 <xsl:if test="not(empty($notes))">
35 <list type="notes">
36 <xsl:attribute name="count"><xsl:value-of select="count($notes)"/></xsl:attribute>
37 <head>Notes</head>
38 <xsl:apply-templates select="$notes"/>
39 </list>
40 </xsl:if>
41 <xsl:if test="not(empty($pages))">
42 <list type="pages">
43 <xsl:attribute name="count"><xsl:value-of select="count($pages)"/></xsl:attribute>
44 <head>Pages</head>
45 <xsl:apply-templates select="$pages"/>
46 </list>
47 </xsl:if>
48 <xsl:if test="not(empty($places))">
49 <list type="places">
50 <xsl:attribute name="count"><xsl:value-of select="count($places)"/></xsl:attribute>
51 <head>Places</head>
52 <xsl:apply-templates select="$places"/>
53 </list>
54 </xsl:if>
55 </list>
56 </xsl:template>
57
58 <xsl:template match="*:figure">
59 <xsl:variable name="page" select="count(./preceding::*:pb)"/>
60 <xsl:variable name="number" select="@number"/>
61 <item>
62 <xsl:if test="not(empty($number))"><xsl:attribute name="n"><xsl:value-of select="$number"/></xsl:attribute></xsl:if>
63 <xsl:apply-templates select="*:caption"/>
64 <xsl:apply-templates select="*:description"/>
65 <xsl:apply-templates select="*:variables"/>
66 <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
67 </item>
68 </xsl:template>
69
70 <xsl:template match="*:caption"><xsl:value-of select="' '"/>
71 <xsl:apply-templates/>
72 </xsl:template>
73
74 <xsl:template match="*:description">
75 <xsl:apply-templates/><xsl:value-of select="' '"/>
76 </xsl:template>
77
78 <xsl:template match="*:variables">
79 <xsl:apply-templates/><xsl:value-of select="' '"/>
80 </xsl:template>
81
82 <xsl:template match="*:note|*:handwritten">
83 <xsl:variable name="page" select="count(./preceding::*:pb)"/>
84 <xsl:variable name="number" select="@number"/>
85 <xsl:variable name="position" select="@position"/>
86 <xsl:variable name="type">
87 <xsl:choose>
88 <xsl:when test="name() = 'note'"><xsl:value-of select="'printed'"/></xsl:when>
89 <xsl:when test="name() = 'handwritten'"><xsl:value-of select="'handwritten'"/></xsl:when>
90 <xsl:otherwise></xsl:otherwise>
91 </xsl:choose>
92 </xsl:variable>
93 <item>
94 <xsl:if test="not(empty($type))"><xsl:attribute name="type"><xsl:value-of select="$type"/></xsl:attribute></xsl:if>
95 <xsl:if test="not(empty($position))"><xsl:attribute name="position"><xsl:value-of select="$position"/></xsl:attribute></xsl:if>
96 <xsl:if test="not(empty($number))"><xsl:attribute name="n"><xsl:value-of select="$number"/></xsl:attribute></xsl:if>
97 <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
98 </item>
99 </xsl:template>
100
101 <xsl:template match="*:place">
102 <xsl:variable name="page" select="count(./preceding::*:pb)"/>
103 <xsl:variable name="id" select="@id"/>
104 <item>
105 <xsl:if test="not(empty($id))"><xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute></xsl:if>
106 <content><xsl:apply-templates/></content>
107 <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
108 </item>
109 </xsl:template>
110
111 <xsl:template match="*:div">
112 <xsl:variable name="level"><xsl:number level="multiple" count="*:div[@type = 'section' or @type = 'chapter' or @type = 'part']" format="1."/></xsl:variable>
113 <xsl:variable name="depth" select="string-length(replace($level, '[^\\.]', ''))"/>
114 <xsl:variable name="pb" select="./preceding::*:pb[1]"/>
115 <xsl:variable name="o" select="$pb/@o"/>
116 <xsl:variable name="oNorm" select="$pb/@o-norm"/>
117 <xsl:variable name="page" select="count(./preceding::*:pb)"/>
118 <item>
119 <xsl:if test="not(empty($level))"><xsl:attribute name="n"><xsl:value-of select="$level"/></xsl:attribute></xsl:if>
120 <xsl:if test="not(empty($level))"><xsl:attribute name="lv"><xsl:value-of select="$depth"/></xsl:attribute></xsl:if>
121 <xsl:apply-templates select="*:head"/>
122 <xsl:if test="not(empty($page))">
123 <ref>
124 <xsl:if test="not(empty($o))"><xsl:attribute name="o"><xsl:value-of select="$o"/></xsl:attribute></xsl:if>
125 <xsl:if test="not(empty($oNorm))"><xsl:attribute name="o-norm"><xsl:value-of select="$oNorm"/></xsl:attribute></xsl:if>
126 <xsl:value-of select="$page"/>
127 </ref>
128 </xsl:if>
129 </item>
130 </xsl:template>
131
132 <xsl:template match="*:head">
133 <xsl:apply-templates/><xsl:value-of select="' '"/>
134 </xsl:template>
135
136 <xsl:template match="*:pb">
137 <xsl:variable name="page" select="count(./preceding::*:pb) + 1"/>
138 <item>
139 <xsl:attribute name="n"><xsl:value-of select="$page"/></xsl:attribute>
140 <xsl:if test="not(empty(@o))"><xsl:attribute name="o"><xsl:value-of select="@o"/></xsl:attribute></xsl:if>
141 <xsl:if test="not(empty(@o-norm))"><xsl:attribute name="o-norm"><xsl:value-of select="@o-norm"/></xsl:attribute></xsl:if>
142 <xsl:if test="not(empty(@file))"><xsl:attribute name="file"><xsl:value-of select="@file"/></xsl:attribute></xsl:if>
143 <xsl:if test="not(empty(@facs))"><xsl:attribute name="file"><xsl:value-of select="@facs"/></xsl:attribute></xsl:if>
144 </item>
145 </xsl:template>
146
147 </xsl:stylesheet>