This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes need a dynamic example FOP from a database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "need a dynamic example FOP from a database" Watch "need a dynamic example FOP from a database" New topic
Author

need a dynamic example FOP from a database

majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 161
Hi, How to do reports with placeholders that are comming from a database, please I appreciate if you can give me a small example.
thanks
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi Majid,

can you elaborate a litlle more what you plan to do? FOP and database are not related to each other. At least not directly.

With FOP your are going to translate a FO (.fo) document into a PDF document.

Normally you start with an XML file which represent the content of your document be it HTML or PDF. You then have to create an XSL stylesheet for the presentation (your report) of that XML file. Use XSLT for HTML and XSL:FO for FO.

After you did that you need to run your XML and XSL files through an XSLT processor like Saxon. In case of FO you still need to run your FO through an FO processor like FOP to get your PDF.

You will find lots of examples when you follow the chain I described.

Good Luck.

Darya


SCJP, SCJD, SCWCD, SCBCD
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
View this as two problems:
1. Creating FOP that renders a PDF correctly from a prototype XML file - once you can do this satisfactorily then:
2. Plugging data from a database into an XML document that is a copy of the prototype. (Presumably as a DOM in memory)
Bill


Java Resources at www.wbrogden.com
majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 161
Thank you Darya and William,
I will appreciate if you can show me an example.
thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
It is not clear from your post if you have made ANY effort to solve this problem on your own. Do you even have a FOP toolkit installed?

The Apache FOP toolkit comes with numerous examples. Come back to us when you have installed a FOP toolkit and run through some of the examples.

Bill
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi majid,

I agree with Bill. Do some study first. The link Bill provided to you should be your entry point to the whole topic. And there you will find your examples.

Regards,
Darya
majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 161
Thank you,
I downloaded fop and the examples are working, how can I create and XML file from a database .
thank you again
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
It is essential to work on this problem in a step-wise fashion. You have accomplished the first step by getting the toolkit working.

I would say that the next step is to create one or more plain XML files that contains prototype data for all reports you need. Once you have the conversion of the prototype(s) to FOP and rendering to PDF correctly, then you need to learn how to manipulate data inside XML documents in memory.

The parsing toolkit is very flexible so don't worry about the fact that this first step involves working with files but you want to eventually end up with database sources.

Bill
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18121
    
    8

Here is an example of how to read from a database and produce SAX events:

http://www.cafeconleche.org/books/xmljava/chapters/ch08s05.html

Then (once you understand the concepts) you should be able to produce a SAXSource containing those events and feed it into a parser. But don't expect to understand this right away. I think it would be a good idea to read other parts of the book that are related, if not the entire book.
majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 161
Thank you for your helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need a dynamic example FOP from a database
 
Similar Threads
use photographs in the database like orkut.com
How to know the sessionID is alive ?
Making Systems for Web Services?
how to access database using jsp
How To Creating XML Docs With Java?