users@jersey.java.net

Re: [Jersey] Marshaling JAXB objects including stylesheet information

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 10 Mar 2009 13:37:01 +0100

Hi,

For setting the style sheet see:

   https://jaxb.dev.java.net/nonav/2.1.10/docs/
vendorProperties.html#xmlheader

You can do this:

         Marshaller m = ...
         m.setProperty("com.sun.xml.bind.xmlHeaders", "<?xml-
stylesheet type='text/xsl' href='foobar.xsl' ?>");

Paul.

On Mar 5, 2009, at 4:41 PM, Rabick, Mark A (MS) wrote:

> I'm also interested in including stylesheet info in the returned xml
> output. I can use the JAXB schemagen task or bat file to generate the
> xsd outside of my normal build process but don't know how to
> dynamically
> generate the schema on the server (in the webapp) and get a common URI
> for the xsd (like the application.wadl). I'd be interested in seeing
> the rest code that actually passes in the URI to your code below...
>
>> /* xslPath is passed in as a URI */
>
> --mark
> _______________________________________________
> Mark A. Rabick - Software Engineer
> Em: mark.rabick_at_ngc.com
>
>
>
>> -----Original Message-----
>> From: Christopher Piggott [mailto:cpiggott_at_gmail.com]
>> Sent: Thursday, March 05, 2009 8:35 AM
>> To: users_at_jersey.dev.java.net
>> Subject: [Jersey] Marshaling JAXB objects including
>> stylesheet information
>>
>> I'd like to be able to include an xml-stylesheet processing
>> instruction in the xml output from my jersey resources. I
>> figured out a way to accomplish this whereby I do the
>> marshalling myself:
>>
>> /* xslPath is passed in as a URI */
>> w.write("<?xml version=\"1.0\" encoding=\""
>> + marshaller.getProperty(Marshaller.JAXB_ENCODING)
>> + "\"?>\n");
>> w.write("<?xml-stylesheet type=\"text/xsl\""
>> + " href=\""
>> + xslPath.toASCIIString()
>> + "\"?>\n");
>> marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
>> marshaller.marshal(item, w);
>>
>> but this is pretty ugly stuff.
>>
>> Anybody have a better idea?
>>
>> --Chris
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>