org.eclipse.xsd.presentation
Class XSDEditor.EcoreXMLSchemaBuilder

java.lang.Object
  |
  +--org.eclipse.xsd.presentation.XSDEditor.MapBuilder
        |
        +--org.eclipse.xsd.presentation.XSDEditor.EcoreXMLSchemaBuilder
Direct Known Subclasses:
XSDEditor.EcoreXMISchemaBuilder
Enclosing class:
XSDEditor

public static class XSDEditor.EcoreXMLSchemaBuilder
extends XSDEditor.MapBuilder

This class produces an XSDSchema given an Ecore EPackage. The XSDSchema is an XML schema.


Field Summary
protected  java.util.Map ecoreToSchemaName
           
protected static java.lang.String EMF_SCHEMA_NAME
           
protected static java.lang.String EMF_SCHEMA_PREFIX
           
protected static java.lang.String EMF_SCHEMA_URI
           
protected  XSDSchema emfSchema
           
protected  org.eclipse.emf.ecore.EPackage ePackage
           
protected  java.util.Map ePackageToXSDSchemaMap
           
protected static java.lang.String REFERENCE_TYPE_NAME
           
protected  org.eclipse.emf.ecore.xmi.XMLResource.XMLMap xmlMap
           
protected  XSDSchema xsdSchema
           
 
Fields inherited from class org.eclipse.xsd.presentation.XSDEditor.MapBuilder
addInputMethod, addOutputMethod, mapMethod, mapper, mappingRoot, xsdComponentToEModelElementMap
 
Constructor Summary
XSDEditor.EcoreXMLSchemaBuilder()
           
 
Method Summary
protected  void addEMFSchema()
           
protected  void addImport(java.lang.String namespace, java.lang.String schemaLocation)
           
protected  void additionalProcessing(org.eclipse.emf.ecore.EClass cls, XSDComplexTypeDefinition xsdComplexTypeDefinition)
           
protected  void createAttributeDeclaration(org.eclipse.emf.ecore.EAttribute attribute, XSDComplexTypeDefinition xsdComplexTypeDefinition)
           
protected  void createAttributeElementDeclaration(org.eclipse.emf.ecore.EAttribute attribute, XSDComplexTypeDefinition xsdComplexTypeDefinition)
           
protected  void createEMFSchema()
           
protected  XSDModelGroup createModelGroup(XSDComplexTypeDefinition xsdComplexTypeDefinition)
           
protected  void createOtherSchema(org.eclipse.emf.ecore.EPackage ePackage)
           
protected  void createSchema()
           
 java.util.Collection generate(org.eclipse.emf.ecore.EPackage ePackage)
           
 java.util.Collection generate(org.eclipse.emf.ecore.EPackage ePackage, org.eclipse.emf.ecore.xmi.XMLResource.XMLMap map)
           
protected  java.util.List getAllFeatures(org.eclipse.emf.ecore.EClass eClass, java.util.Set classesToIgnore)
          This method returns the list of features for the given class and all inherited features; ignoring features from classes in the classesToIgnore set.
protected  java.util.List getFeatures(org.eclipse.emf.ecore.EClass eClass, java.util.List superClasses)
          Return the inherited features from the super classes (except the first one, which is the base type for the generated schema type for the class), and the local features.
protected  org.eclipse.emf.ecore.xmi.XMLResource.XMLInfo getInfo(org.eclipse.emf.ecore.ENamedElement element)
          Return the XMLInfo object for the given element, if there is one.
protected  XSDModelGroup getModelGroup(XSDComplexTypeDefinition xsdComplexTypeDefinition)
          Returns the model group for the given complex type definition.
protected  java.lang.String getName(org.eclipse.emf.ecore.ENamedElement element)
          Return the given name, or the name from the XMLMap, if there is one.
protected  XSDSimpleTypeDefinition getType(org.eclipse.emf.ecore.EDataType dataType)
           
protected  boolean makeAttributeDeclaration(org.eclipse.emf.ecore.EAttribute attribute)
           
protected  boolean makeAttributeElementDeclaration()
           
protected  boolean makeClassElementDeclaration(org.eclipse.emf.ecore.EClass eClass)
           
protected  boolean makeReferenceAttribute(org.eclipse.emf.ecore.EReference reference)
           
protected  void makeReferenceAttribute(org.eclipse.emf.ecore.EReference reference, XSDComplexTypeDefinition xsdComplexTypeDefinition)
           
protected  boolean makeReferenceElement(org.eclipse.emf.ecore.EReference reference)
           
protected  void makeReferenceElement(org.eclipse.emf.ecore.EReference reference, XSDComplexTypeDefinition xsdComplexTypeDefinition)
           
protected  boolean processAttribute(org.eclipse.emf.ecore.EAttribute attribute)
           
protected  void processAttribute(org.eclipse.emf.ecore.EAttribute attribute, XSDComplexTypeDefinition xsdComplexTypeDefinition)
          Map each EAttribute to an XML attribute declaration in the complex type corresponding to the class, or an XML element declaration, depending on the multiplicity of the EAttribute.
protected  void processClass(org.eclipse.emf.ecore.EClass eClass)
          Map each EClass to a schema complex type and an element declaration of that type; the names of the complex type and element declaration are the name of the class.
protected  void processClasses()
           
protected  void processEnum(org.eclipse.emf.ecore.EEnum enum)
          Each EEnum is mapped to a schema simple type that restricts the string simple type; the schema type has an enumeration facet for each EEnumLiteral.
protected  void processEnums()
           
protected  void processReference(org.eclipse.emf.ecore.EReference reference, XSDComplexTypeDefinition xsdComplexTypeDefinition)
           
protected  void setAttributeElementMultiplicity(org.eclipse.emf.ecore.EAttribute attribute, XSDParticle particle)
           
protected  void setAttributeType(org.eclipse.emf.ecore.EAttribute attribute, XSDAttributeDeclaration attrDecl)
           
protected  void setDefaultValue(org.eclipse.emf.ecore.EAttribute attribute, XSDAttributeDeclaration attrDecl)
           
protected  void setReferenceAttribType(XSDAttributeDeclaration xsdAttributeDeclaration)
           
protected  void setReferenceElementMultiplicity(org.eclipse.emf.ecore.EReference reference, XSDParticle particle)
           
protected  void setReferenceElementType(org.eclipse.emf.ecore.EReference reference, XSDElementDeclaration xsdElementDeclaration)
           
protected  void setUseToRequired(org.eclipse.emf.ecore.EAttribute attribute, XSDAttributeUse attrUse)
           
protected  boolean skipReference(org.eclipse.emf.ecore.EReference reference)
           
protected  XSDTypeDefinition typeInOtherSchema(org.eclipse.emf.ecore.EClassifier classifier)
           
 
Methods inherited from class org.eclipse.xsd.presentation.XSDEditor.MapBuilder
addInput, addOutput, map
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMF_SCHEMA_URI

protected static final java.lang.String EMF_SCHEMA_URI

EMF_SCHEMA_PREFIX

protected static final java.lang.String EMF_SCHEMA_PREFIX

EMF_SCHEMA_NAME

protected static final java.lang.String EMF_SCHEMA_NAME

REFERENCE_TYPE_NAME

protected static final java.lang.String REFERENCE_TYPE_NAME

xsdSchema

protected XSDSchema xsdSchema

emfSchema

protected XSDSchema emfSchema

ePackage

protected org.eclipse.emf.ecore.EPackage ePackage

ecoreToSchemaName

protected java.util.Map ecoreToSchemaName

ePackageToXSDSchemaMap

protected java.util.Map ePackageToXSDSchemaMap

xmlMap

protected org.eclipse.emf.ecore.xmi.XMLResource.XMLMap xmlMap
Constructor Detail

XSDEditor.EcoreXMLSchemaBuilder

public XSDEditor.EcoreXMLSchemaBuilder()
Method Detail

generate

public java.util.Collection generate(org.eclipse.emf.ecore.EPackage ePackage)

generate

public java.util.Collection generate(org.eclipse.emf.ecore.EPackage ePackage,
                                     org.eclipse.emf.ecore.xmi.XMLResource.XMLMap map)

createSchema

protected void createSchema()

createEMFSchema

protected void createEMFSchema()

addEMFSchema

protected void addEMFSchema()

typeInOtherSchema

protected XSDTypeDefinition typeInOtherSchema(org.eclipse.emf.ecore.EClassifier classifier)

addImport

protected void addImport(java.lang.String namespace,
                         java.lang.String schemaLocation)

createOtherSchema

protected void createOtherSchema(org.eclipse.emf.ecore.EPackage ePackage)

processClasses

protected void processClasses()

processEnums

protected void processEnums()

getInfo

protected org.eclipse.emf.ecore.xmi.XMLResource.XMLInfo getInfo(org.eclipse.emf.ecore.ENamedElement element)
Return the XMLInfo object for the given element, if there is one.

getName

protected java.lang.String getName(org.eclipse.emf.ecore.ENamedElement element)
Return the given name, or the name from the XMLMap, if there is one.

processEnum

protected void processEnum(org.eclipse.emf.ecore.EEnum enum)
Each EEnum is mapped to a schema simple type that restricts the string simple type; the schema type has an enumeration facet for each EEnumLiteral.

processClass

protected void processClass(org.eclipse.emf.ecore.EClass eClass)
Map each EClass to a schema complex type and an element declaration of that type; the names of the complex type and element declaration are the name of the class. If the class is abstract, only a complex type is created from it; there is no corresponding element declaration.

makeClassElementDeclaration

protected boolean makeClassElementDeclaration(org.eclipse.emf.ecore.EClass eClass)

additionalProcessing

protected void additionalProcessing(org.eclipse.emf.ecore.EClass cls,
                                    XSDComplexTypeDefinition xsdComplexTypeDefinition)

getFeatures

protected java.util.List getFeatures(org.eclipse.emf.ecore.EClass eClass,
                                     java.util.List superClasses)
Return the inherited features from the super classes (except the first one, which is the base type for the generated schema type for the class), and the local features.

getAllFeatures

protected java.util.List getAllFeatures(org.eclipse.emf.ecore.EClass eClass,
                                        java.util.Set classesToIgnore)
This method returns the list of features for the given class and all inherited features; ignoring features from classes in the classesToIgnore set.

processAttribute

protected void processAttribute(org.eclipse.emf.ecore.EAttribute attribute,
                                XSDComplexTypeDefinition xsdComplexTypeDefinition)
Map each EAttribute to an XML attribute declaration in the complex type corresponding to the class, or an XML element declaration, depending on the multiplicity of the EAttribute.

The types are mapped as follows: Ecore type Schema type ------------ ------------- EBoolean boolean EBooleanObject boolean EInt int EIntegerObject int ELong long ELongObject long EFloat float EFloatObject float EDouble double EDoubleObject double EString string

If the attribute has no type or if the type is an EDataType that is not an EEnum, the schema string type is used.

If the EAttribute is required, the attribute declaration includes use="required".

If the EAttribute has a defaultValueLiteral, the attribute declaration has a default attribute whose value is the defaultValueLiteral.

If the EAttribute is transient, or its type is not serializable, an attribute declaration is not generated.

If the EAttribute can have many values, an element declaration is created rather than an attribute declaration. The lower bound of the attribute is set to the minOccurs value of the element declaration. The upper bound of the attribute is set to the maxOccurs value of the element declaration (converting -1 to unbounded as appropriate). The type of the element is set as above for attribute declarations.


createAttributeDeclaration

protected void createAttributeDeclaration(org.eclipse.emf.ecore.EAttribute attribute,
                                          XSDComplexTypeDefinition xsdComplexTypeDefinition)

createAttributeElementDeclaration

protected void createAttributeElementDeclaration(org.eclipse.emf.ecore.EAttribute attribute,
                                                 XSDComplexTypeDefinition xsdComplexTypeDefinition)

setAttributeElementMultiplicity

protected void setAttributeElementMultiplicity(org.eclipse.emf.ecore.EAttribute attribute,
                                               XSDParticle particle)

processAttribute

protected boolean processAttribute(org.eclipse.emf.ecore.EAttribute attribute)

makeAttributeDeclaration

protected boolean makeAttributeDeclaration(org.eclipse.emf.ecore.EAttribute attribute)

makeAttributeElementDeclaration

protected boolean makeAttributeElementDeclaration()

getModelGroup

protected XSDModelGroup getModelGroup(XSDComplexTypeDefinition xsdComplexTypeDefinition)
Returns the model group for the given complex type definition. If there is no model group, a model group is created and added to the complex type definition.

createModelGroup

protected XSDModelGroup createModelGroup(XSDComplexTypeDefinition xsdComplexTypeDefinition)

setAttributeType

protected void setAttributeType(org.eclipse.emf.ecore.EAttribute attribute,
                                XSDAttributeDeclaration attrDecl)

setUseToRequired

protected void setUseToRequired(org.eclipse.emf.ecore.EAttribute attribute,
                                XSDAttributeUse attrUse)

setDefaultValue

protected void setDefaultValue(org.eclipse.emf.ecore.EAttribute attribute,
                               XSDAttributeDeclaration attrDecl)

processReference

protected void processReference(org.eclipse.emf.ecore.EReference reference,
                                XSDComplexTypeDefinition xsdComplexTypeDefinition)

makeReferenceAttribute

protected boolean makeReferenceAttribute(org.eclipse.emf.ecore.EReference reference)

makeReferenceElement

protected boolean makeReferenceElement(org.eclipse.emf.ecore.EReference reference)

skipReference

protected boolean skipReference(org.eclipse.emf.ecore.EReference reference)

makeReferenceAttribute

protected void makeReferenceAttribute(org.eclipse.emf.ecore.EReference reference,
                                      XSDComplexTypeDefinition xsdComplexTypeDefinition)

setReferenceAttribType

protected void setReferenceAttribType(XSDAttributeDeclaration xsdAttributeDeclaration)

makeReferenceElement

protected void makeReferenceElement(org.eclipse.emf.ecore.EReference reference,
                                    XSDComplexTypeDefinition xsdComplexTypeDefinition)

setReferenceElementType

protected void setReferenceElementType(org.eclipse.emf.ecore.EReference reference,
                                       XSDElementDeclaration xsdElementDeclaration)

setReferenceElementMultiplicity

protected void setReferenceElementMultiplicity(org.eclipse.emf.ecore.EReference reference,
                                               XSDParticle particle)

getType

protected XSDSimpleTypeDefinition getType(org.eclipse.emf.ecore.EDataType dataType)

Copyright 2001-2002 IBM Corporation and others.
All Rights Reserved.