Generating a SAX Document Handler
See Also
Once you have created a DTD file, the IDE enables you to generate content
handler files.
To generate a SAX document handler:
- In the Files window, right-click a DTD node and choose SAX Document Handler
Wizard.
- Specify the versions of JAXP and the SAX parser you want to use.
- Use SAX
1.0 as your SAX parser version if you want the generated parser to implement org.xml.sax.DocumentHandler.
- Use SAX 2.0 if you want the generated parser to implement org.xml.sax.ContentHandler.
- If you want to include all of the original SAX parser events in the handler
interface, select the Propagate SAX Events to Generated Handler checkbox.
Click Next to proceed.
- Select the XML elements for which you want to generate handler methods
in the handler interface. The Element column lists the qualified names of
all the elements in your DTD. Choose the handler type for the element in
the Handler Type column, or choose Ignore to exclude the element from the
handler interface.
- Specify the handler method name in the Method column. Then click Next to
proceed.
The IDE generates
a handle_elementName method for container elements and a
pair of start_elementName and end_elementName methods
for content elements.
- Select the elements for which you want to generate data convertor methods.
These methods take the string objects from the parser output and convert
them into qualified data types.
- Type a name for the data convertor method in the Convertor Method column.
Leave (none) in this column if you do not want to generate a data convertor
method for an element.
- Type the return type in the Return Type column. The IDE provides conversion
methods for common return types such as integers and Booleans.
The IDE
checks that entries in this column are valid identifiers and highlights
any invalid identifiers in red. Click Next to proceed.
- Change the names of the generated files if necessary.
- Select the Save Customized Bindings checkbox if you want to save your customizations
to the SAX code generation.
The bindings are stored in an XML file in
the same directory as your SAX implementation files.
- The IDE locates and reuses
the bindings the next time you run the wizard on the DTD.
- Click
Finish.
The IDE generates the content handler files.
- See Also
- SAX Support in the IDE
- Generating a DOM Tree Scanner
- Creating a DTD
Legal Notices