source: clfs-sysroot/BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/xep.xsl @ a18aefd

Last change on this file since a18aefd was a18aefd, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added lfs-xsl stylesheets.

  • Property mode set to 100644
File size: 6.7 KB
Line 
1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                xmlns:fo="http://www.w3.org/1999/XSL/Format"
4                xmlns:rx="http://www.renderx.com/XSL/Extensions"
5                version='1.0'>
6
7<!-- ********************************************************************
8     $Id$
9     ********************************************************************
10     (c) Stephane Bline Peregrine Systems 2001
11     Implementation of xep extensions:
12       * Pdf bookmarks (based on the XEP 2.5 implementation)
13       * Document information (XEP 2.5 meta information extensions)
14     ******************************************************************** -->
15
16<!-- FIXME: Norm, I changed things so that the top-level element (book or set)
17     does not appear in the TOC. Is this the right thing? -->
18
19<xsl:template name="xep-document-information">
20  <rx:meta-info>
21    <xsl:variable name="authors" 
22                  select="(//author|//editor|//corpauthor|//authorgroup)[1]"/>
23    <xsl:if test="$authors">
24      <xsl:variable name="author">
25        <xsl:choose>
26          <xsl:when test="$authors[self::authorgroup]">
27            <xsl:call-template name="person.name.list">
28              <xsl:with-param name="person.list" 
29                        select="$authors/*[self::author|self::corpauthor|
30                               self::othercredit|self::editor]"/>
31            </xsl:call-template>
32          </xsl:when>
33          <xsl:when test="$authors[self::corpauthor]">
34            <xsl:value-of select="$authors"/>
35          </xsl:when>
36          <xsl:otherwise>
37            <xsl:call-template name="person.name">
38              <xsl:with-param name="node" select="$authors"/>
39            </xsl:call-template>
40          </xsl:otherwise>
41        </xsl:choose>
42      </xsl:variable>
43      <xsl:element name="rx:meta-field">
44        <xsl:attribute name="name">author</xsl:attribute>
45        <xsl:attribute name="value">
46          <xsl:value-of select="normalize-space($author)"/>
47        </xsl:attribute>
48      </xsl:element>
49    </xsl:if>
50
51    <xsl:variable name="title">
52      <xsl:apply-templates select="/*[1]" mode="label.markup"/>
53      <xsl:apply-templates select="/*[1]" mode="title.markup"/>
54    </xsl:variable>
55
56    <xsl:element name="rx:meta-field">
57      <xsl:attribute name="name">creator</xsl:attribute>
58      <xsl:attribute name="value">
59        <xsl:text>DocBook </xsl:text>
60        <xsl:value-of select="$DistroTitle"/>
61        <xsl:text> V</xsl:text>
62        <xsl:value-of select="$VERSION"/>
63      </xsl:attribute>
64    </xsl:element>
65
66    <xsl:element name="rx:meta-field">
67      <xsl:attribute name="name">title</xsl:attribute>
68      <xsl:attribute name="value">
69        <xsl:value-of select="normalize-space($title)"/>
70      </xsl:attribute>
71    </xsl:element>
72
73    <xsl:if test="//keyword">
74      <xsl:element name="rx:meta-field">
75        <xsl:attribute name="name">keywords</xsl:attribute>
76        <xsl:attribute name="value">
77          <xsl:for-each select="//keyword">
78            <xsl:value-of select="normalize-space(.)"/>
79            <xsl:if test="position() != last()">
80              <xsl:text>, </xsl:text>
81            </xsl:if>
82          </xsl:for-each>
83        </xsl:attribute>
84      </xsl:element>
85    </xsl:if>
86
87    <xsl:if test="//subjectterm">
88      <xsl:element name="rx:meta-field">
89        <xsl:attribute name="name">subject</xsl:attribute>
90        <xsl:attribute name="value">
91          <xsl:for-each select="//subjectterm">
92            <xsl:value-of select="normalize-space(.)"/>
93            <xsl:if test="position() != last()">
94              <xsl:text>, </xsl:text>
95            </xsl:if>
96          </xsl:for-each>
97        </xsl:attribute>
98      </xsl:element>
99    </xsl:if>
100  </rx:meta-info>
101</xsl:template>
102
103<!-- ********************************************************************
104     Pdf bookmarks
105     ******************************************************************** -->
106
107<xsl:template match="*" mode="xep.outline">
108  <xsl:apply-templates select="*" mode="xep.outline"/>
109</xsl:template>
110
111<xsl:template match="set|book|part|reference|preface|chapter|appendix|article
112                     |glossary|bibliography|index|setindex
113                     |refentry|refsynopsisdiv
114                     |refsect1|refsect2|refsect3|refsection
115                     |sect1|sect2|sect3|sect4|sect5|section"
116              mode="xep.outline">
117  <xsl:variable name="id">
118    <xsl:call-template name="object.id"/>
119  </xsl:variable>
120  <xsl:variable name="bookmark-label">
121    <xsl:apply-templates select="." mode="object.title.markup"/>
122  </xsl:variable>
123
124  <!-- Put the root element bookmark at the same level as its children -->
125  <!-- If the object is a set or book, generate a bookmark for the toc -->
126
127  <xsl:choose>
128    <xsl:when test="parent::*">
129      <rx:bookmark internal-destination="{$id}">
130        <rx:bookmark-label>
131          <xsl:value-of select="normalize-space($bookmark-label)"/>
132        </rx:bookmark-label>
133        <xsl:apply-templates select="*" mode="xep.outline"/>
134      </rx:bookmark>
135    </xsl:when>
136    <xsl:otherwise>
137      <xsl:if test="$bookmark-label != ''">
138        <rx:bookmark internal-destination="{$id}">
139          <rx:bookmark-label>
140            <xsl:value-of select="normalize-space($bookmark-label)"/>
141          </rx:bookmark-label>
142        </rx:bookmark>
143      </xsl:if>
144
145      <xsl:variable name="toc.params">
146        <xsl:call-template name="find.path.params">
147          <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
148        </xsl:call-template>
149      </xsl:variable>
150      <xsl:if test="contains($toc.params, 'toc')
151                    and set|book|part|reference|section|sect1|refentry
152                        |article|bibliography|glossary|chapter
153                        |appendix">
154        <rx:bookmark internal-destination="toc...{$id}">
155          <rx:bookmark-label>
156            <xsl:call-template name="gentext">
157              <xsl:with-param name="key" select="'TableofContents'"/>
158            </xsl:call-template>
159          </rx:bookmark-label>
160        </rx:bookmark>
161      </xsl:if>
162      <xsl:apply-templates select="*" mode="xep.outline"/>
163    </xsl:otherwise>
164  </xsl:choose>
165</xsl:template>
166
167<xsl:template name="xep-pis">
168  <xsl:if test="$crop.marks != 0">
169    <xsl:processing-instruction name="xep-pdf-crop-mark-width"><xsl:value-of select="$crop.mark.width"/></xsl:processing-instruction>
170    <xsl:processing-instruction name="xep-pdf-crop-offset"><xsl:value-of select="$crop.mark.offset"/></xsl:processing-instruction>
171    <xsl:processing-instruction name="xep-pdf-bleed"><xsl:value-of select="$crop.mark.bleed"/></xsl:processing-instruction>
172  </xsl:if>
173
174  <xsl:call-template name="user-xep-pis"/>
175</xsl:template>
176
177<!-- Placeholder for user defined PIs -->
178<xsl:template name="user-xep-pis"/>
179
180</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.