WebLogic Integration


com.bea.schema
Class SOMSchema

java.lang.Object
  |
  +--com.bea.schema.SOMObject
        |
        +--com.bea.schema.SOMSchema

public class SOMSchema
extends SOMObject

<schema> The SOMSchema object is the building block for the Schema Object Model, SOM. The top level <schema> element is represented by the SOMSchema object and all sub-elements are linked underneath this object.

A schema is represented in XML by one or more schema documents, that is, one or more schema element information items. A schema document contains representations for a collection of schema components, e.g. type definitions and element declarations, which have a common {target namespace}.

The SOM allows the output of XML but is represented internally by a hierarchy of objects known as the Schema Object Model. SOMSchema is the object that represents the top level schema element to which everything must be added.

Author:
Copyright © 2000, 2001 BEA Systems, Inc. All Rights Reserved.
See Also:
Serialized Form

Field Summary
static java.lang.String NAMESPACE_2001
           
static java.lang.String NAMESPACE_OCT2000
           
 
Constructor Summary
SOMSchema()
          Create an empty top schema level object
SOMSchema(org.xml.sax.InputSource inputSource, boolean canonical, boolean debugMessages)
          Load a schema from an XML instance document in a file.
SOMSchema(java.io.Reader xml)
          Load a schema from stringified XML using the default SAX parser.
SOMSchema(java.lang.String xmlString)
          Load a schema from serialized XML using the default SAX parser.
SOMSchema(java.lang.String xmlString, boolean canonical, boolean debugMessages)
          Load a schema from stringified XML using the default SAX parser.
SOMSchema(java.lang.String xmlString, java.lang.String encoding)
          Load a schema from stringified XML using the default SAX parser.
SOMSchema(org.xml.sax.XMLReader parser, org.xml.sax.InputSource inputSource, boolean canonical, boolean debugMessages)
          Load a schema from an XML instance document in a file.
 
Method Summary
 SOMAnnotation addAnnotation()
          create a new empty annotation element within this schema.
 SOMAnnotation addAnnotation(SOMAnnotation annotation)
          add an annotation to the schema tree.
 void addAttribute(java.lang.String name, java.lang.String value)
          add attributes to the <schema> element.
 SOMAttribute addAttributeElement(SOMAttribute child)
          Adds a previously created <attribute> object to the root of the schema object model.
 SOMAttribute addAttributeElement(java.lang.String name)
          Creates a SOMAttribute object with the given name and adds the <attribute> to the root level of this schema.
 SOMAttributeGroup addAttributeGroup(SOMAttributeGroup child)
          Adds a previously created <attributeGroup> object to the root of the schema object model.
 SOMAttributeGroup addAttributeGroup(java.lang.String name)
          Creates a SOMAttributeGroup object with the given name and adds the <attributeGroup> to the root level of this schema.
 SOMComplexType addComplexType(SOMComplexType child)
          Adds the complexType to the root level of this schema.
 SOMComplexType addComplexType(java.lang.String name)
          Creates a SOMComplexType object with the given name and adds the to the root level of this schema.
 SOMDocumentation addDocumentation(java.lang.String info)
          adds a documentation element to a new annotation element for this schema.
 SOMElement addElement(SOMElement child)
          Adds a previously created <element> object to the root of the schema object model.
 SOMElement addElement(java.lang.String name)
          Creates a SOMElement object with the given name and adds the <element> to the root level of this schema.
 SOMGroup addGroup(SOMGroup child)
          Adds a previously created <roup> object to the root of the schema object model.
 SOMGroup addGroup(java.lang.String name)
          Creates a SOMGroup object with the given name and adds the <group> to the root level of this schema.
 SOMSimpleType addSimpleType(SOMSimpleType child)
          Adds the simpleType to the root level of this schema.
 SOMSimpleType addSimpleType(java.lang.String name)
          Creates a SOMSimpleType object with the given name and adds the object to the root level of this schema.
 IDocument createDefaultDocument(DefaultDocumentOptions options)
          create an XML instance document template based on this schema model.
 java.util.Iterator getAnnotations()
          Returns an Iterator over all the annotations contained at the root level of this schema.
 java.util.Iterator getAttributeElements()
          Returns an Iterator over all the attributes contained at the root level of this schema.
 java.util.Iterator getAttributes()
          Returns an Iterator over all the attributes in the schema element.
 java.util.Iterator getComplexTypes()
          Returns an Iterator over all the complexTypes contained at the root level of this schema.
 java.lang.String getDefaultNameSpace()
          get the schema xmlns:xsd attribute.
 SOMElement getElement(java.lang.String locationString)
          Lookup an element within this schema.
 java.util.Iterator getElements()
          Returns an Iterator over all the elements contained at the root level of this schema.
 java.util.Iterator getGroups()
          Returns an Iterator over all the groups contained at the root level of this schema.
 java.lang.String getID()
           
 java.util.Iterator getSimpleTypes()
          Returns an Iterator over all the simpleTypes contained at the root level of this schema.
 boolean hasUnresolvedReferences()
           
 boolean hasUnresolvedTypes()
           
 boolean isValid(org.w3c.dom.Document doc, java.util.List errorList)
          Validates an XML Document against an XML Schema.
 boolean isValid(IDocument doc, java.util.List errorList)
          Validates an XML Document against an XML Schema.
 boolean isValid(org.w3c.dom.Node rootElement, java.util.List errorList)
          Validates an XML Document against an XML Schema.
 boolean isValidatingContent()
          current content validation setting.
 SOMAttributeGroup lookupAttrGrpReference(java.lang.String registeredName)
          Returns a reference to an attributeGroup previously added to this schema object.
 SOMElement lookupElement(java.lang.String registeredName)
          Returns a reference to an SOMElement previously added to this schema object.
 SOMReference lookupReference(java.lang.String registeredName)
          Returns a reference to an element previously added to this schema object.
 SOMType lookupTypeReference(java.lang.String registeredTypeName)
          Returns a reference to a type previously added to this schema object.
 SOMAnnotation removeAnnotation(SOMAnnotation note)
          remove an annotation and all of its children from the root level of this schema
 SOMAttribute removeAttribute(java.lang.String name)
          remove an attribute from the root level of this schema
 SOMComplexType removeComplexType(java.lang.String name)
          remove a complexType from the root level of this schema
 SOMElement removeElement(java.lang.String name)
          remove an element from the root level of this schema
 SOMGroup removeGroup(java.lang.String name)
          remove an group from the root level of this schema
 SOMSimpleType removeSimpleType(java.lang.String name)
          remove a simpleType from the root level of this schema
 void resolveReferences()
          Resolve unresolved elements in this schema.
 void resolveTypes()
          Resolve unresolved element types in this schema.
 void setContentValidation(boolean value)
          toggle element and attribute content validation.
 void setDefaultNamespace(java.lang.String xmlns_xsd)
          manually override the XMLSchema namespace - NOT RECOMMENDED.
 void toXML(java.io.Writer rtn, int indent)
          For debugging, display, and printing purposes, the XML Schema Object model can be represented as a character string.
 
Methods inherited from class com.bea.schema.SOMObject
attributesToXML, doIndent, getID_UQ, getParent, getParentSchema, isCircularReference, isSchemaChild, removeNamespaceQualifier, setIndent, setParent, toString, toXML, toXML, toXML, trace, trace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NAMESPACE_OCT2000

public static final java.lang.String NAMESPACE_OCT2000

NAMESPACE_2001

public static final java.lang.String NAMESPACE_2001
Constructor Detail

SOMSchema

public SOMSchema()
Create an empty top schema level object

SOMSchema

public SOMSchema(java.lang.String xmlString)
          throws org.xml.sax.SAXException
Load a schema from serialized XML using the default SAX parser. A default SAXParser is loaded using JAXP SAXParserFactory. This constructor serves as the reverse process to the SOMSchema toString() method.

Parameters:
xmlString - the XML in parsable string format
Throws:
org.xml.sax.SAXException -  
java.io.UnsupportedEncodingException -  

SOMSchema

public SOMSchema(java.lang.String xmlString,
                 java.lang.String encoding)
          throws org.xml.sax.SAXException,
                 java.io.UnsupportedEncodingException
Load a schema from stringified XML using the default SAX parser. A default SAXParser is loaded using JAXP SAXParserFactory. This constructor serves as the reverse process to the SOMSchema toXML(encoding) method.

Parameters:
xmlString - the XML in parsable string format
encoding -  
Throws:
org.xml.sax.SAXException -  
java.io.UnsupportedEncodingException -  

SOMSchema

public SOMSchema(java.lang.String xmlString,
                 boolean canonical,
                 boolean debugMessages)
          throws org.xml.sax.SAXException
Load a schema from stringified XML using the default SAX parser. A default SAXParser is loaded using JAXP SAXParserFactory.

Parameters:
xmlString - the XML in parsable string format
canonical - for future use
debugMessages - print debug messages for loading InputSource to SOMSchema to stdout

SOMSchema

public SOMSchema(java.io.Reader xml)
          throws org.xml.sax.SAXException
Load a schema from stringified XML using the default SAX parser. A default SAXParser is loaded using JAXP SAXParserFactory.

SOMSchema

public SOMSchema(org.xml.sax.InputSource inputSource,
                 boolean canonical,
                 boolean debugMessages)
          throws org.xml.sax.SAXException
Load a schema from an XML instance document in a file. A default SAXParser is loaded using JAXP SAXParserFactory. Example:
 
     SOMSchema mySchema = null;
     java.io.Reader myInput;
     ...
     org.xml.sax.InputSource myInputSource = new org.xml.sax.InputSource(myInput);
 
     try
     {
       mySchema = new SOMSchema(myInputSource, false, false);
     }
     catch (org.xml.sax.SAXException se)
     {
       System.err.println(se.getMessage());
     }
     catch ( Exception e )
     {
       e.printStackTrace();
     }
 

Parameters:
inputSource - the input source to parse
canonical - for future use
debugMessages - print debug messages for loading InputSource to SOMSchema to stdout

SOMSchema

public SOMSchema(org.xml.sax.XMLReader parser,
                 org.xml.sax.InputSource inputSource,
                 boolean canonical,
                 boolean debugMessages)
          throws org.xml.sax.SAXException
Load a schema from an XML instance document in a file.

Parameters:
parser - a SAX parser
inputSource - the input source to parse
canonical - for future use
debugMessages - print debug messages for loading InputSource to SOMSchema to stdout
Method Detail

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String value)
add attributes to the <schema> element. addAttribute can be used to add additional namespace targets, as well as, any other xsd:schema attributes. For example, addAttribute("schemaLocation", "book.xsd"); would add the attribute to the schema as: <xsd:schema schemaLocation="book.xsd">

Parameters:
name - attribute name
value - attribute value

addAttributeElement

public SOMAttribute addAttributeElement(java.lang.String name)
Creates a SOMAttribute object with the given name and adds the <attribute> to the root level of this schema. The object to the newly created element object is returned to you for modification, if necessary.

Parameters:
name - The name attribute for the created <attribute>
Returns:
The object reference of the newly created SOMAttribute

addAttributeElement

public SOMAttribute addAttributeElement(SOMAttribute child)
Adds a previously created <attribute> object to the root of the schema object model.

Parameters:
child -  
Returns:
object reference to the same object passed as a parameter

addAttributeGroup

public SOMAttributeGroup addAttributeGroup(java.lang.String name)
Creates a SOMAttributeGroup object with the given name and adds the <attributeGroup> to the root level of this schema. The object to the newly created element object is returned to you for modification, if necessary.

Parameters:
name - The name attribute for the created <attributeGroup>
Returns:
The object reference of the newly created SOMAttributeGroup

addAttributeGroup

public SOMAttributeGroup addAttributeGroup(SOMAttributeGroup child)
Adds a previously created <attributeGroup> object to the root of the schema object model.

Parameters:
child -  
Returns:
object reference to the same object passed as a parameter

addGroup

public SOMGroup addGroup(java.lang.String name)
Creates a SOMGroup object with the given name and adds the <group> to the root level of this schema. The object to the newly created element object is returned to you for modification, if necessary.

Parameters:
name - The name attribute for the created <group>
Returns:
The object reference of the newly created SOMGroup

addGroup

public SOMGroup addGroup(SOMGroup child)
Adds a previously created <roup> object to the root of the schema object model. The group element must have a name attribute to be added at the root level of the schema.

Parameters:
child -  
Returns:
object reference to the same object passed as a parameter

addElement

public SOMElement addElement(java.lang.String name)
Creates a SOMElement object with the given name and adds the <element> to the root level of this schema. The object to the newly created element object is returned to you for modification, if necessary. Elements added at this level can be used as root elements when creating an instance document.

Parameters:
name - The name attribute for the created <element>
Returns:
The object reference of the newly created SOMElement

addElement

public SOMElement addElement(SOMElement child)
Adds a previously created <element> object to the root of the schema object model. Elements added at this level can be used as root elements when creating an instance document.

Parameters:
child -  
Returns:
object reference to the same object passed as a parameter

addComplexType

public SOMComplexType addComplexType(java.lang.String name)
Creates a SOMComplexType object with the given name and adds the to the root level of this schema. The object to the newly created complexType object is returned to you for modification, if necessary.

Parameters:
name - at the root level of the schema must must have an identity/name.
Returns:
the newly create object

addComplexType

public SOMComplexType addComplexType(SOMComplexType child)
Adds the complexType to the root level of this schema. If the complexType being added is already a member of a tree, it will first be removed and then added to this schema tree.

Parameters:
child - the complexType to add
Returns:
the complexType object

addSimpleType

public SOMSimpleType addSimpleType(java.lang.String name)
Creates a SOMSimpleType object with the given name and adds the object to the root level of this schema. A referemce to the newly created simpleType object is returned.

Parameters:
name - at the root level of the schema must must have an identity/name.
Returns:
the newly created object

addSimpleType

public SOMSimpleType addSimpleType(SOMSimpleType child)
Adds the simpleType to the root level of this schema. If the simpleType being added is already a member of a tree, it will first be removed and then added to this schema tree.

Parameters:
child - the simpleType to add
Returns:
the simpleType object

addDocumentation

public SOMDocumentation addDocumentation(java.lang.String info)
adds a documentation element to a new annotation element for this schema. This method will create a new annotation at the root of this schema and then add the new documentation element to that annotation. Same as:
 SOMSchema mySchema ...
 ...
 SOMAnnotation note = mySchema.addAnnotation();
 note.addDocumentation(info);
 

Parameters:
info - The documentation string to be added
Returns:
a reference to the newly created documentation object

addAnnotation

public SOMAnnotation addAnnotation()
create a new empty annotation element within this schema. The annotation object is created and then added to the SOMSchema tree.

Returns:
the newly created annotation object.

addAnnotation

public SOMAnnotation addAnnotation(SOMAnnotation annotation)
add an annotation to the schema tree. If the annotation exists in another tree, it will first be removed and then added to this tree.

Parameters:
annotation - a previously created annotation
Returns:
the annotation that was added.

getID

public java.lang.String getID()

Overrides:
getID in class SOMObject

getDefaultNameSpace

public java.lang.String getDefaultNameSpace()
get the schema xmlns:xsd attribute.

Returns:
 

setDefaultNamespace

public void setDefaultNamespace(java.lang.String xmlns_xsd)
manually override the XMLSchema namespace - NOT RECOMMENDED. If you are working with tools that do not support the namespace at http://www.w3.org/2001/XMLSchema, this method can be used to override the xmlns attribute for the SOMSchema. This is NOT recommended. The SOM is based on the March 3, 2001 XML Schema standard. Oct, 2000 types are available, but deprecated.

Parameters:
xmlns_xsd - namespace URL

getComplexTypes

public java.util.Iterator getComplexTypes()
Returns an Iterator over all the complexTypes contained at the root level of this schema.

Returns:
an Iterator over the SOMComplexType's contained by this SOMSchema

getSimpleTypes

public java.util.Iterator getSimpleTypes()
Returns an Iterator over all the simpleTypes contained at the root level of this schema.

Returns:
an Iterator over the SOMSimpleType's contained by this SOMSchema

getElements

public java.util.Iterator getElements()
Returns an Iterator over all the elements contained at the root level of this schema.

Returns:
an Iterator over the SOMElement's contained by this SOMSchema

getElement

public SOMElement getElement(java.lang.String locationString)
Lookup an element within this schema. Using a virtual path, the reference to the SOMElement is returned. For example, using the virtual path string "/purchaseOrder/items/item" on the PurchaseOrder schema would return a reference to the SOMElement name="item".

Virtual Path nodes must be separated by the forward slash, "/"

Parameters:
locationString - a virtual element path where nodes are separated by the forward slash, "/"
Returns:
SOMElement or null if locationString could not be resolved.

getGroups

public java.util.Iterator getGroups()
Returns an Iterator over all the groups contained at the root level of this schema.

Returns:
an Iterator over the SOMGroup's contained by this SOMSchema

getAttributeElements

public java.util.Iterator getAttributeElements()
Returns an Iterator over all the attributes contained at the root level of this schema.

Returns:
an Iterator over the SOMAttribute's contained by this SOMSchema

getAttributes

public java.util.Iterator getAttributes()
Returns an Iterator over all the attributes in the schema element. The list will not contain the default namespace, but will include all attributes added with the addAttribute method. The Iterator remove method should be used to remove attributes from the schema element tag.

Returns:
an Iterator over the attributes in this schema tag

hasUnresolvedReferences

public boolean hasUnresolvedReferences()

hasUnresolvedTypes

public boolean hasUnresolvedTypes()

resolveReferences

public void resolveReferences()
Resolve unresolved elements in this schema. If SOMUnresolvedReferences were inserted into this schema during construction, using this method will attempt to resolve and replace unresolved element references with actual references. Use hasUnresolvedRefereces method to determine if any exist in this schema.

resolveTypes

public void resolveTypes()
Resolve unresolved element types in this schema. If SOMUnresolvedTypes were inserted into this schema during construction, using this method will attempt to resolve and replace unresolved element references with actual references. Use hasUnresolvedTypes method to determine if any exist in this schema.

getAnnotations

public java.util.Iterator getAnnotations()
Returns an Iterator over all the annotations contained at the root level of this schema.

Returns:
an Iterator over the SOMAnnotations's contained by this SOMSchema

removeComplexType

public SOMComplexType removeComplexType(java.lang.String name)
remove a complexType from the root level of this schema

Parameters:
name - name the complexType
Returns:
the complexType to which the name had been mapped in this schema, or null if the name did not have a mapping

removeSimpleType

public SOMSimpleType removeSimpleType(java.lang.String name)
remove a simpleType from the root level of this schema

Parameters:
name - name the simpleType
Returns:
the simpleType to which the name had been mapped in this schema, or null if the name did not have a mapping

removeElement

public SOMElement removeElement(java.lang.String name)
remove an element from the root level of this schema

Parameters:
name - name the element
Returns:
the element to which the name had been mapped in this schema, or null if the name did not have a mapping

removeGroup

public SOMGroup removeGroup(java.lang.String name)
remove an group from the root level of this schema

Parameters:
name - name the group
Returns:
the group to which the name had been mapped in this schema, or null if the name did not have a mapping

removeAttribute

public SOMAttribute removeAttribute(java.lang.String name)
remove an attribute from the root level of this schema

Parameters:
name - name the attribute
Returns:
the attribute to which the name had been mapped in this schema, or null if the name did not have a mapping

removeAnnotation

public SOMAnnotation removeAnnotation(SOMAnnotation note)
remove an annotation and all of its children from the root level of this schema

Parameters:
note - The annotation object to be removed
Returns:
the annotation object removed, or null if the object was not found in this schema

lookupTypeReference

public SOMType lookupTypeReference(java.lang.String registeredTypeName)
Returns a reference to a type previously added to this schema object. By adding a type to the root level of this schema object, the type becomes registered within this schema. All types at the root level of a schema must have a name attribute. Therefore, this search restricts itself to types added to this schema object at the root level. The search order is simpleType then complexType.

Parameters:
registeredTypeName - The value of the "name" attribute for the registered type.
Returns:
The registered object for the given "name" or null if none is found.

lookupReference

public SOMReference lookupReference(java.lang.String registeredName)
Returns a reference to an element previously added to this schema object. By adding an element to the root level of this schema object, the element becomes registered within this schema. All elements at the root level of a schema must have a name attribute. Therefore, this search restricts itself to elements added to this schema object at the root level.

Parameters:
registeredBasicName - The value of the "name" attribute for the registered element.
Returns:
The registered object for the given "name" or null if none is found.

lookupElement

public SOMElement lookupElement(java.lang.String registeredName)
Returns a reference to an SOMElement previously added to this schema object. By adding an element to the root level of this schema object, the element becomes registered within this schema. All elements at the root level of a schema must have a name attribute. Therefore, this search restricts itself to elements added to this schema object at the root level.

Parameters:
registeredBasicName - The value of the "name" attribute for the registered attributeGroup element.
Returns:
The registered element for the given "name" or null if none is found.

lookupAttrGrpReference

public SOMAttributeGroup lookupAttrGrpReference(java.lang.String registeredName)
Returns a reference to an attributeGroup previously added to this schema object. By adding an attributeGroup to the root level of this schema object, the element becomes registered within this schema. All elements at the root level of a schema must have a name attribute. Therefore, this search restricts itself to elements added to this schema object at the root level.

Parameters:
registeredBasicName - The value of the "name" attribute for the registered attributeGroup element.
Returns:
The registered object for the given "name" or null if none is found.

isValidatingContent

public boolean isValidatingContent()
current content validation setting.

Returns:
true if isValid should validate element and attribute content

setContentValidation

public void setContentValidation(boolean value)
toggle element and attribute content validation. Content validation for the isValid method defaults to true. When validating a document against this schema, validation of the document's structure can be isolated by toggling the content validation so that element content is ignored during validation.

Parameters:
value - use false to ignore document content

isValid

public boolean isValid(org.w3c.dom.Document doc,
                       java.util.List errorList)
Validates an XML Document against an XML Schema. If the document is valid, the isValid method returns true and the List of errors will be empty.

The error list is cleared before beginning the validation. The List implementation used must support the clear() method.

Elements of the list are instances of the class SOMValidationException.

Parameters:
doc - the document instance to be validated
errorList - A list of SOMValidationException
Returns:
true if the document is valid within this schema

isValid

public boolean isValid(IDocument doc,
                       java.util.List errorList)
Validates an XML Document against an XML Schema. If the document is valid, the isValid method returns true and the List of errors will be empty.

The error list is cleared before beginning the validation. The List implementation used must support the clear() method.

Elements of the list are instances of the class SOMValidationException.

Parameters:
doc - the document instance to be validated
errorList - A list of SOMValidationException
Returns:
true if the document is valid within this schema

isValid

public boolean isValid(org.w3c.dom.Node rootElement,
                       java.util.List errorList)
Validates an XML Document against an XML Schema. If the document is valid, the isValid method returns true and the List of errors will be empty.

The error list is cleared before beginning the validation. The List implementation used must support the clear() method.

Elements of the list are instances of the class SOMValidationException.

Parameters:
doc - the document instance to be validated
errorList - A list of SOMValidationException
Returns:
true if the document is valid within this schema

toXML

public void toXML(java.io.Writer rtn,
                  int indent)
           throws java.io.IOException
For debugging, display, and printing purposes, the XML Schema Object model can be represented as a character string. The super class SOMObject's toString() method calls this method with an indent value of 0.

Parameters:
indent - Indent level
Returns:
String representation of the XML Schema object model
Overrides:
toXML in class SOMObject

createDefaultDocument

public IDocument createDefaultDocument(DefaultDocumentOptions options)
create an XML instance document template based on this schema model. The instance document uses the options provided as the argument with one exception. If the target document is not specified in the options, one will be created for you from com.bea.document.DocumentFactory. The document returned is the same document contained in the options argument, DefaultDocumentOptions.

Parameters:
options - options must include a root element name
Returns:
the created document.

WebLogic Integration

WebLogic Integration (WLI)