XSL-FO / DocBook / Konvertierung einer XML-Datei nach HTML, FO/PDF und Docbook 5.0 / XML nach FO / PDF
![]() |
![]() |
➪ Hier finden Sie ein Beispiel, um eine XML-Datei nach HTML, FO/PDF und Docbook 5.0 zu konvertieren.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="meinformat"
margin-right="15mm" margin-left="2cm"
margin-bottom="1cm" margin-top="2cm"
page-width="21cm"
page-height="297mm">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="meinformat">
<fo:flow flow-name="xsl-region-body">
<fo:block color="blue"
text-align="center">
Artikelliste2.xml nach PDF konvertiert
</fo:block>
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="Artikelliste">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Artikel">
<fo:block
page-break-before="always"
font-size="19pt"
color="violet"
text-align="center"
space-before="2cm"
space-after="1cm"
background-color="green">
<xsl:value-of select="@titel"/>
</fo:block>
<xsl:apply-templates
select="child::*[name() != 'Listing']"/>
</xsl:template>
<xsl:template match="Listing[@id]">
<fo:block text-align="center" font-size="9pt">
<xsl:text>Listing: </xsl:text>
<xsl:value-of select="@id"/>
</fo:block>
<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">
<fo:block
text-align="left"
font-family="Courier"
font-size="9pt"
color="red">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="remark">
<fo:block
space-after="5mm"
text-align="left"
font-size="6pt"
font-family="Courier"
color="black">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="top">
<fo:block
font-size="12pt"
text-align="left"
space-before="1cm"
space-after="5mm">
<xsl:value-of select="@titel"/>
</fo:block>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="utop">
<fo:block
space-before="5mm"
font-size="7pt"
text-align="justify">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="k">
<fo:inline font-style="italic">
<xsl:text> </xsl:text>
<xsl:apply-templates/>
<xsl:text> </xsl:text>
</fo:inline>
</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