RE: [xsl] Problem with embeded XHTML in an XML file and transformation to XSL:FO

Subject: RE: [xsl] Problem with embeded XHTML in an XML file and transformation to XSL:FO
From: Luuk Jansen <subscribe@xxxxxxxxxxxxxxxxx>
Date: Sat, 12 Aug 2006 15:12:16 +0100
Maybe I should rephrase, how do I:
The biggest problem is that I don't know how to do it. 
The output I get is not what I want (it appears a well formed HTML in
the document). The XML says that it is XHTML, but the problem is that
the symbols (like >) are put in unicode.

I use the following style sheet:
___
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright 2006 ATFM Solutions, Ireland
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fo="http://www.w3.org/1999/XSL/Format";
exclude-result-prefixes="fo">
  <xsl:import href="./xsl/xhtml2fo.xsl" />
  <xsl:output method="xml" version="1.0" omit-xml-declaration="no"
indent="yes"/>
  <xsl:output cdata-section-elements="Content" />
  <!-- ========================= -->
  <!-- root element: Section-->
  <!-- ========================= -->
  <xsl:template match="Sections">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
      <fo:layout-master-set>
        <fo:simple-page-master master-name="simpleA4"
page-height="29.7cm" page-width="21cm" margin-top="2cm"
margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      
      <fo:page-sequence master-reference="simpleA4">     
        <fo:flow flow-name="xsl-region-body">
			<xsl:apply-templates select="Section" />
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>

  <xsl:template match="Section">
			<fo:block font-size="16pt" font-weight="bold" space-after="5mm"
text-align-last="center" color="#8686cf">
				<xsl:value-of select="Title"/>
		  	</fo:block>
        	<xsl:apply-templates select=".//Content" />
      	 
  </xsl:template>  
 
  <xsl:template match="Content">      
	        <xsl:if test=". != ''">
	        	<fo:block space-after="10mm">
		      		<xsl:apply-imports />		
	           	</fo:block>
           	</xsl:if>
  </xsl:template>
     
</xsl:stylesheet>
___

The XML file is as follows:
___

<?xml version="1.0" encoding="UTF-8"?>
<Sections>
<Section>
<Title>Technical Summary</Title>
<IE.SFI.4400>
	<Content Version="1.0"
type="XHTML">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p
class="MsoNormal" style="margin-top: 6pt; text-align: justify;
text-indent: 21.25pt; font-family: times new roman;"&gt;&lt;font
size="3"&gt;&lt;span style="font-size: 12pt;"&gt;

&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class="MsoNormal" style="margin-top: 6pt; text-align: justify;
text-indent: 21.25pt; font-family: times new roman;"&gt;&lt;font
size="3"&gt;&lt;span lang="EN-GB" style="font-size: 12pt;"&gt; bla bla
bla &amp;#945;2-bla bla bla &amp;#945;2-bla bla
bla.&lt;/span&gt;&lt;span style="font-size:
12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class="MsoNormal" style="margin-top: 6pt; text-align: justify;
text-indent: 21.25pt; font-family: times new roman;"&gt;&lt;font
size="3"&gt;&lt;span lang="EN-GB" style="font-size:
12pt;"&gt;&amp;#945;2-bla bla bla &lt;/span&gt;&lt;/font&gt;&lt;span
style="font-size: 12pt;"&gt;&lt;font size="3"&gt;&lt;span
style="font-size: 12pt;" lang="EN-GB"&gt;receptors'
&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size="3"&gt;&lt;span
lang="EN-GB" style="font-size: 12pt;"&gt;groups.&lt;/span&gt;&lt;span
style="font-size:
12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class="MsoNormal" style="margin-top: 6pt; text-align: justify;
text-indent: 21.25pt; font-family: times new roman;"&gt;&lt;font
size="3"&gt;&lt;span lang="EN-GB" style="font-size: 12pt;"&gt;In
bla bla bla:&lt;/span&gt;&lt;span style="font-size:
12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p class="MsoNormal" style="margin-top: 6pt; text-align: justify;
text-indent: 21.25pt; font-family: times new roman;"&gt;&lt;font
size="3"&gt;&lt;span lang="EN-GB" style="font-size: 12pt;"&gt;The
applicant&amp;#8217;bla bla bla
&lt;/span&gt;&lt;st1:country-region&gt;&lt;st1:place&gt;&lt;span
lang="EN-GB" style="font-size:
12pt;"&gt;Ireland&lt;/span&gt;&lt;/st1:place&gt;&lt;/st1:country-region&gt;&lt;span lang="EN-GB" style="font-size: 12pt;"&gt; with such capability.&lt;/span&gt;&lt;span style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-top: 6pt; text-align: justify;
text-indent: 21.25pt; font-family: times new roman;"&gt;&lt;font
size="3"&gt;&lt;span lang="EN-GB" style="font-size:
12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;/body&gt;&lt;/html&gt;</Content>
		<Attachments Version="1.0">
		<Attachment context="" mimeType="" name="">
			<Link/>
			<Comment author="" timestamp=""/>
			<Property name=""/>
		</Attachment>
	</Attachments>
</IE.SFI.4400>
</Section>
</Sections>

___

And I use the Apache FOP, which renders the following result:
___

<html><head></head><body><p class="MsoNormal" style="margin-top: 6pt;
text-align: justify; text-indent: 21.25pt; font-family: times new
roman;"><font size="3"><span style="font-size: 12pt;">
</span></font></p> <p class="MsoNormal" style="margin-top: 6pt;
text-align: justify; text-indent: 21.25pt; font-family: times new
roman;"><font size="3"><span lang="EN-GB" style="font-size: 12pt;">bla
bla bla.</span><span style="font-size:
12pt;"><o:p></o:p></span></font></p> <p class="MsoNormal"
style="margin-top: 6pt; text-align: justify; text-indent: 21.25pt;
font-family: times new roman;"><font size="3"><span lang="EN-GB"
style="font-size: 12pt;">&#945;2-bla bla bla </span></font><span
style="font-size: 12pt;"><font size="3"><span style="font-size:12pt;"
lang="EN-GB">receptors' </span></font></span><font size="3"><span
lang="EN-GB" style="font-size: 12pt;">groups.</span><span
style="font-size: 12pt;"><o:p></o:p></span></font></p> <p
class="MsoNormal" style="margin-top: 6pt; text-align: justify;
text-indent: 21.25pt; font-family: times new roman;"><font
size="3"><span lang="EN-GB" style="font-size: 12pt;">bla bla
bla</span><span style="font-size: 12pt;"><o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin-top: 6pt; text-align: justify;
text-indent: 21.25pt; font-family: times new roman;"><font
size="3"><span lang="EN-GB" style="font-size:
12pt;">bla bla bla </span><st1:country-region><st1:place><span
lang="EN-GB" style="font-size:
12pt;">Ireland</span></st1:place></st1:country-region><span
lang="EN-GB" style="font-size: 12pt;"> with such capability.</span><span
style="font-size: 12pt;"><o:p></o:p></span></font></p> <p
class="MsoNormal" style="margin-top: 6pt; text-align: justify;
text-indent: 21.25pt; font-family: times new roman;"><font
size="3"><span lang="EN-GB" style="font-size:
12pt;"><o:p></o:p></span></font></p>
</body></html>
____

What I am looking for is the HTML code as it appears in the PDF document
not to appear as HTML but as formatted text. (I cut out a good bit of
the document because it is a couple of pages, but hope this gives the
idea)

I hope this gives a bit more clarity.
Thanks for the help,
Regards,
Luuk


On Sat, 2006-08-12 at 09:04 -0400, cknell@xxxxxxxxxx wrote:
> "Doesn't work" doesn't tell us anything. If your car broke down on the side of the road, "doesn't work" could mean out of gas, a flat tire, or a broken axel, or a hundred other things. In what manner doesn't it work? What output do you get? Is the troublesome text really XHTML (I'm thinking about the namespace declaration here.), or is it simply in XHTML format. Do you get no output at all or simply output that is not what you expected?
> 
> More information will help the list readers to understand your problem.
> -- 
> Charles Knell
> cknell@xxxxxxxxxx - email
> 
> 
> 
> -----Original Message-----
> From:     Luuk Jansen <subscribe@xxxxxxxxxxxxxxxxx>
> Sent:     Sat, 12 Aug 2006 11:12:22 +0100
> To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  [xsl] Problem with embeded XHTML in an XML file and transformation to XSL:FO
> 
> 
> I have a problem with the following, and breaking my head over it the
> last couple of days.
> 
> I have the content element as seen below in a xml document which has to
> be transformed to a PDF. That is no problem with the Apache FOP and I
> have almost everything working except the view parts that use the XHTML.
> 
> How do I create a template that can transfer the XHTML code to XSL:FO
> code on the fly (preserving layout etc). I tried importing the
> xhtml2fo.xsl sheet into the general style sheet and then call
> apply-templates inside the content element, but that doesn't work, I
> guess because the tags are not correct (as in <).
> 
> The resulting PDF document shows the HTML perfect (with <HTML> etc.).
> 
> I was trying to apply-templates to the code and then put it in a
> variable on which the xhtml2fo.xsl template can be applied, but FOP
> crashed on that try.
> 
> Does anybody have any suggestion?
> 
> Thanks a million in advance,
> Regards,
> 
> Luuk
> 
> _____________
> 
> A small snip of the embedded code is (I replaced the text):
> 
> <Content Version="1.0"
> type="XHTML"><html><head></head><body><p
> class="MsoNormal" style="margin-top: 6pt; text-align: justify;
> text-indent: 21.25pt; font-family: times new roman;"><font
> size="3"><span style="font-size: 12pt;">
> 
> </span></font></p>
> 
> <p class="MsoNormal" style="margin-top: 6pt; text-align: justify;
> text-indent: 21.25pt; font-family: times new roman;"><font
> size="3"><span lang="EN-GB" style="font-size: 12pt;">bla bla
> bla bla bla
> &#945;2-bla bla bla bla bla &#945;2-bla bla bla bla
> bla.</span><span style="font-size:
> 12pt;"><o:p></o:p></span></font></p>
> 
> 
> <p class="MsoNormal" style="margin-top: 6pt; text-align: justify;
> text-indent: 21.25pt; font-family: times new roman;"><font
> size="3"><span lang="EN-GB" style="font-size:
> 12pt;">&#945;2-bla bla bla bla bla
> </span></font><span style="font-size: 12pt;"><font
> size="3"><span style="font-size: 12pt;" lang="EN-GB">receptors'
> </span></font></span><font size="3"><span
> lang="EN-GB" style="font-size: 12pt;">groups.</span><span
> style="font-size:
> 12pt;"><o:p></o:p></span></font></p>
> 
> </body></html></Content>
> 
> __________

Current Thread