Java Reference
In-Depth Information
The JAX-RS specification does not say whether the injected
MultivaluedMap
should con-
tain encoded strings or not. Most JAX-RS implementations will automatically decode the
map's string keys and values. If you want it encoded, you can use the
@javax.ws.rs.Encoded
annotation to notify the JAX-RS implementation that you want the
data in its raw form.
javax.xml.transform.Source
The
javax.xml.transform.Source
interface represents XML input or output. It is usually
used to perform XSLT transformations on input documents. Here's an example:
@Path
(
"/transform"
)
public
public class
class
TransformationService
TransformationService
{
@POST
@Consumes
(
"application/xml"
)
@Produces
(
"application/xml"
)
public
public
String
post
(
Source source
) {
javax
.
xml
.
transform
.
TransformerFactory
tFactory
=
javax
.
xml
.
transform
.
TransformerFactory
.
newInstance
();
javax
.
xml
.
transform
.
Transformer
transformer
=
tFactory
.
newTransformer
(
new
new
javax
.
xml
.
transform
.
stream
.
StreamSource
(
"foo.xsl"
));
StringWriter writer
=
new
new
StringWriter
();
transformer
.
transform
(
source
,
new
new
javax
.
xml
.
transform
.
stream
.
StreamResult
(
writer
));
return
return
writer
.
toString
();
}
In this example, we're having JAX-RS inject a
javax.xml.transform.Source
instance that
represents our request body and we're transforming it using an XSLT transformation.
Except for JAXB,
javax.xml.transform.Source
is the only XML-based construct that the
specification requires implementers to support. I find it a little strange that you can't auto-
matically inject and marshal
org.w3c.dom.Document
objects. This was probably just forgot-
ten in the writing of the specification.