users@jersey.java.net

Re: [Jersey] XSLT and Jersey

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 05 Jan 2009 13:32:16 +0100

Hi Steve,

A response filter might be appropriate. You could use a servlet filter
or a Jersey-based filter. Such filters are not specific to the
resource class (although we are considering having filters specific to
a resource class).

You could implement a filter that checks content-type of the response
and if so transforms the XML serialized by JAXB using XSLT.

See the source code of the LoggingFilter [1] for an example of how to
adapt the output stream when writing the response.

See ResourceConfig and ServletContainer for how to register filters.

Paul.

[1] https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.1/api/jersey/com/sun/jersey/api/container/filter/LoggingFilter.html

http://download.java.net/maven/2/com/sun/jersey/jersey-server/1.0.1/jersey-server-1.0.1-sources.jar

[2]
https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.1/api/jersey/com/sun/jersey/api/core/ResourceConfig.html
https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.1/api/jersey/com/sun/jersey/spi/container/servlet/ServletContainer.html

On Jan 5, 2009, at 4:13 AM, Steve Mactaggart wrote:

> Hi all,
>
> I am loving the ease of use of Jersey to expose simple XML web
> services, I have a quick question about being able to do server side
> transforms on the data using XSLT.
>
> We want to have a standard document format for accessing some of our
> data, but also the ability to pass a flag to the web service that
> allows us to turn on XSLT or some sort of processing that will
> modify the XML output.
>
> We don't want to have multiple data models, as they are close to the
> same, we just would like to do some post (jaxb) processing on the
> XML to make minor changes.
>
> Is there any way to do this inside the Jersey framework?
>
> Thank,
> Steve