Skip Headers

Oracle9i XML API Reference - XDK and Oracle XML DB
Release 2 (9.2)

Part Number A96616-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to next page

6
XML Schema Processing

The full functionality of XML Schema Processor for Java is contained in the oracle.XML.parser.schema package.

This chapter discusses the following topics:


XMLSchema Class


Description of XMLSchema

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.


Syntax of XMLSchema

public class XMLSchemaNode extends oracle.xml.parser.schema.XSDNode
 
oracle.xml.parser.schema.XSDNode
  |
  +--oracle.xml.parser.schema.XMLSchemaNode


Methods of XMLSchema

Table 6-1 Summary of Methods of XML Schema
Constructor Description

XMLSchema()

XMLSchema constructor.

getAllTargetNS()

Returns all the Target Name space defined in the schema.

getSchemaByTargetNS()

Returns schemaNode for the given namespace.

getSchemaTargetNS()

Returns the top level schema's target Namespace.

getXMLSchemaNodeTable()

Returns XMLSchemaNode table.

getXMLSchemaURLS()

Returns XMLSchema URLs.

printSchema()

Print schema information.

XMLSchema()

Description

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

getAllTargetNS()

Description

Returns all the Target Name space defined in the schema.

Syntax

public java.lang.String[] getAllTargetNS();

getSchemaByTargetNS()

Description

Returns schemaNode for the given namespace.

Syntax

public XMLSchemaNode getSchemaByTargetNS( String namespace);

Parameter Description

namespace

Target namespace of the required schema.

getSchemaTargetNS()

Description

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.

Syntax

public String getSchemaTargetNS();

getXMLSchemaNodeTable()

Description

Returns XMLSchemaNode table as a hashtable.

Syntax

public java.util.Hashtable getXMLSchemaNodeTable();

getXMLSchemaURLS()

Description

Returns XMLSchema URLs as an array.

Syntax

public java.lang.String[] getXMLSchemaURLS();

printSchema()

Description

Print schema information. The options are described in the following table.

Syntax Description

public void printSchema();

Prints schema information.

public void printSchema(

boolean all);

Prints schema information, including build-ins.


Parameter Description

all

Flag to indicate that all information, including build-ins, should be printed


XMLSchemaNode


Description of XMLSchemaNode

This class contains sets of top level Schema components in a target namespace.


Syntax of XMLSchemaNode

public class XMLSchemaNode extends oracle.xml.parser.schema.XSDNode
 
oracle.xml.parser.schema.XSDNode
  |
  +--oracle.xml.parser.schema.XMLSchemaNode


Methods of XMLSchemaNode

Table 6-2 Summary of Methods of XMLSchemaNode
Method Description

XMLSchemaNode()

XMLSchema constructor.

getAttributeDeclarations()

Returns all the top level attributes in the schema.

getComplexTypeSet()

Returns all the top level complex type elements in the schema.

getComplexTypeTable()

Returns the complex type definitions.

getElementSet()

Returns all the top level elements in the schema.

getSimpleTypeSet()

Returns all the top level simpleType elements in the schema.

getSimpleTypeTable()

Returns the simple type definitions.

getTargetNS()

Returns targetNS of the schema.

getTypeDefinitionTable()

Returns the type definitions.

XMLSchemaNode()

Description

XMLSchema constructor.

Syntax

public  XMLSchemaNode();

getAttributeDeclarations()

Description

Returns all the top level attributes in the schema as an array.

Syntax

public XSDAttribute getAttributeDeclarations();

getComplexTypeSet()

Description

Returns all the top level complex type elements in the schema as an array.

Syntax

public XSDNode getComplexTypeSet();

getComplexTypeTable()

Description

Returns the complex type definitions as a hashtable.

Syntax

public java.util.Hashtable getComplexTypeTable();

getElementSet()

Description

Returns all the top level elements in the schema as an array.

Syntax

public XSDNode getElementSet();

getSimpleTypeSet()

Description

Returns all the top level simpleType elements in the schema as an array.

Syntax

public XSDNode getSimpleTypeSet();

getSimpleTypeTable()

Description

Returns the simple type definitions, in a hashtable.

Syntax

public java.util.Hashtable getSimpleTypeTable();

getTargetNS()

Description

Returns targetNS of the schema. Overrides XSDNode.getTargetNS() in class XSDNode.

Syntax

public String getTargetNS();

getTypeDefinitionTable()

Description

Returns the type definitions as a hashtable.

Syntax

public java.util.Hashtable getTypeDefinitionTable();

XSDAttribute Class


Description of XSDAttribute

This class represents Schema Attribute declaration.


Syntax of XSDAttribute

public class XSDAttribute extends oracle.xml.parser.schema.XSDNode
 
oracle.xml.parser.schema.XSDNode
  |
  +--oracle.xml.parser.schema.XSDAttribute


Methods of XSDAttribute

Table 6-3 Summary of Methods of XSDAttribute  
Method Description

getDefaultVal()

Returns the value of 'default' attributes in case of element, and the value of 'value' attributes based on 'use' attribute.

getFixedVal()

Returns the value of 'fixed' attribute in case of element, and the value of 'value' attribute based on 'use' attribute.

getName()

Returns the name of the node.

getRefLocalname()

Returns he local name of the resolved 'ref' attribute.

getRefNamespace()

Returns the namespace of the resolved 'ref' attribute.

getRefState()

Returns refState.

getTargetNS()

Returns target namespace.

getType()

Returns the node type.

isRequired()

Checks if the attribute is required.

getDefaultVal()

Description

Returns the value of 'default' attr in case of element, and the value of 'value' attr based on 'use' attribute.

Syntax

public String getDefaultVal();

getFixedVal()

Description

Returns the default value of 'fixed' attr in case of element, and the value of 'value' attr based on 'use' attribute.

Syntax

public java.lang.String getFixedVal();

getName()

Description

Returns the name of the node. Overrides XSDNode.getName() in class XSDNode.

Syntax

public String getName();

getRefLocalname()

Description

Returns the refLocal name of the resolved 'ref' attribute

Syntax

public String getRefLocalname();

getRefNamespace()

Description

Returns the RefNamespace of the resolved 'ref' attribute.

Syntax

public String getRefNamespace();

getRefState()

Description

Returns refState value. The return value is one of the following: TYPE_UNRESOLVED, TYPE_RESOLVED, REF_UNRESOLVED, REF_RESOLVED.

Syntax

public int getRefState();

getTargetNS()

Description

Returns target namespace. XSDNode.getTargetNS() in class XSDNode.

Syntax

public String getTargetNS();

getType()

Description

Returns the node type which is either simpleTypeor complexType.

Syntax

public XSDNode getType();

isRequired()

Description

Checks if the attribute is required.

Syntax

public boolean isRequired();

XSDBuilder Class


Description of XSDBuilder

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).


Syntax of XSDBuilder

public class XSDBuilder

Methods of XSDBuilder

Table 6-4 Summary of Methods of XSDBuilder  
Method Description

XSDBuilder()

Class constructor.

build()

Builds an XMLSchema object or document.

getObject()

Returns XML schema object.

setEntityResolver()

Sets an EntityResolver for resolving imports/include.

setError()

Sets XMLError object.

setLocale()

Sets locale for error reporting.

XSDBuilder()

Description

XSDBuilder constructor.

Syntax

public XSDBuilder() throws XSDException;

build()

Description

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.

Syntax Description

public Object build(

InputStream in,

URL baseurl);

Builds an XMLSchema object from an input stream and a URL.

public Object build(

Reader r,

URL baseurl);

Builds an XMLSchema object from a reader and a URL.

public Object build(

String sysId);

Builds an XMLSchema object from system id.

public Object build(

String ns,

String sysid);

Builds an XMLSchema object from a namespace and system id.

public Object build(

String ns,

URL sysid);

Builds an XMLSchema object from a namespace and URL.

public Object build(

URL schemaurl);

Builds an XMLSchema object from a URL.

public Object build(

XMLDocument schemaDoc);

Builds XMLSchema from XML document.

public Object build(

XMLDocument[] schemaDocs,

URL baseurl);

Builds XMLSchema from an array of XML documents and a URL.

public Object build(

XMLDocument doc,

String fragment,

String ns,

URL sysid);

Build an XMLSchema object from XML document, a fragment, namespace, and system id.

public Object build(

XMLDocument schemaDoc,

URL baseurl);

Build XMLSchema from XML document and URL.

Parameter Description

baseurl

URL used to resolve any relative refs; used for any import/include in document

doc

XMLdocument contain the schema element

fragment

Fragment ID of the schema element

in

Inputstream of Schema

ns

Schema target namespace used to validate targetNamespace

r

Reader of Schema

schemaDoc

XMLDocument

schemaDocs

Array of XMLDocuments

sysId

Schema location

url

URL of Schema

getObject()

Description

Returns XML schema object.

Syntax

public Object getObject();

setEntityResolver()

Description

Sets an EntityResolver for resolving imports/include. See also org.xml.sax.EintityResolver.

Syntax

public void setEntityResolver( org.xml.sax.entityResolver entResolver);

Parameter Description

entResolver

EntityResolver

setError()

Description

Sets XMLError object.

Syntax

public void setError( XMLError er);


Parameter Description

er

XMLError object

setLocale()

Description

Sets locale for error reporting.

Syntax

public void setLocale(L ocale locale);

Parameter Description

locale

Locale object


XSDComplexType Class


Description of XSDComplexType

This class represents the Schema ComplexType definition.


Syntax of XSDComplexType

public class XSDComplexType extends oracle.xml.parser.schema.XSDNode
 
oracle.xml.parser.schema.XSDNode
  |
  +--oracle.xml.parser.schema.XSDComplexType


Methods XSDComplexType

Table 6-5 Summary of Methods of XSDComplexType  
Method Description

getAttributeDeclarations()

Returns attribute declarations of this complex type.

getAttributeWildcard()

Returns attribute wildcard of this complex type.

getBaseType()

Returns the base type of this complextype.

getContent()

Returns content of XSDComplexType.

getDerivationMethod()

Returns information on how was this type derived from its parent type.

getElementSet()

Returns an array of all the local elements inside a complexType element.

getGroup()

Returns the attribute group or the child & attribute group.

getRefLocalname()

Returns the local name of resolved 'base' attr.

getTypeGroup()

Returns type group of Complex Type.

init()

Initializes complex type.

isAbstract()

Returns TRUE if the Complex Type is abstract.

getAttributeDeclarations()

Description

Returns attribute declarations of this complex type; does not include wild card array of attribute declarations.

Syntax

public XSDAttribute getAttributeDeclarations();

getAttributeWildcard()

Description

Returns attribute wildcard of this complex type.

Syntax

public oracle.xml.parser.schema.XSDAny getAttributeWildcard();

Returns

The attribute wildcard if has one

getBaseType()

Description

Returns the base type of this complextype.

Syntax

public XSDNode getBaseType();

getContent()

Description

Returns content of XSDComplexType.

Syntax

public int getContent();

getDerivationMethod()

Description

Returns information on how was this type derived from its parent type. One of EXTENSION_DERIVATION or RESTRICTION_DERIVATION.

Syntax

public short getDerivationMethod();

getElementSet()

Description

Returns an array of all the local elements inside a complexType element.

Syntax

public XSDNode getElementSet();

getGroup()

Description

Returns the attribute group or the child & attribute group.

Syntax

public XSDGroup getGroup();

getRefLocalname()

Description

Returns the local name of resolved 'base' attr.

Syntax

public java.lang.String getRefLocalname();

getTypeGroup()

Description

Returns type group of Complex Type.

Syntax

public XSDGroup getTypeGroup();

init()

Description

Initializes complex type.

Syntax

public static void init();

isAbstract()

Description

Returns TRUE if the Complex Type is abstract.

Syntax

public boolean isAbstract();

XSDConstrainingFacet Class


Description of XSDConstrainingFacet

This class represents Schema Constraining facet for Data Type.


Syntax of XSDConstrainingFacet

public class XSDConstrainingFacet extends java.lang.Object implements 
oracle.xml.parser.schema.XSDTypeConstants
 
java.lang.Object
  |
  +--oracle.xml.parser.schema.XSDConstrainingFacet


Implemented Interfaces of XSDConstrainingFacet

XSDTypeConstants


Methods of XSDConstrainingFacet

Table 6-6 Summary of Methods of XSDConstrainingFacet  
Method Description

getFacetId()

Returns the facet id.

getLexicalEnumeration()

Returns the LEXICAL enumeration of the constraining facet.

getLexicalValue()

Returns the LEXICAL value of the constraining facet.

getName()

Returns the name of the constraining facet.

isFixed()

Checks whether facet is fixed and cannot be changed.

setFixed()

Sets if the facet is fixed and cannot be changed.

validateFacet()

Validates the value against the constraint facet.

getFacetId()

Description

Returns the facet id.

Syntax

public int getFacetId();

getLexicalEnumeration()

Description

Returns the LEXICAL enumeration of the constraining facet.

Syntax

public java.util.Vector getLexicalEnumeration();

getLexicalValue()

Description

Returns the LEXICAL value of a constraining facet.

Syntax

public String getLexicalValue();

getName()

Description

Returns the name of the constraining facet.

Syntax

public String getName();

isFixed()

Description

Checks whether facet is fixed and cannot be changed. Returns TRUE for fixed, FALSE otherwise.

Syntax

public boolean isFixed();

setFixed()

Description

Sets whether facet is fixed and cannot be changed. TRUE for fixed, FALSE otherwise.

Syntax

public void setFixed( boolean fixed);

Parameter Description

value

Value being validated.

validateFacet()

Description

Validates the value against the constraint facet.

Syntax

public void validateFacet( XSDDataValue value);

Parameter Description

value

Value being validated.


XSDDataValue Class


Description of XSDDataValue

This class represents data values for Schema Simple Type.


Syntax of XSDDataValue

public class XSDDataValue extends java.lang.Object implements 
oracle.xml.parser.schema.XSDTypeConstants
 
java.lang.Object
  |
  +--oracle.xml.parser.schema.XSDDataValue


Implemented Interfaces of XSDDataValue

XSDTypeConstants


Methods of XSDDataValue

Table 6-7 Summary of Methods of XSDDataValue  
Method Description

compareTo()

Compares two values returns -1 for smaller, 0 for equal, and 1 for greater.

getLength()

Returns the length of STRING/BINARY value.

getLexicalValue()

Returns LEXICAL value from the XSDDataValue class.

getPrecision()

Returns the precision of decimal value.

getScale()

Returns the scale of decimal value.

compareTo()

Description

Compares two values; returns -1 for smaller, 0 for equal, and 1 for greater. Throws XSDException if the data values are not comparable.

Syntax

public int compareTo( XSDDataValue val);

getLength()

Description

Gets the length of STRING/BINARY value. Throws XSDException if the data value is not of String/Binary type.

Syntax

public int getLength();

getLexicalValue()

Description

Returns LEXICAL value from the XSDDataValue class.

Syntax

public String getLexicalValue();

getPrecision()

Description

Returns the precision of decimal value. Throws XSDException if the data values are not decimal type.

Syntax

public int getPrecision();

getScale()

Description

Returns the int value of a decimal scale. Throws XSDException if the data value is not decimal type.

Syntax

public int getScale();

XSDElement Class


Description of XSDElement

The XSDElement class represents the Schema element declaration.


Syntax of XSDElement

public class XSDElement
 
oracle.xml.parser.schema.XSDElement


Methods of XSDElement

Table 6-8 Summary of Methods of XSDElement  
Method Description

findEquivClass()

Finds the equivalent class corresponding to this class.

getDefaultVal()

Returns the value of 'default' attr in case of element, and the value of 'value' attr based on 'use' attribute.

getEquivClassRef()

Returns the local name of the resolved equivalent class.

getFixedVal()

Returns the value of 'fixed' attr in case of element, and the value of 'value' attr based on 'use' attribute.

getIdentities()

Returns the set of identities.

getMaxOccurs()

Returns the maxOccurs.

getMinOccurs()

Returns the minOccurs.

getName()

Returns Name.

getRefLocalname()

Returns the local name of the resolved 'ref' attribute.

getRefNamespace()

Returns the namespace of the resolved 'ref' attribute.

getRefState()

Returns refState.

getSubstitutionGroup()

Returns the substitutionGroup.

getTargetNS()

Sets target namespace.

getType()

Sets the node type.

isAbstract()

Returns TRUE if element abstract.

isNullable()

Returns TRUE if element nullable.

setMaxOccurs()

Sets the maxOccurs.

setMinOccurs()

Sets the minOccurs.

findEquivClass()

Description

Finds the equivalent class corresponding to this class.

Syntax

public XSDElement findEquivClass( String ns, 
                                  String nm);

Parameter Description

ns

Namespace.

rm

Name.

getDefaultVal()

Description

Returns the value of 'default' attr in case of element, and the value of 'value' attr based on 'use' attribute.

Syntax

public String getDefaultVal();

getEquivClassRef()

Description

Returns the local name of the resolved equivalent class.

Syntax

public String getEquivClassRef();

getFixedVal()

Description

Returns the value of 'fixed' attr in case of element, and the value of 'value' attr based on 'use' attribute

Syntax

public java.lang.String getFixedVal();

getIdentities()

Description

Returns the set of identities, as an array.

Syntax

public XSDIdentity getIdentities();

getMaxOccurs()

Description

Returns the maxOccurs

Syntax

public int getMaxOccurs();

getMinOccurs()

Description

Returns the minOccurs.

Syntax

public int getMinOccurs();

getName()

Description

Returns the name of the node.

Syntax

public String getName();

getRefLocalname()

Description

Returns the local name of the resolved 'ref' attribute

Syntax

public String getRefLocalname();

getRefNamespace()

Description

Returns the namespace of the resolved 'ref' attribute

Syntax

public String getRefNamespace();

getRefState()

Description

Returns refState. The return value is one of the following: TYPE_UNRESOLVED, TYPE_RESOLVED, REF_UNRESOLVED, REF_RESOLVED.

Syntax

public int getRefState();

getSubstitutionGroup()

Description

Returns the substitutionGroup

Syntax

public java.util.Vector getSubstitutionGroup();

getTargetNS()

Description

Returns target namespace.

Syntax

public java.lang.String getTargetNS();

getType()

Description

Returns the node type, either simpleType or complexType.

Syntax

public XSDNode getType();

isAbstract()

Description

Returns TRUE if this element is abstract.

Syntax

public boolean isAbstract();

isNullable()

Description

Returns TRUE if this element is nullable.

Syntax

public boolean isNullable();

setMaxOccurs()

Description

Sets the maxOccurs.

Syntax

public void setMaxOccurs( int max);

Parameter Description

maxOccurs

value

setMinOccurs()

Description

Sets the minOccurs.

Syntax

public void setMinOccurs( int min);

Parameter Description

minOccurs

value


XSDException


Description of XSDException

Indicates that an exception occurred during XMLSchema validation.


Syntax of XSDException

java.lang.Object
   |
   +---java.lang.Throwable
           |
           +---java.lang.Exception
                   |
                   +---oracle.xml.parser.schema.XSDException

public class XSDException extends Exception 

getMessage()

Description

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

public String getMessage(

XMLError err)

Constructs localized error message based on the XMLError sent as parameter


Parameter Description

err

XMLError class used to get the error message


XSDGroup Class


Description of XSDGroup

The XSDGroup class represents the Schema group definition.


Syntax of XSDGroup

public class XSDGroup
 
oracle.xml.parser.schema.XSDGroup


Methods of XSDGroup

Table 6-9 Summary of Methods of XSDIdentity  
Method Description

getMaxOccurs()

Returns the maxOccurs.

getMinOccurs()

Returns the minOccurs.

getNodeVector()

Returns the particles of the group stored in nodeVector.

getOrder()

Returns the composite type - ALL, SEQUENCE, CHOICE.

setMaxOccurs()

Sets maxOccurs.

setMinOccurs()

Sets minOccurs.

getMaxOccurs()

Description

Returns the maxOccurs.

Syntax

public int getMaxOccurs();

getMinOccurs()

Description

Returns the minOccurs.

Syntax

public int getMinOccurs();

getNodeVector()

Description

Returns the particles of the group stored in nodeVector.

Syntax

public java.util.Vector getNodeVector();

getOrder()

Description

Returns the composite type - ALL, SEQUENCE, or CHOICE

Syntax

public int getOrder();

setMaxOccurs()

Description

Sets maxOccurs.

Syntax

public void setMaxOccurs( int max);

Parameter Description

maxOccurs

value

setMinOccurs()

Description

Sets the minOccurs.

Syntax

public void setMinOccurs( int min);

Parameter Description

minOccurs

value


XSDIdentity Class


Description of XSDIdentity

This class represents Schema Identity-Constraint definition: Unique, Key, and Keyref.


Syntax of XSDIdentity

public class XSDIdentity extends oracle.xml.parser.schema.XSDNode
 
oracle.xml.parser.schema.XSDNode
  |
  +--oracle.xml.parser.schema.XSDIdentity


Methods of XSDIdentity

Table 6-10 Summary of Methods of XSDIdentity
Method Description

getFields()

Returns the fields.

getNodeType()

Returns the node type.

getRefer()

Returns the reference key.

getSelector()

Returns the selector.

getFields()

Description

Returns the fields.

Syntax

public java.lang.String[] getFields();

getNodeType()

Description

Returns the node Type. Overrides XSDNode.getNodeType() in class XSDNode.

Syntax

public int getNodeType();

getRefer()

Description

Returns the referenced key

Syntax

public String getRefer();

getSelector()

Description

Returns the selector.

Syntax

public String getSelector();

XSDNode Class


Description of XSDNode

Root class for most of XSD classes. Contains fields and methods corresponding to XMLSchema definition attributes.


Syntax of XSDNode

public class XSDNode
 
oracle.xml.parser.schema.XSDNode


Direct Subclasses of XSDNode

XMLSchema, XMLSchemaNode, XSDAttribute, XSDComplexType, XSDIdentity


Methods of XSDNode

Table 6-11 Summary of Methods of XSDNode  
Method Description