]> git.stg.codes - stg.git/blob - doc/xslt/fo/fop1.xsl
Some comments removed from Firebird db creation script
[stg.git] / doc / xslt / fo / fop1.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
4                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
5                 version='1.0'>
6
7 <!-- ********************************************************************
8      $Id: fop1.xsl 8913 2010-10-01 04:44:57Z bobstayton $
9      ********************************************************************
10
11      This file is part of the XSL DocBook Stylesheet distribution.
12      See ../README or http://docbook.sf.net/release/xsl/current/ for
13      copyright and other information.
14
15      ******************************************************************** -->
16
17 <!-- ==================================================================== -->
18
19 <xsl:variable name="bookmarks.state">
20   <xsl:choose>
21     <xsl:when test="$bookmarks.collapse != 0">hide</xsl:when>
22     <xsl:otherwise>show</xsl:otherwise>
23   </xsl:choose>
24 </xsl:variable>
25
26 <xsl:template match="*" mode="fop1.outline">
27   <xsl:apply-templates select="*" mode="fop1.outline"/>
28 </xsl:template>
29
30 <xsl:template match="set|book|part|reference|
31                      preface|chapter|appendix|article
32                      |glossary|bibliography|index|setindex
33                      |refentry
34                      |sect1|sect2|sect3|sect4|sect5|section"
35               mode="fop1.outline">
36
37   <xsl:variable name="id">
38     <xsl:call-template name="object.id"/>
39   </xsl:variable>
40   <xsl:variable name="bookmark-label">
41     <xsl:apply-templates select="." mode="object.title.markup"/>
42   </xsl:variable>
43
44   <!-- Put the root element bookmark at the same level as its children -->
45   <!-- If the object is a set or book, generate a bookmark for the toc -->
46
47   <xsl:choose>
48     <xsl:when test="self::index and $generate.index = 0"/>      
49     <xsl:when test="parent::*">
50       <fo:bookmark internal-destination="{$id}">
51         <xsl:attribute name="starting-state">
52           <xsl:value-of select="$bookmarks.state"/>
53         </xsl:attribute>
54         <fo:bookmark-title>
55           <xsl:value-of select="normalize-space(translate($bookmark-label, $a-dia, $a-asc))"/>
56         </fo:bookmark-title>
57         <xsl:apply-templates select="*" mode="fop1.outline"/>
58       </fo:bookmark>
59     </xsl:when>
60     <xsl:otherwise>
61       <fo:bookmark internal-destination="{$id}">
62         <xsl:attribute name="starting-state">
63           <xsl:value-of select="$bookmarks.state"/>
64         </xsl:attribute>
65         <fo:bookmark-title>
66           <xsl:value-of select="normalize-space(translate($bookmark-label, $a-dia, $a-asc))"/>
67         </fo:bookmark-title>
68       </fo:bookmark>
69
70       <xsl:variable name="toc.params">
71         <xsl:call-template name="find.path.params">
72           <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
73         </xsl:call-template>
74       </xsl:variable>
75
76       <xsl:if test="contains($toc.params, 'toc')
77                     and (book|part|reference|preface|chapter|appendix|article
78                          |glossary|bibliography|index|setindex
79                          |refentry
80                          |sect1|sect2|sect3|sect4|sect5|section)">
81         <fo:bookmark internal-destination="toc...{$id}">
82           <fo:bookmark-title>
83             <xsl:call-template name="gentext">
84               <xsl:with-param name="key" select="'TableofContents'"/>
85             </xsl:call-template>
86           </fo:bookmark-title>
87         </fo:bookmark>
88       </xsl:if>
89       <xsl:apply-templates select="*" mode="fop1.outline"/>
90     </xsl:otherwise>
91   </xsl:choose>
92 <!--
93   <fo:bookmark internal-destination="{$id}"/>
94 -->
95 </xsl:template>
96
97 <xsl:template match="*" mode="fop1.foxdest">
98   <xsl:apply-templates select="*" mode="fop1.foxdest"/>
99 </xsl:template>
100
101 <xsl:template match="set|book|part|reference|
102                      preface|chapter|appendix|article
103                      |glossary|bibliography|index|setindex
104                      |refentry
105                      |sect1|sect2|sect3|sect4|sect5|section"
106               mode="fop1.foxdest">
107   <xsl:variable name="id">
108     <xsl:call-template name="object.id"/>
109   </xsl:variable>
110   <xsl:variable name="bookmark-label">
111     <xsl:apply-templates select="." mode="object.title.markup"/>
112   </xsl:variable>
113   <!--xsl:if test="$id != ''">
114     <fox:destination internal-destination="{$id}"/>
115   </xsl:if-->
116
117   <!-- Put the root element bookmark at the same level as its children -->
118   <!-- If the object is a set or book, generate a bookmark for the toc -->
119
120   <xsl:choose>
121     <xsl:when test="self::index and $generate.index = 0"/>      
122     <xsl:when test="parent::*">
123       <fox:destination internal-destination="{$id}"/>
124         <xsl:apply-templates select="*" mode="fop1.foxdest"/>
125     </xsl:when>
126     <xsl:otherwise>
127       <fox:destination internal-destination="{$id}"/>
128       <xsl:apply-templates select="*" mode="fop1.foxdest"/>
129     </xsl:otherwise>
130   </xsl:choose>
131 </xsl:template>
132 <!-- Metadata support ("Document Properties" in Adobe Reader) -->
133 <xsl:template name="fop1-document-information">
134   <xsl:variable name="authors" select="(//author|//editor|//corpauthor|//authorgroup)[1]"/>
135
136   <xsl:variable name="title">
137     <xsl:apply-templates select="/*[1]" mode="label.markup"/>
138     <xsl:apply-templates select="/*[1]" mode="title.markup"/>
139     <xsl:variable name="subtitle">
140       <xsl:apply-templates select="/*[1]" mode="subtitle.markup"/>
141     </xsl:variable>
142     <xsl:if test="$subtitle !=''">
143       <xsl:text> - </xsl:text>
144       <xsl:value-of select="$subtitle"/>
145     </xsl:if>
146   </xsl:variable>
147
148   <fo:declarations>
149     <x:xmpmeta xmlns:x="adobe:ns:meta/">
150       <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
151         <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
152           <!-- Dublin Core properties go here -->
153
154           <!-- Title -->
155           <dc:title><xsl:value-of select="normalize-space($title)"/></dc:title>
156
157           <!-- Author -->
158           <xsl:if test="$authors">
159             <xsl:variable name="author">
160               <xsl:choose>
161                 <xsl:when test="$authors[self::authorgroup]">
162                   <xsl:call-template name="person.name.list">
163                     <xsl:with-param name="person.list" 
164                        select="$authors/*[self::author|self::corpauthor|
165                                      self::othercredit|self::editor]"/>
166                   </xsl:call-template>
167                 </xsl:when>
168                 <xsl:when test="$authors[self::corpauthor]">
169                   <xsl:value-of select="$authors"/>
170                 </xsl:when>
171                 <xsl:otherwise>
172                   <xsl:call-template name="person.name">
173                     <xsl:with-param name="node" select="$authors"/>
174                   </xsl:call-template>
175                 </xsl:otherwise>
176               </xsl:choose>
177             </xsl:variable>
178
179             <dc:creator><xsl:value-of select="normalize-space($author)"/></dc:creator>
180           </xsl:if>
181
182           <!-- Subject -->
183           <xsl:if test="//subjectterm">
184             <dc:description>
185               <xsl:for-each select="//subjectterm">
186                 <xsl:value-of select="normalize-space(.)"/>
187                 <xsl:if test="position() != last()">
188                   <xsl:text>, </xsl:text>
189                 </xsl:if>
190               </xsl:for-each>
191             </dc:description>
192           </xsl:if>
193         </rdf:Description>
194
195         <rdf:Description rdf:about="" xmlns:pdf="http://ns.adobe.com/pdf/1.3/">
196           <!-- PDF properties go here -->
197
198           <!-- Keywords -->
199           <xsl:if test="//keyword">
200             <pdf:Keywords>
201               <xsl:for-each select="//keyword">
202                 <xsl:value-of select="normalize-space(.)"/>
203                 <xsl:if test="position() != last()">
204                   <xsl:text>, </xsl:text>
205                 </xsl:if>
206               </xsl:for-each>
207             </pdf:Keywords>
208           </xsl:if>
209         </rdf:Description>
210
211         <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
212           <!-- XMP properties go here -->
213
214           <!-- Creator Tool -->
215           <xmp:CreatorTool>DocBook XSL Stylesheets with Apache FOP</xmp:CreatorTool>
216         </rdf:Description>
217
218       </rdf:RDF>
219     </x:xmpmeta>
220   </fo:declarations>
221 </xsl:template>
222
223 </xsl:stylesheet>