• 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

Returning a byte-array after performing an XSLT

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hej!

Me again with another nerve-wrecking issue, since I'm not very experienced witj java and xml

What i need to do is marshal Dummy.class and return the result in form of a byte array. Problem is I can't do that straight like marshalling directly into a ByteOutputStream, because I have to modify the output by performing an XSLT.

In other words, what I want to do is
- Marshal my class structure to whatever result might be necessary
- transform the result
- return the result in form of a byte-array.

That's what I have right now..



Thanks thousandfold in advance for any help
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use javax.xml.bind.util.JAXBSource
 
Martin Fiskare
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, that looks useful at the first glance.. but, when does the actual marshalling happen?
Does is happen implicitly when I instantiate the JAXBSource?

And besides.. the result of the transformation has somehow to be a byte-array.. and i have no clue how I can achieve that.
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both marshalling and transformation happen when the transform() is called. JAXBSource is just an adaptor between JAXB and transformer - it calls marshal() as soon as the transformer asks it for an XML input stream.

As for the byte array, well you're already half way there:
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just occurred to me now...why do you need a byte array as output? Perhaps there is a better way, if you can explain the circumstances.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic