[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Problem with embeded XHTML in an XML file and tra

Subject: Re: Problem with embeded XHTML in an XML file and transformation to XSL:FO
From: Luuk Jansen <subscribe@xxxxxxxxxxxxxxxxx>
Date: Sat, 12 Aug 2006 16:47:23 +0100
xhtml lt
On Sat, 2006-08-12 at 14:54 +0100, andrew welch wrote:
> On 8/12/06, Luuk Jansen <subscribe@xxxxxxxxxxxxxxxxx> wrote:
> >
> > 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 &lt;).
> >
> > 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">&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;
> 
> Because the markup is escaped you will need to parse it twice. You
> have a <Content> element containing a string:
> 
> <Content>&lt;html&gt;
> 
> In order for a template to be applied to <html> you need to parse it
> once to get angle brackets:
> 
> <Content><html>
> 
> ...then parse it again to get an <html> element.
> 
> To do this you can use an extension such as saxon:parse() eg:
> 
> <xsl:variable name="htmlContent" select="saxon:parse(/pathto/Content)"/>
> 
> and then:
> 
> <xsl:apply-templates select="$htmlContent"/>
> 
> cheers
> andrew
> 

Thanks Andrew,

I understand the logic, just a practical question.
I wrote the application with the javax.xml.transform. Is there a similar
function as saxon:parse() which I can use with my excising code or and
easy way to sue it without having to rewrite and retest the whole
application?

An other small side problem is that the transformation crashes with a
variable in the apply-templates (??). I tried as I hoped that that would
do the job, but it crashes.

___
 
  <xsl:template match="Content">      
	        <xsl:if test=". != ''">
	        	<fo:block space-after="10mm">
		      		<xsl:variable name="htmlContent" select="."/>		      		
	            	<!-- <xsl:call-template name="replace">
        				<xsl:with-param name="string" select="$htmlContent"/>
    				</xsl:call-template> -->
					<xsl:value-of select="$htmlContent"/>
	           	</fo:block>
           	</xsl:if>
  </xsl:template>
 
  <xsl:template name="replace"> 
    <xsl:param name="string"/>
    <xsl:value-of disable-output-escaping="yes" select="$string"/>
  </xsl:template> 

____

Thanks Luuk

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.