Hello Charles,
thanks for taking time to solve my problem by providing an appropriate
stylesheet.
But as David Carlisle wrote in his email from 14 Apr 2005 14:31:55 the HTML
tags for bold and italic formatting inside TITLE are not embraced by "<" and
">"
characters, rather by "_&_lt_;" and "_&_gt_;" (without the "_" characters,
which I only added to avoid that my original HTML-tag embracing will be
misinterpreted by your email reader).
And exactly this made me headaches and lead me to ask the community for
help.
I followed the tips of the other contributers and do now preprocess the XML
input
file, where I substitute the HTML-tags "_&_lt_;" and "_&_gt_;" by their
equivalents "<" and ">" in a previous/first step before I apply a xsl
stylesheet like yours in a second step.
Again thanks for your help!
Best regards,
Maik
Date: Thu, 14 Apr 2005 10:24:05 -0400
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
From: cknell(_at_)onebox(_dot_)com
Subject: RE: Re: [xsl] how to translate XML with XHTML-formatted element
to FO
Message-ID: <B0036942183(_at_)securemail(_dot_)onebox(_dot_)com>
I remain puzzled over the idea that there are "escaped" HTML tags in your
input XML file. They appear as ordinary HTML tags in my email. In order to
proceed I will put this down to a different understanding of what
"escaped" means. If I have misunderstood you, please clarify the matter
further.
I have taken your input and output and written a stylesheet that will
produce the expected output. Well, almost. In your input file you have the
bold and italic tags nested in the Donald Duck entry, but they are not
nested in the desired output you posted. I will assume that this is a
typing error and go on to produce nested output as is suggested by the
input document's structure.
Given all these caveats, this stylesheet produces what I think you want.
<?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" encoding="UTF-8" />
<xsl:strip-space elements="*" />
<xsl:template match="/">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates />
</fo:flow>
</xsl:template>
<xsl:template match="BOOKS">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="BOOK">
<fo:block>
<fo:block space-before.optimum="1pt" space-after.optimum="2pt">
<xsl:apply-templates />
</fo:block>
</fo:block>
</xsl:template>
<xsl:template match="AUTHOR">
<fo:block>Author: <xsl:value-of select="." /></fo:block>
</xsl:template>
<xsl:template match="PRICE">
<fo:block>Price : US$ <xsl:value-of select="." /></fo:block>
</xsl:template>
<xsl:template match="TITLE">
<xsl:choose>
<xsl:when test="child::*">
<fo:block>Title : <xsl:apply-templates /></fo:block>
</xsl:when>
<xsl:otherwise>
<fo:block>Title : <xsl:value-of select="." /></fo:block>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="b">
<xsl:choose>
<xsl:when test="child::*">
<fo:inline font-weight="bold"><xsl:apply-templates /></fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline font-weight="bold"><xsl:value-of select="."
/></fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="i">
<xsl:choose>
<xsl:when test="child::*">
<fo:inline font-style="italic"><xsl:apply-templates /></fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline font-weight="italic"><xsl:value-of select="."
/></fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--