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: xep.xsl,v 1.24 2005/11/20 19:30:41 bobstayton Exp $ 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" select="(//author|//editor|//corpauthor|//authorgroup)[1]"/> 22 <xsl:if test="$authors"> 23 <xsl:variable name="author"> 24 <xsl:choose> 25 <xsl:when test="$authors[self::authorgroup]"> 26 <xsl:call-template name="person.name.list"> 27 <xsl:with-param name="person.list" 28 select="$authors/*[self::author|self::corpauthor| 29 self::othercredit|self::editor]"/> 30 </xsl:call-template> 31 </xsl:when> 32 <xsl:when test="$authors[self::corpauthor]"> 33 <xsl:value-of select="$authors"/> 34 </xsl:when> 35 <xsl:otherwise> 36 <xsl:call-template name="person.name"> 37 <xsl:with-param name="node" select="$authors"/> 38 </xsl:call-template> 39 </xsl:otherwise> 40 </xsl:choose> 41 </xsl:variable> 42 <xsl:element name="rx:meta-field"> 43 <xsl:attribute name="name">author</xsl:attribute> 44 <xsl:attribute name="value"> 45 <xsl:value-of select="normalize-space($author)"/> 46 </xsl:attribute> 47 </xsl:element> 48 </xsl:if> 49 50 <xsl:variable name="title"> 51 <xsl:apply-templates select="/*[1]" mode="label.markup"/> 52 <xsl:apply-templates select="/*[1]" mode="title.markup"/> 53 </xsl:variable> 54 55 <xsl:element name="rx:meta-field"> 56 <xsl:attribute name="name">creator</xsl:attribute> 57 <xsl:attribute name="value"> 58 <xsl:text>DocBook XSL Stylesheets V</xsl:text> 59 <xsl:value-of select="$VERSION"/> 60 </xsl:attribute> 61 </xsl:element> 62 63 <xsl:element name="rx:meta-field"> 64 <xsl:attribute name="name">title</xsl:attribute> 65 <xsl:attribute name="value"> 66 <xsl:value-of select="normalize-space($title)"/> 67 </xsl:attribute> 68 </xsl:element> 69 70 <xsl:if test="//keyword"> 71 <xsl:element name="rx:meta-field"> 72 <xsl:attribute name="name">keywords</xsl:attribute> 73 <xsl:attribute name="value"> 74 <xsl:for-each select="//keyword"> 75 <xsl:value-of select="normalize-space(.)"/> 76 <xsl:if test="position() != last()"> 77 <xsl:text>, </xsl:text> 78 </xsl:if> 79 </xsl:for-each> 80 </xsl:attribute> 81 </xsl:element> 82 </xsl:if> 83 84 <xsl:if test="//subjectterm"> 85 <xsl:element name="rx:meta-field"> 86 <xsl:attribute name="name">subject</xsl:attribute> 87 <xsl:attribute name="value"> 88 <xsl:for-each select="//subjectterm"> 89 <xsl:value-of select="normalize-space(.)"/> 90 <xsl:if test="position() != last()"> 91 <xsl:text>, </xsl:text> 92 </xsl:if> 93 </xsl:for-each> 94 </xsl:attribute> 95 </xsl:element> 96 </xsl:if> 97 </rx:meta-info> 98</xsl:template> 99 100<!-- ******************************************************************** 101 Pdf bookmarks 102 ******************************************************************** --> 103 104<xsl:template match="*" mode="xep.outline"> 105 <xsl:apply-templates select="*" mode="xep.outline"/> 106</xsl:template> 107 108<xsl:template match="set|book|part|reference|preface|chapter|appendix|article 109 |glossary|bibliography|index|setindex 110 |refentry|refsynopsisdiv 111 |refsect1|refsect2|refsect3|refsection 112 |sect1|sect2|sect3|sect4|sect5|section" 113 mode="xep.outline"> 114 <xsl:variable name="id"> 115 <xsl:call-template name="object.id"/> 116 </xsl:variable> 117 <xsl:variable name="bookmark-label"> 118 <xsl:apply-templates select="." mode="object.title.markup"/> 119 </xsl:variable> 120 121 <!-- Put the root element bookmark at the same level as its children --> 122 <!-- If the object is a set or book, generate a bookmark for the toc --> 123 124 <xsl:choose> 125 <xsl:when test="parent::*"> 126 <rx:bookmark internal-destination="{$id}"> 127 <rx:bookmark-label> 128 <xsl:value-of select="normalize-space($bookmark-label)"/> 129 </rx:bookmark-label> 130 <xsl:apply-templates select="*" mode="xep.outline"/> 131 </rx:bookmark> 132 </xsl:when> 133 <xsl:otherwise> 134 <xsl:if test="$bookmark-label != ''"> 135 <rx:bookmark internal-destination="{$id}"> 136 <rx:bookmark-label> 137 <xsl:value-of select="normalize-space($bookmark-label)"/> 138 </rx:bookmark-label> 139 </rx:bookmark> 140 </xsl:if> 141 142 <xsl:variable name="toc.params"> 143 <xsl:call-template name="find.path.params"> 144 <xsl:with-param name="table" select="normalize-space($generate.toc)"/> 145 </xsl:call-template> 146 </xsl:variable> 147 <xsl:if test="contains($toc.params, 'toc') 148 and set|book|part|reference|section|sect1|refentry 149 |article|bibliography|glossary|chapter 150 |appendix"> 151 <rx:bookmark internal-destination="toc...{$id}"> 152 <rx:bookmark-label> 153 <xsl:call-template name="gentext"> 154 <xsl:with-param name="key" select="'TableofContents'"/> 155 </xsl:call-template> 156 </rx:bookmark-label> 157 </rx:bookmark> 158 </xsl:if> 159 <xsl:apply-templates select="*" mode="xep.outline"/> 160 </xsl:otherwise> 161 </xsl:choose> 162</xsl:template> 163 164<xsl:template name="xep-pis"> 165 <xsl:if test="$crop.marks != 0"> 166 <xsl:processing-instruction name="xep-pdf-crop-mark-width"><xsl:value-of select="$crop.mark.width"/></xsl:processing-instruction> 167 <xsl:processing-instruction name="xep-pdf-crop-offset"><xsl:value-of select="$crop.mark.offset"/></xsl:processing-instruction> 168 <xsl:processing-instruction name="xep-pdf-bleed"><xsl:value-of select="$crop.mark.bleed"/></xsl:processing-instruction> 169 </xsl:if> 170 171 <xsl:call-template name="user-xep-pis"/> 172</xsl:template> 173 174<!-- Placeholder for user defined PIs --> 175<xsl:template name="user-xep-pis"/> 176 177</xsl:stylesheet> 178