|Oracle8i Application Developer's Guide - XML
Release 3 (8.1.7)
Part Number A86030-01
Using XML Java Class Generator, 3 of 8
Using XML Class Generator for Java
The XML Class Generator for Java creates Java source files from an XML DTD. This is useful for the following situations:
- When an application wants to send an XML message to another application based on an agreed-upon DTD
- As the back end of a web form to construct an XML document.
Using the Class Generator classes, Java applications can construct, validate, and print XML documents that comply with the input DTD.
It also optionally generates Javadoc comments in the source files. XML Class Generator requires Oracle XML Parser for Java.
Figure 18-1 shows a summary of how XML Java Class Generator is used.
Figure 18-1 XML Java Class Generator
XML Java Class Generator works in conjunction with XML Parser for Java, which parses the DTD and passes the parsed document to the Class Generator.
Figure 18-2 shows the XML Java Class Generator usage.
XML Java Class Generator operates as follows:
- A new ClassGenerator() class is initiated and inputs the generate() method. Available properties for ClassGenerator() class are:
- setGeneraterComments(), with default = TRUE
- setJavaPackage(string), with default = no package
- setOutputDirectory (string), with default = current directory
- If a DTD is used, the DTD object returned using getDocType() from the parseDTD() method, is also input. See also Figure 17-4, "XML Parser for Java: DOMParser()" from Chapter 17, "Using XML Parser for Java".
- The generate() method generates Java classes which can then be used to build your XML document.
Figure 18-2 XML Java Class Generator Usage