Generating XML from an Arbitrary Data Structure

In this section, you'll use XSLT to convert an arbitrary data structure to XML.

Here is an outline of the process:

1.
You'll modify an existing program that reads the data, to make it generate SAX events. (Whether that program is a real parser or simply a data filter of some kind is irrelevant for the moment.)
2.
You'll then use the SAX “parser” to construct a SAXSource for the transformation.
3.
You'll use the same StreamResult object you created in the last exercise so that you can see the results. (But note that you could just as easily create a DOMResult object to create a DOM in memory.)
4.
You'll wire the source to the result using the transformer object to make the conversion.

For starters, ...

Get The J2EE™ Tutorial Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.