| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
|---|
| 2 |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
|---|
| 3 |
<xsl:output method="html" encoding="UTF-8" indent="yes"/> |
|---|
| 4 |
|
|---|
| 5 |
<!-- Variablen --> |
|---|
| 6 |
<xsl:variable name="bezeichner_bildbeschriftung">Abbildung</xsl:variable> |
|---|
| 7 |
<xsl:variable name="bezeichner_tabellenbeschriftung">Tabelle</xsl:variable> |
|---|
| 8 |
<xsl:variable name="quelle_tabellenbeschriftung">title</xsl:variable> |
|---|
| 9 |
|
|---|
| 10 |
<!-- Einstiegspunkt --> |
|---|
| 11 |
<xsl:template match="/"> |
|---|
| 12 |
<html> |
|---|
| 13 |
<head> |
|---|
| 14 |
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/> |
|---|
| 15 |
<meta name="Generator" content="Microsoft Word 11 (filtered)"/> |
|---|
| 16 |
<xsl:text disable-output-escaping="yes"><![CDATA[<style> |
|---|
| 17 |
<!-- |
|---|
| 18 |
p.MsoNormal, li.MsoNormal, div.MsoNormal |
|---|
| 19 |
{margin:0cm;} |
|---|
| 20 |
--> |
|---|
| 21 |
</style>]]></xsl:text> |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
<title></title> |
|---|
| 28 |
</head> |
|---|
| 29 |
<body> |
|---|
| 30 |
<!-- Beginn der eigentlichen Verarbeitung --> |
|---|
| 31 |
<!-- Wenn aus der gesamten Wiki-Seite extrahiert werden soll, dann muss die apply-templates-Anweisung folgende Eigenschaft beinhalten: select="//div[@id='content']" --> |
|---|
| 32 |
<xsl:apply-templates /> |
|---|
| 33 |
</body> |
|---|
| 34 |
</html> |
|---|
| 35 |
</xsl:template> |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
<!-- Ueberschriften --> |
|---|
| 39 |
<xsl:template match="h1|h2|h3|h4|h5|h6|h7"> |
|---|
| 40 |
<xsl:element name = "{name()}" > |
|---|
| 41 |
<a name="{@id}"> |
|---|
| 42 |
<xsl:value-of select="normalize-space(text())"/> |
|---|
| 43 |
</a> |
|---|
| 44 |
</xsl:element> |
|---|
| 45 |
</xsl:template> |
|---|
| 46 |
|
|---|
| 47 |
<!-- Formatierungen --> |
|---|
| 48 |
<xsl:template match="strong|b|i|u"> |
|---|
| 49 |
<xsl:element name = "{name()}" > |
|---|
| 50 |
<!--<xsl:value-of select="normalize-space(text())"/>--> |
|---|
| 51 |
<xsl:apply-templates/> |
|---|
| 52 |
</xsl:element> |
|---|
| 53 |
<xsl:text> </xsl:text> |
|---|
| 54 |
</xsl:template> |
|---|
| 55 |
|
|---|
| 56 |
<!-- Bilder und Bildbeschriftungen --> |
|---|
| 57 |
<xsl:template match="img"> |
|---|
| 58 |
<img src="{@src}" alt="{@alt}"/> |
|---|
| 59 |
<p class="MsoCaption"> |
|---|
| 60 |
<xsl:value-of select="$bezeichner_bildbeschriftung"/> |
|---|
| 61 |
<!-- Alles hier folgende ist Word-interner Code, der die Abbildungsnummer als Feld markiert --> |
|---|
| 62 |
<xsl:text disable-output-escaping="yes"><![CDATA[ <!--[if supportFields]><span style='mso-element:field-begin'></span><span style='mso-spacerun:yes'>Â </span>SEQ ]]></xsl:text> |
|---|
| 63 |
<xsl:value-of select="$bezeichner_bildbeschriftung"/> |
|---|
| 64 |
<xsl:text disable-output-escaping="yes"><![CDATA[ \* ARABIC <span style='mso-element:field-separator'></span><![endif]--><span style='mso-no-proof:yes'>]]></xsl:text> |
|---|
| 65 |
<xsl:number count="img"/> |
|---|
| 66 |
<xsl:text disable-output-escaping="yes"><![CDATA[</span><!--[if supportFields]><span style='mso-element:field-end'></span><![endif]-->: ]]></xsl:text> |
|---|
| 67 |
<!-- Bildbezeichnung, aus title-Tag lesen --> |
|---|
| 68 |
<xsl:value-of select="@title"/> |
|---|
| 69 |
</p> |
|---|
| 70 |
</xsl:template> |
|---|
| 71 |
|
|---|
| 72 |
<!-- Tabellendefinition --> |
|---|
| 73 |
<xsl:template match="table"> |
|---|
| 74 |
<table> |
|---|
| 75 |
<xsl:apply-templates/> |
|---|
| 76 |
</table> |
|---|
| 77 |
<!-- Tabellenbeschriftung --> |
|---|
| 78 |
<xsl:if test="substring-before(tbody/tr[last()]/td[1],':')=$quelle_tabellenbeschriftung or substring-before(tr[last()]/td[1],':')=$quelle_tabellenbeschriftung"> |
|---|
| 79 |
<p class="MsoCaption"> |
|---|
| 80 |
<xsl:value-of select="$bezeichner_tabellenbeschriftung"/> |
|---|
| 81 |
<!-- Markierung als Feld --> |
|---|
| 82 |
<xsl:text disable-output-escaping="yes"><![CDATA[ <!--[if supportFields]><span style='mso-element:field-begin'></span><span style='mso-spacerun:yes'>Â </span>SEQ ]]></xsl:text> |
|---|
| 83 |
<xsl:value-of select="$bezeichner_tabellenbeschriftung"/> |
|---|
| 84 |
<xsl:text disable-output-escaping="yes"><![CDATA[ \* ARABIC <span style='mso-element:field-separator'></span><![endif]--><span style='mso-no-proof:yes'>]]></xsl:text> |
|---|
| 85 |
<xsl:number count="table"/> |
|---|
| 86 |
<xsl:text disable-output-escaping="yes"><![CDATA[</span><!--[if supportFields]><span style='mso-element:field-end'></span><![endif]-->: ]]></xsl:text> |
|---|
| 87 |
<!-- Bezeichnung --> |
|---|
| 88 |
<xsl:if test="tbody"> |
|---|
| 89 |
<xsl:value-of select="substring-after(tbody/tr[last()]/td[1],':')"/> |
|---|
| 90 |
</xsl:if> |
|---|
| 91 |
<xsl:if test="tr"> |
|---|
| 92 |
<xsl:value-of select="substring-after(tr[last()]/td[1],':')"/> |
|---|
| 93 |
</xsl:if> |
|---|
| 94 |
|
|---|
| 95 |
</p> |
|---|
| 96 |
</xsl:if> |
|---|
| 97 |
|
|---|
| 98 |
</xsl:template> |
|---|
| 99 |
|
|---|
| 100 |
<!-- Tabellenzeilen --> |
|---|
| 101 |
<xsl:template match="tr"> |
|---|
| 102 |
<!-- Die Tabellenbeschriftung nicht nochmal als separate Tabellenzeile ausgeben --> |
|---|
| 103 |
<xsl:if test="td[substring-before(text()[1],':')!=$quelle_tabellenbeschriftung]"> |
|---|
| 104 |
<tr> |
|---|
| 105 |
<xsl:apply-templates/> |
|---|
| 106 |
</tr> |
|---|
| 107 |
</xsl:if> |
|---|
| 108 |
</xsl:template> |
|---|
| 109 |
|
|---|
| 110 |
<!-- Tabellenspalten --> |
|---|
| 111 |
<xsl:template match="td"> |
|---|
| 112 |
<xsl:element name = "{name()}" > |
|---|
| 113 |
<xsl:apply-templates/> |
|---|
| 114 |
<!-- Leere Tabellenzellen mit einem Leerzeichen fuellen, damit sie dargestellt werden --> |
|---|
| 115 |
<xsl:if test="not(string(.))"> |
|---|
| 116 |
  |
|---|
| 117 |
</xsl:if> |
|---|
| 118 |
</xsl:element> |
|---|
| 119 |
</xsl:template> |
|---|
| 120 |
|
|---|
| 121 |
<!-- Absatz --> |
|---|
| 122 |
<xsl:template match="p"> |
|---|
| 123 |
<!-- MsoNormal bedeutet Formatvorlage "Standard" --> |
|---|
| 124 |
<p class="MsoNormal"> |
|---|
| 125 |
<xsl:apply-templates/> |
|---|
| 126 |
</p> |
|---|
| 127 |
</xsl:template> |
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
<!-- Listen mit/ohne Nummerierung --> |
|---|
| 131 |
<xsl:template match="ul|ol"> |
|---|
| 132 |
<xsl:element name="{name()}"> |
|---|
| 133 |
<xsl:apply-templates/> |
|---|
| 134 |
</xsl:element> |
|---|
| 135 |
</xsl:template> |
|---|
| 136 |
|
|---|
| 137 |
<!-- Listenelemente --> |
|---|
| 138 |
<xsl:template match="li"> |
|---|
| 139 |
<li class="MsoNormal"> |
|---|
| 140 |
<xsl:apply-templates/> |
|---|
| 141 |
</li> |
|---|
| 142 |
</xsl:template> |
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
<!-- praeformatierter Text --> |
|---|
| 146 |
<xsl:template match="tt"> |
|---|
| 147 |
<tt><xsl:apply-templates/></tt> |
|---|
| 148 |
</xsl:template> |
|---|
| 149 |
|
|---|
| 150 |
<xsl:template match="pre"> |
|---|
| 151 |
<xsl:variable name="pre_string"> |
|---|
| 152 |
<xsl:call-template name="replace-string"> <!-- imported template --> |
|---|
| 153 |
<xsl:with-param name="text" select="."/> |
|---|
| 154 |
<xsl:with-param name="replace" select="'a'"/> |
|---|
| 155 |
<xsl:with-param name="with" select="'a'"/> |
|---|
| 156 |
</xsl:call-template> |
|---|
| 157 |
</xsl:variable> |
|---|
| 158 |
<pre> |
|---|
| 159 |
<xsl:value-of select="$pre_string"/> |
|---|
| 160 |
</pre> |
|---|
| 161 |
</xsl:template> |
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
<!-- blockquotes: Werden um die Ausgabe von IncludeMacros herum gelegt --> |
|---|
| 165 |
<xsl:template match="blockquote"> |
|---|
| 166 |
<!-- nichts tun, einfach ueberspringen --> |
|---|
| 167 |
<xsl:apply-templates/> |
|---|
| 168 |
</xsl:template> |
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
<!-- Links --> |
|---|
| 172 |
<xsl:template match="a"> |
|---|
| 173 |
<!-- Fuer interne Referenzen: Links in Text konvertieren --> |
|---|
| 174 |
<!-- normale Wiki-Links --> |
|---|
| 175 |
<xsl:if test="@class='wiki'"> |
|---|
| 176 |
<xsl:apply-templates/> |
|---|
| 177 |
</xsl:if> |
|---|
| 178 |
<!-- fehlende Wiki-Links --> |
|---|
| 179 |
<xsl:if test="@class='missing wiki'"> |
|---|
| 180 |
<xsl:apply-templates /> |
|---|
| 181 |
</xsl:if> |
|---|
| 182 |
<!-- Links ins SVN --> |
|---|
| 183 |
<xsl:if test="@class='source'"> |
|---|
| 184 |
<xsl:apply-templates /> |
|---|
| 185 |
</xsl:if> |
|---|
| 186 |
|
|---|
| 187 |
<!-- Externe Links werden ausgeschrieben --> |
|---|
| 188 |
<xsl:if test="@class='ext-link'"> |
|---|
| 189 |
<a href="{@href}"> |
|---|
| 190 |
<xsl:value-of select="@href"/> |
|---|
| 191 |
</a> |
|---|
| 192 |
</xsl:if> |
|---|
| 193 |
|
|---|
| 194 |
<!-- Bilder sind zulaessig --> |
|---|
| 195 |
<xsl:if test="img"> |
|---|
| 196 |
<xsl:apply-templates/> |
|---|
| 197 |
</xsl:if> |
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
</xsl:template> |
|---|
| 201 |
|
|---|
| 202 |
<!-- string replacement function http://www.dpawson.co.uk/xsl/sect2/replace.html#d9550e61 --> |
|---|
| 203 |
<xsl:template name="replace-string"> |
|---|
| 204 |
<xsl:param name="text"/> |
|---|
| 205 |
<xsl:param name="replace"/> |
|---|
| 206 |
<xsl:param name="with"/> |
|---|
| 207 |
<xsl:choose> |
|---|
| 208 |
<xsl:when test="contains($text,$replace)"> |
|---|
| 209 |
<xsl:value-of select="substring-before($text,$replace)"/> |
|---|
| 210 |
<xsl:value-of select="$with"/> |
|---|
| 211 |
<xsl:call-template name="replace-string"> |
|---|
| 212 |
<xsl:with-param name="text" |
|---|
| 213 |
select="substring-after($text,$replace)"/> |
|---|
| 214 |
<xsl:with-param name="replace" select="$replace"/> |
|---|
| 215 |
<xsl:with-param name="with" select="$with"/> |
|---|
| 216 |
</xsl:call-template> |
|---|
| 217 |
</xsl:when> |
|---|
| 218 |
<xsl:otherwise> |
|---|
| 219 |
<xsl:value-of select="$text"/> |
|---|
| 220 |
</xsl:otherwise> |
|---|
| 221 |
</xsl:choose> |
|---|
| 222 |
</xsl:template> |
|---|
| 223 |
|
|---|
| 224 |
</xsl:stylesheet> |
|---|