Using XSLT with DOM

Using the DOM APIs, an XML document can be read into a DOM tree. After a DOM is created, you can manipulate the DOM, such as adding or deleting element nodes and so on. After the changes are made in the DOM, you might want to save it back as an XML file. The XSLT APIs help you generate XML out of a DOM.

To understand how to use XSLT with DOM, create an application called MyDOMTransformer that does the following:

  • Reads an XML file into a DOM. Use the CarParts.xml file that was created in the earlier chapters as the sample XML file.

  • Adds a new engine element node to the DOM.

  • Removes the carstereo element node from the DOM.

  • Using the XSLT APIs, generates the modified DOM as XML.

Sequence of Steps in Using XSLT with DOM

The following ...

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.