TrAX (Transformation API for XML), a proposal incorporated in JAXP (Java API
for XML Parsing), which is part of the standard Java runtime for a while
now.  You retrieve a TransformerFactory from the default (or a named) XML
service provider, like Crimson or Xerces-J:

Transformer transformer = TransformerFactory.newInstance().newTransformer();

Then you do transformations like this:

transformer.transform(new DOMSource(document), new StreamResult(System.out
));

The *Source and *Result classes are part of the core SAX API, so you can
transform from and to lots of things.

In between fetching the transformer and making it do transformations, you
can set properties on it to modulate its behavior.  These properties are
defined in the OutputKeys class and you can find the relevant Javadoc there.

Especially when writing a public API/framework, it is best to stick to the
JAXP factory mechanism so that the framework does not become dependent on a
particular parser or transformation library.

/digression

One of the benefits of the Restlet library is that by using
DomRepresentation you can just ignore all this and let XML serialization and
deserialization happen transparently ... and Restlet will also now
transparently work around annoying bugs in the JAXP implementation, per this
thread  ;-)

On Fri, Mar 14, 2008 at 6:04 PM, Leshek <[EMAIL PROTECTED]> wrote:

>  "Rob Heittman" <[EMAIL PROTECTED]> wrote in message
> >> JDK transformation incantations
>
> Sorry for the digression, what are those?
>
> That is exactly the task I am about to tackle...
> L.
>

Reply via email to