Thanks. That was very helpful.

Rgs
Vikram

-----Original Message-----
From: J.Pietschmann [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 30, 2002 3:15 AM
To: [EMAIL PROTECTED]
Subject: Re: Image source


Vikram Goyal01 wrote:
> This means that I can have an xsl stylesheet and place fo
 > namespace tags within it to combine the two steps right?

I'm not sure you have the right picture.
The following is a file containing formatting objects for
a simple greeting, or short FO, by convention getting the
file extension .fo (therefore a .fo file):

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
   <fo:layout-master-set>
     <fo:simple-page-master master-name="simple"
         page-height="29.7cm"  page-width="21cm">
       <fo:region-body/>
     </fo:simple-page-master>
   </fo:layout-master-set>
   <fo:page-sequence master-reference="simple">
     <fo:flow flow-name="xsl-region-body">
       <fo:block>Hello!</fo:block>
     </fo:flow>
   </fo:page-sequence>
</fo:root>

You can use the FOP command line application to produce
a PDF file from it.

  fop -fo greeting.fo -pdf greeting.pdf

While you can create a FO file by hand, it soon becomes
unwieldy. You'll probably prefer a shorter XML representation,
like

  <greeting>Hello!</greeting>

Of course, FOP doesn't understand this directly. It's
time to introduce XSLT. The goal is to transform the
simple XML into the FO at the beginning. The following
XSLT file describes the transformation:

  <?xml version="1.0" encoding="ISO-8859-1"?>
  <xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns:fo="http://www.w3.org/1999/XSL/Format";>

    <xsl:template match="greeting">
     <fo:root>
       <fo:layout-master-set>
         <fo:simple-page-master master-name="simple"
           page-height="29.7cm"  page-width="21cm">
           <fo:region-body/>
         </fo:simple-page-master>
       </fo:layout-master-set>
       <fo:page-sequence master-reference="simple">
         <fo:flow flow-name="xsl-region-body">
           <fo:block><xsl:value-of select="."/></fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </xsl:template>
  </xsl:stylesheet>

The FO structure has been copied nearly verbatim into
an xsl:template element, with the exception of the "Hello!"
text. The elements with the xsl: prefix are instructions
for the XSLT processor. The elements with the fo: prefix
serve as template for the output to generate. You can use
an XSLT processor, for example Xalan, to produce to FO
file:

  xalan -in greeting.xml -xsl greeting.xsl -out greeting.fo

The FOP command line application has Xalan built in. This
allows you to skip the explicit generation of the FO file.
There is still a FO document produced as the result of the
transformation, it is just kept in memory and never written
to disk. So you can say

  fop -xml greeting.xml -xsl greeting.xsl -pdf greeting.fo

which is for most practical purposes the same as

  xalan -in greeting.xml -xsl greeting.xsl -out greeting.fo
  fop -fo greeting.fo -pdf greeting.pdf

J.Pietschmann

Reply via email to