Oracle9i XML API Reference - XDK and Oracle XML DB Release 2 (9.2) Part Number A96616-01 |
|
The full functionality of XML Schema Processor for Java is contained in the oracle.XML.parser.schema
package.
This chapter discusses the following topics:
This class contains a set of Schema for different target namespaces. They are used by XSDParser for instance XML documents validation and by XSDBuilder as imported schemas.
public class XMLSchemaNode extendsoracle.xml.parser.schema.XSDNode
oracle.xml.parser.schema.XSDNode
| +--oracle.xml.parser.schema.XMLSchemaNode
XMLSchema constructor. Throws XSDException. The options are described in the following table.
Syntax | Description |
---|---|
public XMLSchema() |
Default constructor. |
public XMLSchema(int n); |
Constructs schema given initial size of schemanode set. |
Parameter | Description |
---|---|
n |
Initial size of schemanode set |
Returns all the Target Name space defined in the schema.
public java.lang.String[] getAllTargetNS();
Returns schemaNode for the given namespace.
public XMLSchemaNode
getSchemaByTargetNS( String namespace);
Parameter | Description |
---|---|
namespace |
Target namespace of the required schema. |
Returns the top level schema's target Namespace. In case there are more than one top level schema, the last one being built is returned.
public String getSchemaTargetNS();
Returns XMLSchemaNode table as a hashtable.
public java.util.Hashtable getXMLSchemaNodeTable();
Returns XMLSchema URLs as an array.
public java.lang.String[] getXMLSchemaURLS();
Print schema information. The options are described in the following table.
Syntax | Description |
---|---|
public void printSchema(); |
Prints schema information. |
boolean all); |
Prints schema information, including build-ins. |
Parameter | Description |
---|---|
all |
Flag to indicate that all information, including build-ins, should be printed |
This class contains sets of top level Schema components in a target namespace.
public class XMLSchemaNode extendsoracle.xml.parser.schema.XSDNode
oracle.xml.parser.schema.XSDNode
| +--oracle.xml.parser.schema.XMLSchemaNode
XMLSchema constructor.
public XMLSchemaNode();
Returns all the top level attributes in the schema as an array.
public XSDAttribute
getAttributeDeclarations();
Returns all the top level complex type elements in the schema as an array.
public XSDNode
getComplexTypeSet();
Returns the complex type definitions as a hashtable.
public java.util.Hashtable getComplexTypeTable();
Returns all the top level elements in the schema as an array.
public XSDNode
getElementSet();
Returns all the top level simpleType elements in the schema as an array.
public XSDNode
getSimpleTypeSet();
Returns the simple type definitions, in a hashtable.
public java.util.Hashtable getSimpleTypeTable();
Returns targetNS of the schema. Overrides XSDNode.getTargetNS()
in class XSDNode.
public String getTargetNS();
Returns the type definitions as a hashtable.
public java.util.Hashtable getTypeDefinitionTable();
This class represents Schema Attribute declaration.
public class XSDAttribute extendsoracle.xml.parser.schema.XSDNode
oracle.xml.parser.schema.XSDNode
| +--oracle.xml.parser.schema.XSDAttribute
Returns the value of 'default' attr in case of element, and the value of 'value' attr based on 'use' attribute.
public String getDefaultVal();
Returns the default value of 'fixed' attr in case of element, and the value of 'value' attr based on 'use' attribute.
public java.lang.String getFixedVal();
Returns the name of the node. Overrides XSDNode.getName()
in class XSDNode.
public String getName();
Returns the refLocal name of the resolved 'ref' attribute
public String getRefLocalname();
Returns the RefNamespace of the resolved 'ref' attribute.
public String getRefNamespace();
Returns refState value. The return value is one of the following: TYPE_UNRESOLVED
, TYPE_RESOLVED
, REF_UNRESOLVED
, REF_RESOLVED.
public int getRefState();
Returns target namespace. XSDNode.getTargetNS()
in class XSDNode.
public String getTargetNS();
Returns the node type which is either simpleTypeor complexType.
public XSDNode
getType();
Checks if the attribute is required.
public boolean isRequired();
Builds an XMLSchema object from XMLSchema document. XMLSchema object is a set of objects (Infoset items) corresponding to top-level schema declarations & definitions. Schema document is 'XML' parsed and converted to a DOM tree. This schema DOM tree is 'Schema' parsed in a following order: (if any) builds a schema object and makes it visible. (if any) is replaced by corresponding DOM tree. Top-level declarations & definitions are registered as a current schema infoset items. Finally, top-level tree elements (infoset items) are 'Schema' parsed. The result XMLSchema object is a set (infoset) of objects (top-level input elements). Object's contents is a tree with nodes corresponding to low-level element/group decls/refs preceded by node/object of type SNode containing cardinality information (min/maxOccurs).
public class XSDBuilder
XSDBuilder constructor.
public XSDBuilder() throws XSDException;
Build and returns an XMLSchema object/document. An Exception is thrown if Builder fails to build an XMLSchema object. The options are described in the following table.
Returns XML schema object.
public Object getObject();
Sets an EntityResolver for resolving imports/include. See also org.xml.sax.EintityResolver.
public void setEntityResolver( org.xml.sax.entityResolver entResolver);
Parameter | Description |
---|---|
entResolver |
EntityResolver |
Sets XMLError object.
public void setError( XMLError er);
Parameter | Description |
---|---|
er |
XMLError object |
Sets locale for error reporting.
public void setLocale(L ocale locale);
Parameter | Description |
---|---|
locale |
Locale object |
This class represents the Schema ComplexType definition.
public class XSDComplexType extendsoracle.xml.parser.schema.XSDNode
oracle.xml.parser.schema.XSDNode
| +--oracle.xml.parser.schema.XSDComplexType
Returns attribute declarations of this complex type; does not include wild card array of attribute declarations.
public XSDAttribute
getAttributeDeclarations();
Returns attribute wildcard of this complex type.
public oracle.xml.parser.schema.XSDAny getAttributeWildcard();
The attribute wildcard if has one
Returns the base type of this complextype.
public XSDNode
getBaseType();
Returns content of XSDComplexType.
public int getContent();
Returns information on how was this type derived from its parent type. One of EXTENSION_DERIVATION
or RESTRICTION_DERIVATION
.
public short getDerivationMethod();
Returns an array of all the local elements inside a complexType element.
public XSDNode
getElementSet();
Returns the attribute group or the child & attribute group.
public XSDGroup
getGroup();
Returns the local name of resolved 'base' attr.
public java.lang.String getRefLocalname();
Returns type group of Complex Type.
public XSDGroup
getTypeGroup();
Initializes complex type.
public static void init();
Returns TRUE
if the Complex Type is abstract.
public boolean isAbstract();
This class represents Schema Constraining facet for Data Type.
public class XSDConstrainingFacet extends java.lang.Object implements
oracle.xml.parser.schema.XSDTypeConstants
java.lang.Object
|
+--oracle.xml.parser.schema.XSDConstrainingFacet
XSDTypeConstants
Returns the facet id.
public int getFacetId();
Returns the LEXICAL enumeration of the constraining facet.
public java.util.Vector getLexicalEnumeration();
Returns the LEXICAL value of a constraining facet.
public String getLexicalValue();
Returns the name of the constraining facet.
public String getName();
Checks whether facet is fixed and cannot be changed. Returns TRUE
for fixed, FALSE
otherwise.
public boolean isFixed();
Sets whether facet is fixed and cannot be changed. TRUE
for fixed, FALSE
otherwise.
public void setFixed( boolean fixed);
Parameter | Description |
---|---|
value |
Value being validated. |
Validates the value against the constraint facet.
public void validateFacet( XSDDataValue
value);
Parameter | Description |
---|---|
value |
Value being validated. |
This class represents data values for Schema Simple Type.
public class XSDDataValue extends java.lang.Object implements
oracle.xml.parser.schema.XSDTypeConstants
java.lang.Object
|
+--oracle.xml.parser.schema.XSDDataValue
XSDTypeConstants
Compares two values; returns -1 for smaller, 0 for equal, and 1 for greater. Throws XSDException
if the data values are not comparable.
public int compareTo( XSDDataValue
val);
Gets the length of STRING/BINARY value. Throws XSDException
if the data value is not of String/Binary type.
public int getLength();
Returns LEXICAL value from the XSDDataValue class.
public String getLexicalValue();
Returns the precision of decimal value. Throws XSDException
if the data values are not decimal type.
public int getPrecision();
Returns the int value of a decimal scale. Throws XSDException
if the data value is not decimal type.
public int getScale();
The XSDElement class represents the Schema element declaration.
public class XSDElement oracle.xml.parser.schema.XSDElement
Finds the equivalent class corresponding to this class.
public XSDElement
findEquivClass( String ns,
String nm);
Parameter | Description |
---|---|
ns |
Namespace. |
rm |
Name. |
Returns the value of 'default' attr in case of element, and the value of 'value' attr based on 'use' attribute.
public String getDefaultVal();
Returns the local name of the resolved equivalent class.
public String getEquivClassRef();
Returns the value of 'fixed' attr in case of element, and the value of 'value' attr based on 'use' attribute
public java.lang.String getFixedVal();
Returns the set of identities, as an array.
public XSDIdentity
getIdentities();
Returns the maxOccurs
public int getMaxOccurs();
Returns the minOccurs.
public int getMinOccurs();
Returns the name of the node.
public String getName();
Returns the local name of the resolved 'ref' attribute
public String getRefLocalname();
Returns the namespace of the resolved 'ref' attribute
public String getRefNamespace();
Returns refState. The return value is one of the following: TYPE_UNRESOLVED
, TYPE_RESOLVED
, REF_UNRESOLVED
, REF_RESOLVED
.
public int getRefState();
Returns the substitutionGroup
public java.util.Vector getSubstitutionGroup();
Returns target namespace.
public java.lang.String getTargetNS();
Returns the node type, either simpleType or complexType.
public XSDNode
getType();
Returns TRUE
if this element is abstract.
public boolean isAbstract();
Returns TRUE
if this element is nullable.
public boolean isNullable();
Sets the maxOccurs.
public void setMaxOccurs( int max);
Parameter | Description |
---|---|
maxOccurs |
value |
Sets the minOccurs.
public void setMinOccurs( int min);
Parameter | Description |
---|---|
minOccurs |
value |
Indicates that an exception occurred during XMLSchema validation.
java.lang.Object | +---java.lang.Throwable | +---java.lang.Exception | +---oracle.xml.parser.schema.XSDException public class XSDException extends Exception
Overrides getMessage() in class Throwable in order to construct error message from error id and error parameters. The options are described in the following table.
Syntax | Description |
---|---|
public String getMessage() |
Constructs error message from error id and error parameters |
XMLError err) |
Constructs localized error message based on the XMLError sent as parameter |
Parameter | Description |
---|---|
err |
XMLError class used to get the error message |
The XSDGroup class represents the Schema group definition.
public class XSDGroup oracle.xml.parser.schema.XSDGroup
Returns the maxOccurs.
public int getMaxOccurs();
Returns the minOccurs.
public int getMinOccurs();
Returns the particles of the group stored in nodeVector.
public java.util.Vector getNodeVector();
Returns the composite type - ALL
, SEQUENCE
, or CHOICE
public int getOrder();
Sets maxOccurs.
public void setMaxOccurs( int max);
Parameter | Description |
---|---|
maxOccurs |
value |
Sets the minOccurs.
public void setMinOccurs( int min);
Parameter | Description |
---|---|
minOccurs |
value |
This class represents Schema Identity-Constraint definition: Unique
, Key
, and Keyref
.
public class XSDIdentity extendsoracle.xml.parser.schema.XSDNode
oracle.xml.parser.schema.XSDNode
| +--oracle.xml.parser.schema.XSDIdentity
Method | Description |
---|---|
Returns the fields. |
|
Returns the node type. |
|
Returns the reference key. |
|
Returns the selector. |
Returns the fields.
public java.lang.String[] getFields();
Returns the node Type. Overrides XSDNode.getNodeType()
in class XSDNode.
public int getNodeType();
Returns the referenced key
public String getRefer();
Returns the selector.
public String getSelector();
Root class for most of XSD classes. Contains fields and methods corresponding to XMLSchema definition attributes.
public class XSDNode oracle.xml.parser.schema.XSDNode
XMLSchema
,XMLSchemaNode
,XSDAttribute
,XSDComplexType
,XSDIdentity
Method | Description |
---|---|
Returns the name of the node. |
|
Returns namespace uri for psv. |
|
Returns the type of XSDNode. |
|
Returns target namespace. |
|
Checks if the node is of the give type. |
Returns the name of the node.
public java.lang.String getName();
Returns namespace uri for psv.
public String getNamespaceURI()
Returns the type of XSDNode.
public int getNodeType();
Returns target namespace.
public java.lang.String getTargetNS();
Checks if the node is of the give type.
public boolean isNodeType( int type);
Parameter | Description |
---|---|
type |
Type of node that is being checked. |
This class represents Schema Simple Type definition.
public class XSDSimpleType implements oracle.xml.parser.schema.XSDTypeConstants
oracle.xml.parser.schema.XSDSimpleType
XSDTypeConstants
Class constructor. The options are described in the following table.
Syntax | Description |
---|---|
public XSDSimpleType(); |
Default constructor. |
String tnm); |
Implements W3C XMLSchema Datatype definition. |
Parameter | Description |
---|---|
basic |
Id of the Primitive type from which this one is derived. |
tnm |
Name of this type. |
Derives a type from the given base type. Throws XSDException
if new type cannot be created.
public staticXSDSimpleType
derivedFrom(XSDSimpleType
source, String nm, String var);
Parameter | Description |
---|---|
source |
XSDSimpleType The base type |
nm |
The name of the new type |
var |
The method of derivation |
Retrieves the base type.
public XSDSimpleType
getBase();
Retrieves the basic type from which this type was derived.
public int getBasicType();
Gets a built-in datatype. Throws XSDException
if the type is not a valid name.
public static Hashtable getBuiltInDatatypes();
Parameter | Description |
---|---|
type |
Name of the built-in type. |
Retrieves the facets.
public XSDConstrainingFacet
getFacets();
Retrieves value of maxOccurs.
public int getMaxOccurs();
Retrieves the value of minOccurs.
public int getMinOccurs();
Retrieves the variety of the type.
public java.lang.String getVariety();
Returns TRUE
if this type is abstract, FALSE
otherwise.
public boolean isAbstract();
Sets a facet for the datatype (Internal private API). Throws XSDException
if the facet is invalid.
public void setFacet( String facetName, String value);
Parameter | Description |
---|---|
facetName |
Name of the facet being set. |
value |
Value of the facet. |
Set the value of maxOccurs
public void setMaxOccurs(int max);
Parameter | Description |
---|---|
max |
Number of maximum occurrences. |
Set the value of minOccurs.
public void setMinOccurs( int min);
Parameter | Description |
---|---|
min |
Number of minimum occurrences. |
Sets the base type of the datatype, or in case of aggregate types sets the type of the component of the aggregate type. Throws SDException
if the src is not a valid type.
public void setSource( XSDNode
src);
Parameter | Description |
---|---|
src |
XSDNode source. |
Validates the string value with the facets defined for this type. Throws XSDException
if the value is not valid.
public void validateValue( String val);
Parameter | Description |
---|---|
val |
Value to be validated. |
This interface defines constants for the W3C Schema Processor.
public interface XSDTypeConstants
XSDValidator validates an instance XML document against an XMLSchema.
When registered, an XSDValidator object is inserted as a pipe-line node between XMLParser and XMLDocument events handler (SAXHandler or DOMBuilder). It works with three events: startElement()
, characters()
and endElement()
. If defined, default element and default attribute values are added to the events contents as XMLSchema additions to infoset, and are propagated upwards.
The XMLSchema object is a set or group of element declarations:
[element(name)] -> [shode(min/maxOccurs)] ->
[type(group/simpleType)]
XSDValidator is implemented as stack based state machine. Each state represents element type - group
or simpleType
.
XMLSchema object, as a group, is loaded as a first state. Current element
is matched against current state group elements. If matched the element type element name and snode info are loaded as new state.
In a case of group, a vector of counters
is allocated in a parallel stack. This vector is used to count element occurrences.
State status could be:
Text element contents, or event characters, are matched against simpleType
through method validateValue()
. End element, found through event endElement()
, is matched against yjr last named state.
XMLSchema attributes are represented as a group (attrName -> attrType
) forming the contents of special element: <_attrTag> attrType
. XMLParser converts attributes, found through event startElement()
, accordingly.
XSDAny objects are used as Namespace frame descriptors.
Fake states are loaded in a case of error or when wildcard('any') contents is skipped.
public class XSDValidator oracle.xml.parser.schema.XSDValidator
XSDValidator constructor.
public XSDValidator();
Propagate notification of character data inside an element. Throws org.xml.sax.SAXException
, which can be any SAX exception, possibly wrapping another exception. See also org.xml.sax.DocumentHandler
public void characters( char[] ch, int start, int length);
Parameter | Description |
---|---|
ch |
The characters |
start |
The start position in the character array. |
length |
The number of characters to use from the character array. |
Receive notification of the end of an element. Throws org.xml.sax.SAXException
, which can be any SAX exception, possibly wrapping another exception.
public void endElement( String namespaceURI, String localName, String qName);
Propagates Locator object for document events. See also org.xml.sax.DocumentHandler
, org.xml.sax.Locator.
public void setDocumentLocator( org.xml.sax.Locator locator);
Parameter | Description |
---|---|
locator |
A locator for all SAX document events |
Sets an XMLError object as current err. Throws org.xml.sax.SAXException
, which can be any SAX exception, possibly wrapping another exception.
public void setError( oracle.xml.parser.v2.XMLError he);
Parameter | Description |
---|---|
he |
XMLError object. |
Sets XML Properties for runtime properties.
public void setXMLProperties( XMLProperties xmlProp);
Parameter | Description |
---|---|
xmlProp |
XML properties. |
Sets and returns a property. The value of the property set is returned if successfully set, a null is returned if the property is read-only and cannot be set or is not supported.
public Object setXMLProperty( java.lang.String name, java.lang.Object value);
Parameter | Description |
---|---|
name |
name of the property |
value |
value of the property |
Receive notification of the beginning of an element. Throws org.xml.sax.SAXException
, which can be any SAX exception, possibly wrapping another exception. See also: endElement()
, org.xml.sax.Attributes.
public void startElement( String namespaceURI, String localName, String qName, Attributes atts);
|
Copyright © 2001, 2002 Oracle Corporation. All Rights Reserved. |
|