• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need a dynamic example FOP from a database

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
majid nakit
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Darya and William,
I will appreciate if you can show me an example.
thanks
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your helps.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic