author | František Kučera <franta-hg@frantovo.cz> |
Tue Oct 18 20:54:14 2011 +0200 (2011-10-18) | |
changeset 96 | a0a93e49d055 |
parent 90 | 2ed2497d4559 |
child 97 | 7520a9246ff5 |
permissions | -rwxr-xr-x |
franta-hg@76 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
franta-hg@77 | 2 |
<xsl:stylesheet version="2.0" |
franta-hg@76 | 3 |
xmlns="http://www.w3.org/1999/xhtml" |
franta-hg@76 | 4 |
xmlns:h="http://www.w3.org/1999/xhtml" |
franta-hg@76 | 5 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
franta-hg@76 | 6 |
xmlns:fn="http://www.w3.org/2005/xpath-functions" |
franta-hg@76 | 7 |
xmlns:svg="http://www.w3.org/2000/svg" |
franta-hg@76 | 8 |
xmlns:xs="http://www.w3.org/2001/XMLSchema" |
franta-hg@76 | 9 |
exclude-result-prefixes="fn h xs"> |
franta-hg@76 | 10 |
<xsl:output |
franta-hg@76 | 11 |
method="xml" |
franta-hg@76 | 12 |
indent="yes" |
franta-hg@76 | 13 |
encoding="UTF-8" |
franta-hg@88 | 14 |
doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"/><!-- |
franta-hg@88 | 15 |
doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>--> |
franta-hg@76 | 16 |
|
franta-hg@76 | 17 |
|
franta-hg@76 | 18 |
<xsl:param name="title"/> |
franta-hg@83 | 19 |
<xsl:param name="headComment"/> |
franta-hg@76 | 20 |
<xsl:param name="isRoot"/> |
franta-hg@76 | 21 |
<xsl:param name="urlBase"/> |
franta-hg@76 | 22 |
<xsl:param name="wwwRead"/> |
franta-hg@76 | 23 |
<xsl:param name="wwwPost"/> |
franta-hg@76 | 24 |
|
franta-hg@76 | 25 |
|
franta-hg@76 | 26 |
<!-- Celý dokument --> |
franta-hg@76 | 27 |
<xsl:template match="/"> |
franta-hg@76 | 28 |
<html> |
franta-hg@76 | 29 |
<head> |
franta-hg@76 | 30 |
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> |
franta-hg@76 | 31 |
<xsl:if test="$urlBase"> |
franta-hg@76 | 32 |
<base href="{$urlBase}"/> |
franta-hg@76 | 33 |
</xsl:if> |
franta-hg@76 | 34 |
<xsl:if test="$title"> |
franta-hg@76 | 35 |
<title><xsl:value-of select="$title"/></title> |
franta-hg@76 | 36 |
</xsl:if> |
franta-hg@83 | 37 |
<xsl:if test="$headComment"> |
franta-hg@83 | 38 |
<xsl:comment><xsl:value-of select="$headComment"/></xsl:comment> |
franta-hg@83 | 39 |
</xsl:if> |
franta-hg@76 | 40 |
<style type="text/css"> |
franta-hg@76 | 41 |
body { |
franta-hg@76 | 42 |
font-family: sans-serif; |
franta-hg@76 | 43 |
font-size: 16px; |
franta-hg@76 | 44 |
} |
franta-hg@76 | 45 |
|
franta-hg@76 | 46 |
.wwwLinks { |
franta-hg@76 | 47 |
border-top: 2px solid grey; |
franta-hg@76 | 48 |
margin-top: 16px; |
franta-hg@76 | 49 |
font-size: 66%; |
franta-hg@76 | 50 |
} |
franta-hg@76 | 51 |
|
franta-hg@76 | 52 |
blockquote { |
franta-hg@76 | 53 |
background-color: #eee; |
franta-hg@76 | 54 |
font-style: italic; |
franta-hg@76 | 55 |
padding: 2px 20px; |
franta-hg@76 | 56 |
margin: 10px 32px; |
franta-hg@76 | 57 |
border-left: 3px solid silver; |
franta-hg@76 | 58 |
} |
franta-hg@76 | 59 |
|
franta-hg@76 | 60 |
pre { |
franta-hg@76 | 61 |
background-color: #eee; |
franta-hg@76 | 62 |
padding: 2px 20px; |
franta-hg@76 | 63 |
margin: 10px 32px; |
franta-hg@76 | 64 |
border-left: 3px solid #a00; |
franta-hg@76 | 65 |
} |
franta-hg@76 | 66 |
|
franta-hg@76 | 67 |
img { |
franta-hg@76 | 68 |
margin: 8px; |
franta-hg@76 | 69 |
} |
franta-hg@76 | 70 |
|
franta-hg@76 | 71 |
a img { |
franta-hg@76 | 72 |
border: none; |
franta-hg@76 | 73 |
} |
franta-hg@76 | 74 |
</style> |
franta-hg@76 | 75 |
</head> |
franta-hg@76 | 76 |
<body> |
franta-hg@76 | 77 |
<xsl:if test="$title and $isRoot"> |
franta-hg@76 | 78 |
<h1><xsl:value-of select="$title"/></h1> |
franta-hg@76 | 79 |
</xsl:if> |
franta-hg@83 | 80 |
|
franta-hg@83 | 81 |
<xsl:apply-templates select="h:html/h:body"/> |
franta-hg@76 | 82 |
|
franta-hg@76 | 83 |
<xsl:if test="$wwwRead or $wwwPost"> |
franta-hg@76 | 84 |
<div class="wwwLinks"> |
franta-hg@76 | 85 |
<p>Přístup přes síť www:</p> |
franta-hg@76 | 86 |
<ul> |
franta-hg@76 | 87 |
<xsl:if test="$wwwRead"><li><a href="{$wwwRead}">číst tento příspěvek</a></li></xsl:if> |
franta-hg@76 | 88 |
<xsl:if test="$wwwPost"><li><a href="{$wwwPost}">odpovědět na tento příspěvek</a></li></xsl:if> |
franta-hg@76 | 89 |
</ul> |
franta-hg@76 | 90 |
</div> |
franta-hg@76 | 91 |
</xsl:if> |
franta-hg@76 | 92 |
</body> |
franta-hg@76 | 93 |
</html> |
franta-hg@76 | 94 |
</xsl:template> |
franta-hg@76 | 95 |
|
franta-hg@76 | 96 |
|
franta-hg@76 | 97 |
<!-- Odkazy --> |
franta-hg@76 | 98 |
<xsl:template match="h:a"> |
franta-hg@94 | 99 |
<xsl:element name="a"> |
franta-hg@94 | 100 |
<xsl:if test="@href"><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute></xsl:if> |
franta-hg@94 | 101 |
<xsl:if test="@title"><xsl:attribute name="title"><xsl:value-of select="@title"/></xsl:attribute></xsl:if> |
franta-hg@94 | 102 |
<xsl:if test="@id"><xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute></xsl:if> |
franta-hg@94 | 103 |
<xsl:apply-templates select="node()"/> |
franta-hg@94 | 104 |
</xsl:element> |
franta-hg@76 | 105 |
</xsl:template> |
franta-hg@76 | 106 |
|
franta-hg@76 | 107 |
|
franta-hg@76 | 108 |
<!-- Obrázky --> |
franta-hg@76 | 109 |
<xsl:template match="h:img"> |
franta-hg@94 | 110 |
<xsl:element name="img"> |
franta-hg@94 | 111 |
<xsl:if test="@src"><xsl:attribute name="src"><xsl:value-of select="@src"/></xsl:attribute></xsl:if> |
franta-hg@94 | 112 |
<xsl:if test="@title"><xsl:attribute name="title"><xsl:value-of select="@title"/></xsl:attribute></xsl:if> |
franta-hg@94 | 113 |
<xsl:if test="@alt"><xsl:attribute name="alt"><xsl:value-of select="@alt"/></xsl:attribute></xsl:if> |
franta-hg@94 | 114 |
</xsl:element> |
franta-hg@76 | 115 |
</xsl:template> |
franta-hg@76 | 116 |
|
franta-hg@94 | 117 |
|
franta-hg@76 | 118 |
<!-- Zkratky --> |
franta-hg@76 | 119 |
<xsl:template match="h:abbr"> |
franta-hg@76 | 120 |
<abbr title="{@title}"><xsl:apply-templates/></abbr> |
franta-hg@76 | 121 |
</xsl:template> |
franta-hg@76 | 122 |
|
franta-hg@94 | 123 |
|
franta-hg@94 | 124 |
<!-- Citace --> |
franta-hg@90 | 125 |
<xsl:template match="h:blockquote[not(h:p)]"> |
franta-hg@90 | 126 |
<blockquote> |
franta-hg@90 | 127 |
<p> |
franta-hg@90 | 128 |
<xsl:copy-of select="node()"/> |
franta-hg@90 | 129 |
</p> |
franta-hg@90 | 130 |
</blockquote> |
franta-hg@90 | 131 |
</xsl:template> |
franta-hg@90 | 132 |
|
franta-hg@94 | 133 |
<!-- Tučné písmo --> |
franta-hg@94 | 134 |
<xsl:template match="h:b"> |
franta-hg@94 | 135 |
<strong> |
franta-hg@94 | 136 |
<xsl:apply-templates select="node()"/> |
franta-hg@94 | 137 |
</strong> |
franta-hg@94 | 138 |
</xsl:template> |
franta-hg@76 | 139 |
|
franta-hg@94 | 140 |
<!-- Skloněné písmo --> |
franta-hg@94 | 141 |
<xsl:template match="h:i"> |
franta-hg@94 | 142 |
<em> |
franta-hg@94 | 143 |
<xsl:apply-templates select="node()"/> |
franta-hg@94 | 144 |
</em> |
franta-hg@94 | 145 |
</xsl:template> |
franta-hg@94 | 146 |
|
franta-hg@94 | 147 |
|
franta-hg@94 | 148 |
<!-- |
franta-hg@94 | 149 |
Další povolené značky (jejich případné atributy zahodíme). |
franta-hg@94 | 150 |
Ostatní elementy odfiltrujeme (zbude z nich jen text). |
franta-hg@94 | 151 |
--> |
franta-hg@76 | 152 |
<xsl:template match="*"> |
franta-hg@76 | 153 |
<xsl:choose> |
franta-hg@76 | 154 |
<xsl:when test=" |
franta-hg@76 | 155 |
name() = 'h1' or |
franta-hg@76 | 156 |
name() = 'h2' or |
franta-hg@76 | 157 |
name() = 'h3' or |
franta-hg@76 | 158 |
name() = 'h4' or |
franta-hg@76 | 159 |
name() = 'h5' or |
franta-hg@76 | 160 |
name() = 'h6' or |
franta-hg@76 | 161 |
name() = 'p' or |
franta-hg@76 | 162 |
name() = 'div' or |
franta-hg@76 | 163 |
name() = 'br' or |
franta-hg@88 | 164 |
name() = 'hr' or |
franta-hg@76 | 165 |
name() = 'strong' or |
franta-hg@76 | 166 |
name() = 'em' or |
franta-hg@76 | 167 |
name() = 'sub' or |
franta-hg@76 | 168 |
name() = 'sup' or |
franta-hg@76 | 169 |
name() = 'del' or |
franta-hg@76 | 170 |
name() = 'ul' or |
franta-hg@76 | 171 |
name() = 'ol' or |
franta-hg@76 | 172 |
name() = 'li' or |
franta-hg@76 | 173 |
name() = 'pre' or |
franta-hg@76 | 174 |
name() = 'code' or |
franta-hg@76 | 175 |
name() = 'blockquote'"> |
franta-hg@76 | 176 |
<xsl:element name="{name()}"> |
franta-hg@94 | 177 |
<xsl:apply-templates select="node()"/> |
franta-hg@76 | 178 |
</xsl:element> |
franta-hg@76 | 179 |
</xsl:when> |
franta-hg@76 | 180 |
<xsl:otherwise> |
franta-hg@83 | 181 |
<xsl:apply-templates/> |
franta-hg@76 | 182 |
</xsl:otherwise> |
franta-hg@76 | 183 |
</xsl:choose> |
franta-hg@76 | 184 |
</xsl:template> |
franta-hg@77 | 185 |
|
franta-hg@76 | 186 |
</xsl:stylesheet> |