2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:d="http://docbook.org/ns/docbook"
4 xmlns:fo="http://www.w3.org/1999/XSL/Format"
5 xmlns:exsl="http://exslt.org/common"
6 xmlns:set="http://exslt.org/sets"
7 exclude-result-prefixes="exsl set d"
10 <!-- ********************************************************************
12 This file is part of the DocBook XSL Stylesheet distribution.
13 See ../README or http://cdn.docbook.org/release/xsl for copyright
14 copyright and other information.
16 ******************************************************************** -->
18 <!-- This module contains templates that match against FO nodes. It is used
19 to post-process result tree fragments for some sorts of cleanup.
20 These templates can only ever be fired by a processor that supports
23 <!-- ==================================================================== -->
25 <!-- insert.fo.fnum mode templates insert a particular RTF at the beginning
26 of the first paragraph in the primary RTF. In fact, they are inserting
27 a footnote-number, so we tinker a few other things too, like spacing and
30 <xsl:template match="/" mode="insert.fo.fnum">
31 <xsl:param name="mark" select="'?'"/>
32 <xsl:apply-templates mode="insert.fo.fnum">
33 <xsl:with-param name="mark" select="$mark"/>
34 </xsl:apply-templates>
37 <xsl:template match="*" mode="insert.fo.fnum">
38 <xsl:param name="mark" select="'?'"/>
40 <xsl:copy-of select="@*"/>
41 <xsl:apply-templates mode="insert.fo.fnum">
42 <xsl:with-param name="mark" select="$mark"/>
43 </xsl:apply-templates>
47 <xsl:template match="fo:block" mode="insert.fo.fnum">
48 <xsl:param name="mark" select="'?'"/>
50 <xsl:for-each select="@*">
52 <xsl:when test="starts-with(name(.), 'space-before')"/>
53 <xsl:when test="starts-with(name(.), 'space-after')"/>
54 <xsl:when test="starts-with(name(.), 'font-size')"/>
56 <xsl:copy-of select="."/>
60 <xsl:if test="not(preceding::fo:block)">
61 <xsl:copy-of select="$mark"/>
63 <xsl:apply-templates mode="insert.fo.fnum">
64 <xsl:with-param name="mark" select="$mark"/>
65 </xsl:apply-templates>
69 <xsl:template match="text()|processing-instruction()|comment()" mode="insert.fo.fnum">
70 <xsl:param name="mark" select="'?'"/>
74 <!-- ==================================================================== -->
76 <!-- insert.fo.block mode templates insert a particular RTF at the beginning
77 of the first paragraph in the primary RTF. -->
79 <xsl:template match="/" mode="insert.fo.block">
80 <xsl:param name="mark" select="'?'"/>
81 <xsl:apply-templates mode="insert.fo.block">
82 <xsl:with-param name="mark" select="$mark"/>
83 </xsl:apply-templates>
86 <xsl:template match="*" mode="insert.fo.block">
87 <xsl:param name="mark" select="'?'"/>
89 <xsl:copy-of select="@*"/>
90 <xsl:apply-templates mode="insert.fo.block">
91 <xsl:with-param name="mark" select="$mark"/>
92 </xsl:apply-templates>
96 <xsl:template match="fo:block" mode="insert.fo.block">
97 <xsl:param name="mark" select="'?'"/>
99 <xsl:copy-of select="@*"/>
100 <xsl:if test="not(preceding::fo:block)">
101 <xsl:copy-of select="$mark"/>
103 <xsl:apply-templates mode="insert.fo.block">
104 <xsl:with-param name="mark" select="$mark"/>
105 </xsl:apply-templates>
109 <xsl:template match="text()|processing-instruction()|comment()" mode="insert.fo.block">
110 <xsl:param name="mark" select="'?'"/>
114 <!-- ==================================================================== -->
116 <!-- insert.fo.text mode templates insert a particular RTF at the beginning
117 of the first text-node in the primary RTF. -->
119 <xsl:template match="/" mode="insert.fo.text">
120 <xsl:param name="mark" select="'?'"/>
121 <xsl:apply-templates mode="insert.fo.text">
122 <xsl:with-param name="mark" select="$mark"/>
123 </xsl:apply-templates>
126 <xsl:template match="*" mode="insert.fo.text">
127 <xsl:param name="mark" select="'?'"/>
129 <xsl:copy-of select="@*"/>
130 <xsl:apply-templates mode="insert.fo.text">
131 <xsl:with-param name="mark" select="$mark"/>
132 </xsl:apply-templates>
136 <xsl:template match="text()|processing-instruction()|comment()" mode="insert.fo.text">
137 <xsl:param name="mark" select="'?'"/>
139 <xsl:if test="not(preceding::text())">
140 <xsl:copy-of select="$mark"/>
146 <xsl:template match="processing-instruction()|comment()" mode="insert.fo.text">
147 <xsl:param name="mark" select="'?'"/>
151 <!-- ==================================================================== -->