Transforming XML

So far in this chapter you have learned about the XSLT and XPath basics, and how to use the transformation classes with DOM and SAX. This section will teach you how to create an XSLT stylesheet and use the transformation classes to transform an XML document into another with a very different structure and tag names.

As before, the CarParts.xml file will be used as the source XML document. You will need to write an XSLT stylesheet that will contain the transformation information. You will also need to write a small Java application that will use CarParts.xml and the XSLT stylesheet to do the transformation and show the transformed XML on the screen.

First, let's look at what the transformed CarParts.xml should look like. The transformed ...

Get Java™ APIs for XML Kick Start 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.