Oracle9i XML API Reference - XDK and Oracle XML DB Release 2 (9.2) Part Number A96616-01 |
|
The XML Class Generator for Java is contained within the oracle.xml.classgen package.
This chapter describes API's in the following classes:
This class serves as the base document class for the DTD class Generator generated classes.
public abstract class CGDocument extendsoracle.xml.classgen.CGNode
implements java.io.Externalizableoracle.xml.classgen.CGNode
| +--oracle.xml.classgen.CGDocument
java.io.Externalizable, java.io.Serializable
Method | Description |
---|---|
Constructor for the root element of the DTD. |
|
Prints the constructed XML document. |
|
Reads the compressed stream and creates the object corresponding to the root element. |
Constructor for the root element of the DTD.
protected CGDocument( String doctype, oracle.xml.parser.v2.DTD dtd);
Parameter | Description |
---|---|
doctype |
Name of the root Element of the DTD. |
dtd |
The DTD used to generate the classes. |
Prints the constructed XML Document. Throws InvalidContentException
if the document's content does not match the grammar specified by DTD; the validation mode should be set to TRUE. See also setValidationMode()
in DTDClassGenerator Class. The options are described in the following table.
Parameter | Description |
---|---|
out |
Output stream to which the document will be printed. |
enc |
Encoding of the output stream. |
Reads the compressed stream and creates the object corresponding to the root element. Used for instantiating the generated classes with XML instance document.
protected void readExternal( java.io.ObjectInput inArg, oracle.xml.comp.CXMLContext cxmlContext);
Parameter | Description |
---|---|
in |
ObjectInput stream passed to read the compressed stream |
cxmlContext |
The context of the compressed stream |
This class serves as the base class for the classes corresponding to the nodes of XML document generated by the DTD class generator.
public abstract class CGNode oracle.xml.classgen.CGNode
CGDocument
Field | Syntax | Description |
---|---|---|
isValidating |
protected boolean isValidating |
Boolean to indicate the validating mode |
Constructor for the Elements of the DOM Tree.
protected CGNode( String elementName);
Parameter | Description |
---|---|
elementName |
Name of the element. |
Adds CDATA Section to the Element. Throws InvalidContentException
if theData
has illegal characters; validation must be set to TRUE. See also setValidationMode()
in DTDClassGenerator Class.
protected void addCDATASection( String theData);
Parameter | Description |
---|---|
theData |
Text to be added as CDATA Section to the element. |
Adds PCDATA to the element node. Throws InvalidContentException
if theData
has illegal characters; validation must be set to TRUE. See also setValidationMode()
in DTDClassGenerator Class.
protected void addData( String theData);
Parameter | Description |
---|---|
theData |
Text to be added a to the element. |
Adds a node as a child to the element. Throws InvalidContentException
if theData
has illegal characters; validation must be set to TRUE. See also setValidationMode()
in DTDClassGenerator Class.
protected void addNode( CGNode
theNode);
Parameter | Description |
---|---|
theNode |
The node to be added as child. |
Deletes PCDATA from the element node. Throws InvalidContentException
if theData
has illegal characters; validation must be set to TRUE. See also setValidationMode()
in DTDClassGenerator Class.
protected void deleteData( String theData);
Parameter | Description |
---|---|
theNode |
Text to be deleted from an element. |
Returns the value of the attribute.
protected String getAttribute( String attName);
Parameter | Description |
---|---|
attName |
Name of the attribute. |
Gets the base document (root Element).
protected CGDocument
getCGDocument();
Gets the PCDATA of the Element. Throws InvalidContentException
if the data is not present.
protected String getData();
Retrieves the static DTD from the base CGDocument.
protected abstract oracle.xml.parser.v2.DTD getDTDNode();
Retrieves the XMLElement node corresponding to this CGNode.
protected oracle.xml.parser.v2.XMLElement getElementNode();
Retrieves the CGNode which is one of the children of the element corresponding to the node whose name matches the input string.
protected java.lang.Object getNode(String theNode);
Parameter | Description |
---|---|
theNode |
The name of the string corresponding to the CGNode returned. |
Reads the compressed stream and instantiate the corresponding node. Throws the following exceptions:
IOException
when an I/O Error occursClassNotFoundException
when the class could not be instantiated
protected void readExternal( oracle.xml.io.XMLObjectInput in, oracle.xml.comp.CXMLContext cxmlContext)
Parameter | Description |
---|---|
in |
The |
cxmlContext |
The context of the compressed stream. |
Sets the value of the attribute.
protected void setAttribute( String attName, String value);
Parameter | Description |
---|---|
attName |
Name of the attribute. |
value |
Value of the attribute. |
Sets the base document (root element).
public void setDocument( CGDocument
d);
Parameter | Description |
---|---|
d |
Base CGDocument. |
Sets the XMLElement node corresponding to this CGNode.
protected void setElementNode( oracle.xml.parser.v2.XMLElement node);
Parameter | Description |
---|---|
node |
The XMLElement. |
Store this value for an ID identifier, which can be verified with IDREF values.
protected void storeID( String attName, String id);
Parameter | Description |
---|---|
attName |
Name of the ID attribute. |
id |
Value of the ID |
Store this value for an IDREF identifier, which can be verified by the corresponding ID.
protected void storeIDREF( String attName, String idref);
Parameter | Description |
---|---|
attName |
Name of the IDREF attribute. |
idref |
Value of the IDREF |
Checks if the content of the element is valid according to the Content Model specified in DTD.
protected void validateContent();
Checks if the ENTITY identifier is valid. Returns TRUE
if ENTITY is valid, FALSE
otherwise.
protected boolean validEntity( String entity);
Parameter | Description |
---|---|
name |
Value of the ENTITY attribute |
Checks if the ID identifier is valid. Returns TRUE
if ID is valid, FALSE
otherwise.
protected boolean validID( String name);
Parameter | Description |
---|---|
name |
Value of the ID attribute. |
Checks if the NMTOKEN identifier is valid. Returns TRUE
if NMTOKEN is valid, FALSE
otherwise.
protected boolean validNMTOKEN( String name);
Parameter | Description |
---|---|
name |
Value of the NMTOKEN attribute. |
Writes the compressed stream corresponding to this node.
protected void writeExternal( oracle.xml.io.XMLObjectOutput out,
oracle.xml.comp.CXMLContext cxmlContext);
Parameter | Description |
---|---|
out |
ObjectOutput stream to write the compressed data. |
cxmlContext |
The context of the compressed stream. |
This class serves as the base class for the all the generated classes corresponding to the XML Schema generated by Schema Class Generator
public abstract class CGXSDElement extends java.lang.Object java.lang.Object | +--oracle.xml.classgen.CGXSDElement
Field | Syntax | Description |
---|---|---|
type |
protected java.lang.Object type |
Type information of a node |
Default constructor.
public CGXSDElement();
Adds the attribute of a given node to the hashtable.
protected void addAttribute( String attName, java.lang.Object attValue);
Parameter | Description |
---|---|
attName |
The attribute name. |
attValue |
The attribute value. |
Adds the local elements of an element node to the vector corresponded to the elements.
protected void addElement( java.lang.Object elem);
Parameter | Description |
---|---|
elem |
The object which needs to be added. |
Returns the attributes as a hashtable of attribute names and values.
public java.util.Hashtable getAttributes();
Retrieves the vector of all local elements.
public java.util.Vector getChildElements();
Returns the value of the node.
public String getNodeValue();
Prints an element node. Throws an IOException
if not able to print to the output stream
public void print( oracle.xml.parser.v2.XMLOutputStream out);
Parameter | Description |
---|---|
out |
The XMLObjectOutput stream to which the output is printed. |
Prints an attribute node. Throws an IOException
if not able to print to the XMLObjectOutput
stream.
public void printAttributes( oracle.xml.parser.v2.XMLOutputStream out, String name, String namespace);
Parameter | Description |
---|---|
out |
The XMLObjectOutput stream to which the output is printed. |
name |
The attribute name |
namespace |
The namespace |
Sets the node value of an element.
protected void setNodeValue( String value);
Parameter | Description |
---|---|
value |
The node vale. |
Generates the data binding classes corresponding to a DTD or an XML file based on a DTD.
public class DTDClassGenerator extends java.lang.Object java.lang.Object | +--oracle.xml.classgen.DTDClassGenerator
Default constructor for DTDClassGenerator.
public DTDClassGenerator();
Traverses the DTD with element doctype
as root and generates Java classes.
public void generate( oracle.xml.parser.v2.DTD dtd, String doctype);
Parameter | Description |
---|---|
DTD |
The DTD used to generate the classes. |
doctype |
Name of the root element. |
Sets the switch to determine whether to generate java doc comments for the generated classes. Default value is TRUE.
public void setGenerateComments( boolean comments);
Parameter | Description |
---|---|
comments |
The boolean flag for turning on/off the java doc comment generation. |
Sets the package for the classes generated. Default - no package set.
public void setJavaPackage( java.util.Vector packageName);
Parameter | Description |
---|---|
packageName |
Name of the package. |
Sets the output directory where the java source code for the DTD is generated. Default value is the current directory.
public void setOutputDirectory( String dir);
Parameter | Description |
---|---|
dir |
Output directory. |
Sets the switch to determine if the DTD should be saved as a serialized object or as text file. Serializing the DTD improves the performance when the generated classes are used to author XML files.
public void setSerializationMode( boolean yes);
Parameter | Description |
---|---|
yes |
The boolean flag for turning on/off saving of DTD as serialized object ( |
Sets the switch to determine whether the classes generated should validate the XML document being constructed. Default value is TRUE
.
public void setValidationMode( boolean yes);
Parameter | Description |
---|---|
yes |
The boolean flag for turning on/off validation of XML document. Default is |
Defines the Exception thrown by DTD ClassGenerator and Schema Class Generator.
public class InvalidContentException extends java.lang.Exception java.lang.Object | +--java.lang.Throwable | +--java.lang.Exception | +--oracle.xml.classgen.InvalidContentException
java.io.Serializable
Constructor. The options are described in the following table.
Syntax | Description |
---|---|
public InvalidContentException(); |
Default constructor. |
public InvalidContentException( String s); |
This constructor takes an input String of information about the exception. |
Parameter | Description |
---|---|
s |
String that contains the information about the exception. |
Provides a command-line interface to generate java classes corresponding to the DTD or XML
public class oracg extends java.lang.Object java.lang.Object | +--oracle.xml.classgen.oracg
This class generates the classes corresponding to an XML Schema.
public class SchemaClassGenerator extends java.lang.Object java.lang.Object | +--oracle.xml.classgen.SchemaClassGenerator
Constructor. The options are described in the following table.
Parameter | Description |
---|---|
fileName |
The input XML Schema. |
Generates the Schema classes corresponding to top level elements, simpleType elements and complexType elements by calling createSchemaClass() on each of these nodes.
public void generate( oracle.xml.parser.schema.XMLSchema schema);
Parameter | Description |
---|---|
XML |
Schema object. |
Sets the switch to determine whether to generate java doc comments. TRUE
by default.
public void setGenerateComments( boolean comments)
Parameter | Description |
---|---|
comments |
Turns on/off the java doc comment generation. |
Assigns user-defined Java package name for each namespace. The Namespaces defined in the schema are queried, and their number should match the number of package names provided by the user; otherwise, an error is thrown.
public void setJavaPackage( oracle.xml.parser.schema.XMLSchema schema, java.util.Vector pkgName);
Parameter | Description |
---|---|
schema |
The XML Schema |
pkgName |
A vector containing user defined package names given through command line. |
Sets the output directory where the java source code for the Schema class are generated. The current directory is the default.
public void setOutputDirectory( String dir);
Parameter | Description |
---|---|
dir |
The output directory. |
|
Copyright © 2001, 2002 Oracle Corporation. All Rights Reserved. |
|