XSL-FO / DocBook / Konvertierung einer XML-Datei nach HTML, FO/PDF und Docbook 5.0 / XML nach HTML
![]() |
![]() |
➪ Hier finden Sie ein Beispiel, um eine XML-Datei nach HTML, FO/PDF und Docbook 5.0 zu konvertieren.
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:character-map name="html">
<xsl:output-character character="ä" string="ä"/>
<xsl:output-character character="ö" string="ö"/>
<xsl:output-character character="ü" string="ü"/>
<xsl:output-character character="Ä" string="Ä"/>
<xsl:output-character character="Ö" string="Ö"/>
<xsl:output-character character="Ü" string="Ü"/>
<xsl:output-character character="ß" string="ß"/>
</xsl:character-map>
<xsl:output method="html" encoding="ISO-8859-1"
use-character-maps="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="Artikel">
<h1>
<xsl:value-of select="@titel"/>
</h1>
<xsl:apply-templates
select="child::*[name() != 'Listing']"/>
</xsl:template>
<xsl:template match="Listing[@id]">
<h5>
<xsl:text>Listing: </xsl:text>
<xsl:value-of select="@id"/>
</h5>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Listing[@ref]">
<xsl:variable name="vref" select="@ref"/>
<xsl:apply-templates
select="../../Listing[@id = $vref]"/>
</xsl:template>
<xsl:template match="code">
<code>
<xsl:apply-templates/>
</code>
</xsl:template>
<xsl:template match="remark">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="top">
<h3>
<xsl:value-of select="@titel"/>
</h3>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="utop">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="k">
<i>
<xsl:text> </xsl:text>
<xsl:apply-templates/>
<xsl:text> </xsl:text>
</i>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of
select="normalize-space(.)"/>
</xsl:template>
</xsl:stylesheet>
wg / 25. Oktober 2020
Fragen? Anmerkungen? Tipps?
Bitte nehmen Sie Kontakt zu mir auf.
V.i.S.d.P.: Wilfried Grupe * Klus 6 * 37643 Negenborn
☎ 0151. 750 360 61 * eMail: info10@wilfried-grupe.de