001 <?xml version="1.0" encoding="UTF-8"?> 002 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 003 xmlns:fn="http://www.w3.org/2005/xpath-functions" 004 xmlns:xs="http://www.w3.org/2001/XMLSchema" 005 xmlns:tm="http://www.datenverdrahten.de/tm" 006 xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" 007 xmlns:dc="http://purl.org/dc/elements/1.1/" 008 xmlns:dcterms="http://purl.org/dc/terms/" 009 xmlns:dcmitype="http://purl.org/dc/dcmitype/" 010 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 011 xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" 012 xmlns:o="urn:schemas-microsoft-com:office:office" 013 xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" 014 xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" 015 xmlns:v="urn:schemas-microsoft-com:vml" 016 xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" 017 xmlns:w10="urn:schemas-microsoft-com:office:word" 018 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" 019 xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" 020 exclude-result-prefixes="fn tm xs"> 021 022 <!-- Author: T. Meinike 2012 / docx.xsl - Ausführung über run.cmd 023 DOCX-Anpassung zum Tutorial http://www.tekom.de/upload/3383/OTS11_Meinike.pdf --> 024 025 <!-- Globale Vorgaben - variable Dateinamen, Pfade und Vorgabewerte (Zeitstempel sowie px-in-cm-Umrechnungsfaktor) --> 026 <xsl:variable name="docxdir" select="'ausgabe'"/> 027 <xsl:variable name="corefile" select="'docProps/core.xml'"/> 028 <xsl:variable name="docufile" select="'word/document.xml'"/> 029 <xsl:variable name="relsfile" select="'word/_rels/document.xml.rels'"/> 030 <xsl:variable name="crea_mod" select="format-dateTime(fn:adjust-dateTime-to-timezone(fn:current-dateTime(), xs:dayTimeDuration('PT0H')), '[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]Z')"/> 031 <xsl:variable name="fktpx2cm" select="45"/><!-- 300px / 45 = 6,67cm --> 032 033 <!-- externe Funktionen einbinden --> 034 <xsl:include href="../FktLib/library.xsl"/> 035 036 <!-- Ausgabeformat zur Dateierzeugung über xsl:result-document --> 037 <xsl:output name="stdxml" method="xml" version="1.0" encoding="UTF-8" standalone="yes" indent="yes" media-type="text/xml"/> 038 039 040 <!-- Basis-Template --> 041 <xsl:template match="diskografie"> 042 043 <!-- DOCX-Struktur: core.xml --> 044 <xsl:result-document href="{$docxdir}/{$corefile}" format="stdxml"> 045 046 <cp:coreProperties 047 xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" 048 xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" 049 xmlns:dcmitype="http://purl.org/dc/dcmitype/" 050 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 051 052 <dc:title><xsl:value-of select="fn:concat('Diskografie | ', @bandname)"/></dc:title> 053 <dc:subject>Katalog</dc:subject> 054 <dc:creator>T. Meinike 2012 / docx.xsl</dc:creator> 055 <cp:keywords>XML, XSLT, DOCX, OOXML</cp:keywords> 056 <dc:description>Beispiel zu XML + XSLT → DOCX</dc:description> 057 <cp:lastModifiedBy>docx.xsl</cp:lastModifiedBy> 058 <cp:revision>1</cp:revision> 059 <dcterms:created xsi:type="dcterms:W3CDTF"><xsl:value-of select="$crea_mod"/></dcterms:created> 060 <dcterms:modified xsi:type="dcterms:W3CDTF"><xsl:value-of select="$crea_mod"/></dcterms:modified> 061 </cp:coreProperties> 062 063 </xsl:result-document> 064 065 066 <!-- DOCX-Struktur: document.xml.rels --> 067 <xsl:result-document href="{$docxdir}/{$relsfile}" format="stdxml"> 068 069 <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> 070 071 <!-- feste rId-Strukturvorgaben --> 072 <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/> 073 <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/> 074 <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" Target="webSettings.xml"/> 075 <Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml"/> 076 <Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/> 077 <Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Target="numbering.xml"/> 078 <Relationship Id="rId7" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes" Target="endnotes.xml"/> 079 <Relationship Id="rId8" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes" Target="footnotes.xml"/> 080 <Relationship Id="rId9" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" Target="footer.xml"/> 081 082 <!-- ab rId10 folgen die Bilder in media mit Sterngrafik als Vorgabe --> 083 <Relationship Id="rId10" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/stern.gif"/> 084 085 <!-- zusätzliches Katalogcover (600x800px) als rId11 hinterlegt --> 086 <Relationship Id="rId11" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/katalogcover.jpg"/> 087 088 <!-- Coverbilder als variable Vorgabe ab rId12--> 089 <xsl:for-each select="werk"> 090 <xsl:sort select="@jahr" order="ascending" data-type="number"/> 091 <Relationship Id="rId{fn:position() + 11}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/{coverbild}"/> 092 </xsl:for-each> 093 094 <!-- ab rId100 folgen die externen Referenz-URLs --> 095 <xsl:for-each select="referenzen/referenz"> 096 <xsl:if test="@url"> 097 <Relationship Id="rId{fn:position() + 99}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="{@url}" TargetMode="External"/> 098 </xsl:if> 099 </xsl:for-each> 100 101 </Relationships> 102 103 </xsl:result-document> 104 105 106 <!-- Inhaltsdokument: document.xml --> 107 <xsl:result-document href="{$docxdir}/{$docufile}" format="stdxml"> 108 109 <w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" 110 xmlns:o="urn:schemas-microsoft-com:office:office" 111 xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" 112 xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" 113 xmlns:v="urn:schemas-microsoft-com:vml" 114 xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" 115 xmlns:w10="urn:schemas-microsoft-com:office:word" 116 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" 117 xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"> 118 119 <w:body> 120 121 <!-- Hauptüberschrift --> 122 <w:p w:rsidR="00674E1A" w:rsidRDefault="00674E1A" w:rsidP="000220E4"> 123 <w:pPr><w:pStyle w:val="Heading1"/></w:pPr> 124 <w:r> 125 <w:rPr><w:color w:val="990000"/></w:rPr> 126 <w:t><xsl:value-of select="fn:concat('Diskografie / ', @bandname)"/></w:t> 127 </w:r> 128 </w:p> 129 130 <w:p w:rsidR="00674E1A" w:rsidRDefault="00674E1A" w:rsidP="000220E4"> 131 <w:r> 132 <w:pict> 133 <v:shape style="width:8cm;height:10.67cm"> 134 <v:imagedata r:id="rId11" o:title="Coverbild"/> 135 </v:shape> 136 </w:pict> 137 </w:r> 138 </w:p> 139 140 <xsl:if test="fn:string-length(bandinfo) > 0 or referenzen"> 141 <!-- optionalen Bandinfotext ausgeben --> 142 <xsl:apply-templates select="bandinfo[fn:string-length(.) > 0]"/> 143 144 <!-- optionale Referenzen verarbeiten --> 145 <xsl:apply-templates select="referenzen"/> 146 147 <!-- werk-Verarbeitung --> 148 <xsl:apply-templates select="werk"> 149 <xsl:sort select="@jahr" order="ascending" data-type="number"/> 150 </xsl:apply-templates> 151 </xsl:if> 152 153 <!-- Seitenvorgaben einschließlich Footer für Seitenzahl --> 154 <w:sectPr w:rsidR="00674E1A" w:rsidSect="00044EE3"> 155 <w:footerReference w:type="even" r:id="rId9"/> 156 <w:footerReference w:type="default" r:id="rId9"/> 157 <w:pgSz w:w="11906" w:h="16838"/> 158 <w:pgMar w:top="1134" w:right="1418" w:bottom="567" w:left="1418" w:header="709" w:footer="709" w:gutter="0"/> 159 <w:cols w:space="708"/> 160 <w:docGrid w:linePitch="360"/> 161 </w:sectPr> 162 163 </w:body> 164 165 </w:document> 166 167 </xsl:result-document> 168 169 </xsl:template> 170 171 172 <!-- werk-Inhalte seitenweise ausgeben --> 173 <xsl:template match="werk"> 174 175 <!-- Wername als Überschrift ausgeben --> 176 <w:p w:rsidR="00674E1A" w:rsidRPr="000220E4" w:rsidRDefault="00674E1A" w:rsidP="000220E4"> 177 <w:pPr><w:pStyle w:val="Heading2"/></w:pPr> 178 <w:r> 179 <w:rPr><w:color w:val="006666"/></w:rPr> 180 <!-- Seitenumbruch --> 181 <w:br w:type="page"/> 182 <w:t>[<xsl:value-of select="fn:position()"/>] <xsl:value-of select="werkname"/></w:t> 183 </w:r> 184 </w:p> 185 186 <!-- Erscheinungsjahr sowie optionalen Typ und optionale Bewertungssterne ausgeben --> 187 <w:p w:rsidR="00674E1A" w:rsidRDefault="00674E1A" w:rsidP="000220E4"> 188 <w:pPr><w:pStyle w:val="Heading3"/></w:pPr> 189 <w:r> 190 <w:rPr><w:color w:val="6699FF"/></w:rPr> 191 <w:t> 192 <xsl:value-of select="@jahr"/> 193 <xsl:if test="fn:string-length(@typ) > 0"> 194 <xsl:value-of select="fn:concat(' (', @typ, ') ')"/> 195 </xsl:if> 196 </w:t> 197 </w:r> 198 199 <!-- n Sterne --> 200 <xsl:if test="@bewertung >= 1"> 201 <xsl:for-each select="1 to @bewertung"> 202 <w:r> 203 <w:pict> 204 <v:shape style="width:16px;height:16px"> 205 <v:imagedata r:id="rId10" o:title="*"/> 206 </v:shape> 207 </w:pict> 208 </w:r> 209 </xsl:for-each> 210 </xsl:if> 211 </w:p> 212 213 <!-- optionales Coverbild ausgeben --> 214 <xsl:apply-templates select="coverbild[fn:string-length(.) > 0]"> 215 <xsl:with-param name="werkpos" select="fn:position()"/> 216 </xsl:apply-templates> 217 218 <!-- Titelliste ausgeben --> 219 <xsl:apply-templates select="titelliste"> 220 <xsl:with-param name="werkpos" select="fn:position()"/> 221 </xsl:apply-templates> 222 223 <!-- Gesamtzeit über externe Funktion ausgeben, sofern @spielzeit bei allen titel-Elementen vorhanden --> 224 <xsl:if test="fn:count(titelliste/titel) = fn:count(titelliste/titel/@spielzeit)"> 225 <xsl:variable name="spielzeiten" select="for $t in titelliste/titel return $t/@spielzeit"/> 226 227 <w:p w:rsidR="00674E1A" w:rsidRDefault="00674E1A"> 228 <w:r> 229 <w:br/> 230 <w:t>Gesamtzeit: <xsl:value-of select="tm:gesamtzeit($spielzeiten)"/></w:t> 231 </w:r> 232 </w:p> 233 </xsl:if> 234 235 <!-- optionalen Kommentar ausgeben --> 236 <xsl:apply-templates select="kommentar[fn:string-length(.) > 0]"/> 237 238 <!-- Leerabsatz am aktuellen Seitenende --> 239 <w:p w:rsidR="00674E1A" w:rsidRDefault="00674E1A"/> 240 241 </xsl:template> 242 243 244 <!-- Template für die bandinfo-Verarbeitung --> 245 <xsl:template match="bandinfo"> 246 247 <!-- Zwischenüberschrift / Einführung --> 248 <w:p w:rsidR="00674E1A" w:rsidRPr="000220E4" w:rsidRDefault="00674E1A" w:rsidP="000220E4"> 249 <w:pPr><w:pStyle w:val="Heading2"/></w:pPr> 250 <w:r> 251 <w:rPr><w:color w:val="006666"/></w:rPr> 252 <w:t>Einführung</w:t> 253 </w:r> 254 </w:p> 255 256 <!-- Infotext --> 257 <w:p w:rsidR="00674E1A" w:rsidRDefault="00674E1A"> 258 <w:r> 259 <w:rPr><w:b/></w:rPr> 260 <w:t><xsl:value-of select="."/></w:t> 261 </w:r> 262 </w:p> 263 264 </xsl:template> 265 266 267 <!-- Template für die referenzen-Verarbeitung --> 268 <xsl:template match="referenzen"> 269 270 <!-- Zwischenüberschrift / Referenzen --> 271 <w:p w:rsidR="00674E1A" w:rsidRPr="000220E4" w:rsidRDefault="00674E1A" w:rsidP="000220E4"> 272 <w:pPr><w:pStyle w:val="Heading2"/></w:pPr> 273 <w:r> 274 <w:rPr><w:color w:val="006666"/></w:rPr> 275 <w:t>Referenzen</w:t> 276 </w:r> 277 </w:p> 278 279 <xsl:apply-templates select="referenz"/> 280 281 </xsl:template> 282 283 284 <!-- Template für die referenz-Verarbeitung als ungeordneter Listeneintrag mit/ohne Links --> 285 <xsl:template match="referenz"> 286 287 <w:p w:rsidR="00674E1A" w:rsidRDefault="00674E1A" w:rsidP="000220E4"> 288 <w:pPr> 289 <w:numPr><w:ilvl w:val="0"/><w:numId w:val="4"/></w:numPr> 290 </w:pPr> 291 292 <xsl:choose> 293 <xsl:when test="fn:string-length(@url) > 0"> 294 <w:hyperlink r:id="rId{fn:position() + 99}" w:history="1"> 295 <w:r w:rsidRPr="00141F38"> 296 <w:rPr><w:rStyle w:val="Hyperlink"/></w:rPr> 297 <w:t><xsl:value-of select="."/></w:t> 298 </w:r> 299 </w:hyperlink> 300 </xsl:when> 301 <xsl:otherwise> 302 <w:r> 303 <w:t><xsl:value-of select="."/></w:t> 304 </w:r> 305 </xsl:otherwise> 306 </xsl:choose> 307 </w:p> 308 309 </xsl:template> 310 311 312 <!-- Template für die coverbild-Verarbeitung --> 313 <xsl:template match="coverbild"> 314 315 <xsl:param name="werkpos"/> 316 317 <w:p w:rsidR="00674E1A" w:rsidRDefault="00674E1A" w:rsidP="000220E4"> 318 <w:r> 319 <w:pict> 320 <v:shape style="width:{fn:round-half-to-even(@breite div $fktpx2cm, 2)}cm;height:{fn:round-half-to-even(@hoehe div $fktpx2cm, 2)}cm"> 321 <v:imagedata r:id="rId{$werkpos + 11}" o:title="Coverbild"/> 322 </v:shape> 323 </w:pict> 324 <w:br/> 325 </w:r> 326 </w:p> 327 328 </xsl:template> 329 330 331 <!-- Template für die titelliste-Verarbeitung --> 332 <xsl:template match="titelliste"> 333 334 <xsl:param name="werkpos"/> 335 336 <xsl:apply-templates select="titel"> 337 <xsl:with-param name="werkpos" select="$werkpos"/> 338 </xsl:apply-templates> 339 340 </xsl:template> 341 342 343 <!-- Template für die titel-Verarbeitung als geordneter Listeneintrag --> 344 <xsl:template match="titel"> 345 346 <xsl:param name="werkpos"/> 347 348 <w:p w:rsidR="00674E1A" w:rsidRDefault="00674E1A" w:rsidP="000220E4"> 349 <!-- w:val beginnt hier ab 11, da kleinere w:val-Werte bereits in numbering.xml belegt sind - List-Bullets (w:val="4"), siehe numbering.xml --> 350 <w:pPr><w:numPr><w:ilvl w:val="0"/><w:numId w:val="{$werkpos + 10}"/></w:numPr></w:pPr> 351 <w:r> 352 <w:t> 353 <xsl:value-of select="."/> 354 <xsl:if test="fn:string-length(@spielzeit) > 0"> 355 <xsl:value-of select="fn:concat(' (', @spielzeit, ')')"/> 356 </xsl:if> 357 </w:t> 358 </w:r> 359 </w:p> 360 361 </xsl:template> 362 363 364 <!-- Template für die kommentar-Verarbeitung --> 365 <xsl:template match="kommentar"> 366 367 <w:p w:rsidR="00674E1A" w:rsidRDefault="00674E1A"> 368 <w:r> 369 <w:br/> 370 <w:t xml:space="preserve">Kommentar: </w:t> 371 </w:r> 372 <w:r w:rsidRPr="003B2A33"> 373 <w:rPr><w:i/></w:rPr> 374 <w:t><xsl:value-of select="."/></w:t> 375 </w:r> 376 </w:p> 377 378 </xsl:template> 379 380 </xsl:stylesheet>
Code formatiert mit »Highlight 3.7«