1) I am just trying with one sample xml and xls (got from web).
2) Using FopServlet (came with fop - from servlet example)
3) But continuously getting NullPointer Exception at following
driver.render(input.getParser(), input.getInputSource());
I am attaching the xml and xsl for the info
XML File - data.xml
-------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Catalogue>
<Book>
<Title>Mastering EJB</Title>
<Author>Ed Roman</Author>
<Price>$45.00</Price>
</Book>
<Book>
<Title>Design Patterns</Title>
<Author>Erich Gamma</Author>
<Price>$50.00</Price>
</Book>
<Book>
<Title>Effective Java</Title>
<Author>Josch Bloch</Author>
<Price>$30.00</Price>
</Book>
</Catalogue>
----------------------------------------------------------
<Catalogue>
<Book>
<Title>Mastering EJB</Title>
<Author>Ed Roman</Author>
<Price>$45.00</Price>
</Book>
<Book>
<Title>Design Patterns</Title>
<Author>Erich Gamma</Author>
<Price>$50.00</Price>
</Book>
<Book>
<Title>Effective Java</Title>
<Author>Josch Bloch</Author>
<Price>$30.00</Price>
</Book>
</Catalogue>
----------------------------------------------------------
XSL File - format.xsl
-------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:java="java" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<!-- ========================= -->
<!-- root element: Catalogue -->
<!-- ========================= -->
<xsl:template match="Catalog">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:java="java" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<!-- ========================= -->
<!-- root element: Catalogue -->
<!-- ========================= -->
<xsl:template match="Catalog">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- (1. Define the page margins) -->
<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>
<!-- (2. For the page layout refer to the master layout)-->
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="16pt" font-weight="bold" space-after="5mm">Catalog Information
</fo:block>
<!-- (3. Defining the block with table definition to display data -->
<!-- (1. Define the page margins) -->
<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>
<!-- (2. For the page layout refer to the master layout)-->
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="16pt" font-weight="bold" space-after="5mm">Catalog Information
</fo:block>
<!-- (3. Defining the block with table definition to display data -->
<fo:block font-size="10pt">
<fo:table table-layout="fixed">
<fo:table-column column-width="8cm"/>
<fo:table-column column-width="8cm"/>
<fo:table-column column-width="8cm"/>
<fo:table-body>
<xsl:apply-templates/>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<!-- ========================= -->
<!-- Book Information -->
<!-- ========================= -->
<xsl:template match="Book">
<fo:table-row>
<fo:table-cell>
<fo:block>
<xsl:value-of select="Title"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="Author"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="Price"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
<fo:table table-layout="fixed">
<fo:table-column column-width="8cm"/>
<fo:table-column column-width="8cm"/>
<fo:table-column column-width="8cm"/>
<fo:table-body>
<xsl:apply-templates/>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<!-- ========================= -->
<!-- Book Information -->
<!-- ========================= -->
<xsl:template match="Book">
<fo:table-row>
<fo:table-cell>
<fo:block>
<xsl:value-of select="Title"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="Author"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="Price"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
-------------------------------------------------------------
Pls tell me what am i missing now ? If possible whether anybody can provide me the sample xml / xsl files so that i can test it out ?
regards
Manisha
Arun Sinha <[EMAIL PROTECTED]> wrote:
Hi Manisha,
Once you have your XML, you can directly use :-
fop -xml myxml.xml -xsl myxsl.xsl -pdf mydoc.pdf
Hope the above helps.
Cheers.
Arun
>From: Manisha Sathe <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: Want to know the normal practice
>Date: Sun, 6 Feb 2005 23:14:52 -0800 (PST)
>
>I need to pull some data from database and want to show it inside pdf in a
>tabular form. What is the best way to do it ?
>
>1)First create XML and convert it to FO
>2)Take FO and convert it into PDF
>
>Is there any other direct way ? My environment is java / JSP / Struts
>framework with MSSQL as backend. Is there any example for FOP with Database
>?
>
>btw, the examples given seems to be using deprecated methods, where can i
>find latest examples ? (using j2sdk 1.4.2_03)
>
>regards
>Manisha
>
>
>
>
>
>
>
>---------------------------------
>Do you Yahoo!?
> Yahoo! Search presents - Jib Jab's 'Second Term'
_________________________________________________________________
MSN Spaces! Your space, your time. http://www.msn.co.in/spaces Your personal
haven online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Do you Yahoo!?
Yahoo! Search presents - Jib Jab's 'Second Term'