source: rfc2629xslt/xsl11toFop-0.20.5.xslt @ 560

Last change on this file since 560 was 329, checked in by julian.reschke@…, 11 years ago

update to latest version of rfc2629.xslt

  • Property svn:eol-style set to native
File size: 5.2 KB
Line 
1<!--
2    Transform XSL 1.1 extensions to FOP extensions
3
4    Copyright (c) 2006-2007, Julian Reschke (julian.reschke@greenbytes.de)
5    All rights reserved.
6
7    Redistribution and use in source and binary forms, with or without
8    modification, are permitted provided that the following conditions are met:
9
10    * Redistributions of source code must retain the above copyright notice,
11      this list of conditions and the following disclaimer.
12    * Redistributions in binary form must reproduce the above copyright notice,
13      this list of conditions and the following disclaimer in the documentation
14      and/or other materials provided with the distribution.
15    * Neither the name of Julian Reschke nor the names of its contributors
16      may be used to endorse or promote products derived from this software
17      without specific prior written permission.
18
19    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29    POSSIBILITY OF SUCH DAMAGE.
30-->
31
32<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
33               xmlns:fo="http://www.w3.org/1999/XSL/Format"
34               xmlns:fox="http://xml.apache.org/fop/extensions"
35               version="1.0"
36>
37
38<!-- transform bookmark elements -->
39
40<xsl:template match="fo:bookmark-tree" >
41  <xsl:apply-templates/>
42</xsl:template>
43
44<xsl:template match="fo:bookmark" >
45  <fox:outline internal-destination="{@internal-destination}">
46    <xsl:apply-templates/>
47  </fox:outline>
48</xsl:template>
49
50<xsl:template match="fo:bookmark-title" >
51  <fox:label>
52    <xsl:apply-templates/>
53  </fox:label>
54</xsl:template>
55
56
57<!-- work around for missing page break stuff -->
58
59<xsl:template match="fo:block[@page-break-before='always']">
60  <xsl:copy>
61    <xsl:attribute name="break-before">page</xsl:attribute>
62    <xsl:attribute name="keep-with-previous">auto</xsl:attribute>
63    <xsl:apply-templates select="@*[not(name()='page-break-before') and not(name()='id')]" />
64    <xsl:apply-templates select="@id" />
65    <xsl:apply-templates select="node()" />
66  </xsl:copy>
67</xsl:template>
68
69<!-- work around weird list item behaviour -->
70
71<xsl:template match="fo:list-item-body/fo:block[not(node())]">
72  <xsl:copy>
73    <xsl:apply-templates select="@*"/>
74    <!-- add NBSP so the block is not empty -->
75    <xsl:text>&#160;</xsl:text>
76  </xsl:copy>
77</xsl:template>
78
79<!-- add destination elements where IDs are defined -->
80<xsl:template match="@id">
81  <xsl:copy-of select="."/>
82  <fox:destination internal-destination="{.}"/>
83</xsl:template>
84
85<xsl:template match="fo:list-item/@id">
86  <!-- dunno how to in list items, so move into list-item-body -->
87</xsl:template>
88
89<xsl:template match="fo:list-item[@id]/fo:list-item-body">
90  <xsl:copy>
91    <xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
92    <xsl:apply-templates select="@*|node()"/>
93  </xsl:copy>
94</xsl:template>
95
96<!-- index-page-citation-list -->
97
98<xsl:attribute-set name="internal-link">
99  <xsl:attribute name="color">#000080</xsl:attribute>
100</xsl:attribute-set>
101
102<xsl:template match="fo:index-page-citation-list">
103  <xsl:variable name="items" select="fo:index-key-reference"/>
104  <xsl:variable name="entries" select="//*[@index-key=$items/@ref-index-key]"/>
105  <xsl:for-each select="$entries">
106    <fo:basic-link internal-destination="{ancestor-or-self::*/@id}" xsl:use-attribute-sets="internal-link">
107      <xsl:if test="contains(@index-key,',primary') and substring-after(@index-key,',primary')=''">
108        <xsl:attribute name="font-weight">bold</xsl:attribute>
109      </xsl:if>
110      <fo:page-number-citation ref-id="{ancestor-or-self::*/@id}"/>
111    </fo:basic-link>
112    <xsl:if test="position()!=last()"><xsl:text>, </xsl:text></xsl:if>
113  </xsl:for-each>
114</xsl:template>
115
116<!-- suppress and map-->
117<xsl:template match="@index-key" />
118<xsl:template match="fo:index-range-end" />
119<xsl:template match="fo:index-range-begin">
120  <fo:wrapper id="{@id}"/>
121</xsl:template>
122
123<!-- remove third-party extensions -->
124
125<xsl:template match="*[namespace-uri()!='http://www.w3.org/1999/XSL/Format' and namespace-uri()!='http://xml.apache.org/fop/extensions']" />
126<xsl:template match="@*[namespace-uri()!='' and namespace-uri()!='http://www.w3.org/1999/XSL/Format' and namespace-uri()!='http://xml.apache.org/fop/extensions']" />
127
128
129
130<xsl:template match="node()|@*">
131  <xsl:copy>
132    <xsl:apply-templates select="@*[not(name()='id')]" />
133    <xsl:apply-templates select="@id" />
134    <xsl:apply-templates select="node()" />
135  </xsl:copy>
136</xsl:template>
137
138<xsl:template match="/">
139        <xsl:copy><xsl:apply-templates select="node()" /></xsl:copy>
140</xsl:template>
141
142</xsl:transform>
Note: See TracBrowser for help on using the repository browser.