Hi,
I have the following xml that I want to format in the obvious way with xsl:fo.
<?xml version="1.0" encoding="UTF-8"?>
<main>
<body>
<p>
normal normal <b>bold bold <i>bold-italic</i> bold bold<sub>3</sub> </b>
normal<sup>5</sup> normal
</p>
</body>
</main>
Currently my xsl looks like shown below. In it I select all text() nodes within
a paragraph and
then check for the combinations of attributes that hold. This worked OK for
bold and italic, but
when more attributes are used, I get overwhelmed by the combinations. So what
is the clever way
to do this?
Thanks a lot.
Erwin
<<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="/main/body">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="DINA4"
page-height="297mm"
page-width="210mm"
margin-top="25.0mm"
margin-bottom="25.0mm"
margin-left="25.0mm"
margin-right="25.0mm">
<fo:region-body/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="master-sequence">
<fo:repeatable-page-master-reference master-reference="DINA4"/>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="master-sequence">
<fo:flow flow-name="xsl-region-body">
<xsl:for-each select="//p">
<fo:block font-family="Times-Roman" space-before="10pt">
<xsl:for-each select=".//text()">
<xsl:choose>
<xsl:when test="ancestor::i and ancestor::b">
<fo:inline font-style="oblique" font-weight="bold"
space-after="8pt" color="green">
<xsl:value-of select="."/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor::i and not(ancestor::b)">
<fo:inline font-style="oblique" space-after="8pt"
color="cyan">
<xsl:value-of select="."/>
</fo:inline>
</xsl:when>
<xsl:when test="not(ancestor::i) and ancestor::b">
<fo:inline font-weight="bold" space-after="8pt"
color="magenta">
<xsl:value-of select="."/>
</fo:inline>
</xsl:when>
<xsl:when test="not(ancestor::i) and not(ancestor::b)">
<fo:inline space-after="8pt" color="black">
<xsl:value-of select="."/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor-or-self::sub">
<fo:inline font-family="Times-Roman" font-size="8pt"
vertical-align="sub" color="red">
<xsl:value-of select="."/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor-or-self::sup">
<fo:inline font-family="Times-Roman" font-size="8pt"
vertical-align="super">
<xsl:value-of select="."/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</fo:block>
</xsl:for-each>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
..............................
Erwin Kloeck
Produktentwicklung
Oestreicher + Wagner
Medientechnik GmbH
Frankenthaler Strasse 20
D-81539 Muenchen
Fon +49 (0)89-68961 216
Fax +49 (0)89-68961 271
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list