Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Transform XML blob object from database to PDF

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need some help in one of my requirements. I have a xml file stored as Blob object in the Oracle database. My requirement is to connect to the database, get the xml file, parse the xml file and output the content of the xml to a pdf. My pdf should be of specific format. Can any one help me with any ideas in this context please? I appreciate if someone can provide me with some sample code.

Thanks,
Ram...
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What part do you need help with? There are a number of different phases to your process, each of which requires different tools.
 
Rama Krishna Ghanta
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know I should use an XML parser to parse the xml and I should use itext to output to a pdf. I have written the jdbc connection code also. I stopped at Blob blob = resultSet.getBlob("blobObject").I don't know how to proceed next.

Thanks,
Ram...
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to convert that Blob to valid XML, have a look for conversion routines and/or look at bringing it back as something other than a Blob (perhaps generically as an Object).

Once you have the XML you can start using the iText libs...
 
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
Seems to me if that Blob was created by somebody writing the text of an XML document into a Blob and storing it you should be able to use the Blob getBinaryStream method to get an InputStream.

If that InputStream can be read as valid characters you should be able to parse it.

If the format of the xml is suitable you might be able to do an XSL transform directly on that stream to get FOP formatted output suitable for feeding to a PDF creation tool.

On the other hand, if that Blob is - for example - a serialized Java object, you have other problems.

Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic