Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Returning a byte-array after performing an XSLT  RSS feed

 
Martin Fiskare
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use javax.xml.bind.util.JAXBSource
 
Martin Fiskare
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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 C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • 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 C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!