Create a Simple Filter
The simple filter example demonstrates how SAX can be used to filter content to create a subset of the original document being parsed. In this example, the application parses books.xml and produces a document fragment that contains only <title>
elements and characters. The application is kept simple to demonstrate the fundamental principles involved in transforming documents with SAX, including the following:
- How to detect the presence of an element in an XML document and how to write the element's content to the application's output.
- The essential SAX methods you must use to conditionally process content.
- How to set a flag to indicate across events that an element is within scope.
- How to create a document fragment.
This topic is divided into the following sections:
- Overview of the Simple Filter Application
- Application Form (Simple Filter)
- How Filter Criteria is Set
- ContentHandlerImpl Class
- Essential Handler Methods
- Run the Application