Re: [xsl] Working example xml+xsl to .fo file

Subject: Re: [xsl] Working example xml+xsl to .fo file
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 18 Nov 2008 19:16:27 +0100
eleonora46@xxxxxxx wrote:

No, that is just a working .fo file.
I have such sample files in fop package.
I need the way from xml+xsl to .fo file.

Well write a stylesheet that creates an XSL-FO document as its result:


<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:fo="http://www.w3.org/1999/XSL/Format";
  version="1.0">

<xsl:template match="/">
<fo:root>B
<fo:layout-master-set>B
<fo:simple-page-master master-name="LetterPage" page-width="8.5in"
page-height="11in" >B
<fo:region-body region-name="PageBody" margin="0.7in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="LetterPage">
<fo:flow flow-name="PageBody">
<fo:block>Hello World</fo:block> B
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>


</xsl:stylesheet>

In a real stylesheet you would obviously fill the XSL-FO document with data from an XML document but as a Hello Word example the above suffices, it creates the without taking any data from the XML input.

If you want a Hello world example for that then use e.g

<foo>bar</foo>

as the XML input document and then change the stylesheet to

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:fo="http://www.w3.org/1999/XSL/Format";
  version="1.0">

<xsl:template match="/">
<fo:root>B
<fo:layout-master-set>B
<fo:simple-page-master master-name="LetterPage" page-width="8.5in"
page-height="11in" >B
<fo:region-body region-name="PageBody" margin="0.7in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="LetterPage">
<fo:flow flow-name="PageBody">
<fo:block>Hello World <xsl:value-of select="foo"/></fo:block> B
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>


</xsl:stylesheet>



--

	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread