blob: 9bb2e81d0b87886d2622d239fd1a4d92ad66fb58 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<!--
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program; see the file COPYING.LGPL. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mal="http://projectmallard.org/1.0/"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:exsl="http://exslt.org/common"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="mal svg xlink"
extension-element-prefixes="exsl"
version="1.0">
<!--!!==========================================================================
Mallard to HTML - SVG
Handle embedded SVG.
:Revision: version="1.0" date="2010-06-04" status="final"
This stylesheet matches embedded SVG in %{mal2html.block.mode} and processes it
in %{mal2html.svg.mode}.
-->
<!--%%==========================================================================
mal2html.svg.mode
Output SVG and handle Mallard extension.
:Revision: version="1.0" date="2010-06-04" status="final"
This mode is used for processing SVG embedded into Mallard documents. For most
types of SVG content, it simply copies the input directly. It does check for
certain Mallard extensions, for example to use the Mallard linking mechanism.
-->
<xsl:template mode="mal2html.svg.mode" match="svg:*">
<xsl:choose>
<xsl:when test="@mal:xref">
<xsl:variable name="target">
<xsl:call-template name="mal.link.target">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="xref" select="@mal:xref"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="title">
<xsl:call-template name="mal.link.content">
<xsl:with-param name="xref" select="@mal:xref"/>
<xsl:with-param name="role" select="'text'"/>
</xsl:call-template>
</xsl:variable>
<svg:a xlink:href="{$target}" xlink:show="replace"
xlink:title="{$title}" target="_top">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates mode="mal2html.svg.mode" select="node()"/>
</xsl:copy>
</svg:a>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates mode="mal2html.svg.mode" select="node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template mode="mal2html.svg.mode" match="text()">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template mode="mal2html.block.mode" match="svg:svg">
<xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
<xsl:variable name="id">
<xsl:choose>
<xsl:when test="@xml:id">
<xsl:value-of select="@xml:id"/>
</xsl:when>
<xsl:when test="@id">
<xsl:value-of select="@id"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="generate-id(.)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$html.xhtml">
<div>
<xsl:attribute name="class">
<xsl:text>svg</xsl:text>
<xsl:if test="$if != 'true'">
<xsl:text> if-if </xsl:text>
<xsl:value-of select="$if"/>
</xsl:if>
</xsl:attribute>
<xsl:apply-templates mode="mal2html.svg.mode" select="."/>
</div>
</xsl:when>
<xsl:otherwise>
<div>
<xsl:attribute name="class">
<xsl:text>svg</xsl:text>
<xsl:if test="$if != 'true'">
<xsl:text> if-if </xsl:text>
<xsl:value-of select="$if"/>
</xsl:if>
</xsl:attribute>
<object data="{$id}.svg" type="image/svg+xml">
<xsl:copy-of select="@width"/>
<xsl:copy-of select="@height"/>
</object>
</div>
<exsl:document href="{$id}.svg">
<xsl:apply-templates mode="mal2html.svg.mode" select="."/>
</exsl:document>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
|