use of org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle in project eclipselink by eclipse-ee4j.
the class SchemaGenerator method buildSchemaComponentsForXPath.
/**
* This method will build element/complexType/typedefparticle components for a given xml-path,
* and return an XmlPathResult instance containg the sequence that the target should be added
* to, as well as the current schema - which could be different than the working schema used
* before calling this method in the case of a prefixed path element from a different namespace.
* Regarding the path 'target', if the xml-path was "contact-info/address/street", "street"
* would be the target. In this case the sequence containing the "address" element would be
* set in the XmlPathResult to be returned.
*
* The exception case is an 'any', where we want to process the last path element before
* returning - this is necessary due to the fact that an Any will be added to the sequence
* in place of the last path element by the calling method.
*/
private AddToSchemaResult buildSchemaComponentsForXPath(XPathFragment frag, AddToSchemaResult xpr, boolean isChoice, Property next) {
boolean isAny = next.isAny() || next.isAnyAttribute();
TypeDefParticle currentParticle = xpr.particle;
Schema workingSchema = xpr.schema;
// each nested choice on a collection will be unbounded
boolean isUnbounded = false;
if (currentParticle != null) {
isUnbounded = (currentParticle.getMaxOccurs() != null && currentParticle.getMaxOccurs() == Occurs.UNBOUNDED);
}
// don't process the last frag; that will be handled by the calling method if necessary
// note that we may need to process the last frag if it has a namespace or is an 'any'
boolean lastFrag = (frag.getNextFragment() == null || frag.getNextFragment().nameIsText());
// if the element is already in the sequence we don't want the calling method to add a second one
if (lastFrag && (elementExistsInParticle(frag.getLocalName(), frag.getShortName(), currentParticle) != null)) {
xpr.particle = null;
return xpr;
}
// if the current element exists, use it; otherwise create a new one
Element currentElement = elementExistsInParticle(frag.getLocalName(), frag.getShortName(), currentParticle);
boolean currentElementExists = (currentElement != null);
if (!currentElementExists) {
currentElement = new Element();
// don't set the element name yet, as it may end up being a ref
ComplexType cType = new ComplexType();
TypeDefParticle particle = null;
if (isChoice) {
particle = new Choice();
if (isUnbounded) {
particle.setMaxOccurs(Occurs.UNBOUNDED);
}
} else {
XPathFragment nextFragment = frag.getNextFragment();
if (frag.containsIndex() || frag.getPredicate() != null || (!next.isXmlList() && null != nextFragment && nextFragment.isAttribute() && helper.isCollectionType(next.getType()))) {
currentElement.setMaxOccurs(Occurs.UNBOUNDED);
}
particle = new Sequence();
}
cType.setTypeDefParticle(particle);
currentElement.setComplexType(cType);
} else {
// if the current element already exists, we may need to change it's type
XPathFragment nextFrag = frag.getNextFragment();
if (nextFrag != null && nextFrag.isAttribute()) {
if (currentElement.getType() != null && currentElement.getComplexType() == null) {
// there's already a text mapping to this element, so
// attributes can be added by making it complex with
// simple content.
SimpleType type = currentElement.getSimpleType();
if (type != null) {
ComplexType cType = new ComplexType();
cType.setSimpleContent(new SimpleContent());
Extension extension = new Extension();
extension.setBaseType(type.getRestriction().getBaseType());
cType.getSimpleContent().setExtension(extension);
currentElement.setSimpleType(null);
currentElement.setComplexType(cType);
} else {
String eType = currentElement.getType();
ComplexType cType = new ComplexType();
SimpleContent sContent = new SimpleContent();
Extension extension = new Extension();
extension.setBaseType(eType);
sContent.setExtension(extension);
cType.setSimpleContent(sContent);
currentElement.setType(null);
currentElement.setComplexType(cType);
}
}
}
}
// may need to create a ref, depending on the namespace
Element globalElement = null;
String fragUri = frag.getNamespaceURI();
if (fragUri != null) {
Schema fragSchema = getSchemaForNamespace(fragUri);
String targetNS = workingSchema.getTargetNamespace();
// handle Attribute case
if (frag.isAttribute()) {
if (fragSchema == null || (fragSchema.isAttributeFormDefault() && !fragUri.equals(targetNS)) || (!fragSchema.isAttributeFormDefault() && fragUri.length() > 0)) {
// if fragSchema is null, just generate the ref
if (fragSchema != null) {
Attribute globalAttribute = null;
globalAttribute = fragSchema.getTopLevelAttributes().get(frag.getLocalName());
if (globalAttribute == null) {
globalAttribute = createGlobalAttribute(frag, workingSchema, fragSchema, next);
}
} else {
// may need to add an import
addImportIfRequired(workingSchema, null, fragUri);
}
// add the attribute ref to the current element
String attributeRefName;
if (fragUri.equals(targetNS)) {
String prefix = fragSchema.getNamespaceResolver().resolveNamespaceURI(fragUri);
attributeRefName = prefix + COLON + frag.getLocalName();
} else {
attributeRefName = frag.getShortName();
}
TypeDefParticleOwner type;
if (currentParticle != null) {
type = currentParticle.getOwner();
} else {
type = xpr.simpleContentType;
}
if (type instanceof ComplexType) {
createRefAttribute(attributeRefName, (ComplexType) type);
}
// set the frag's schema as it may be different than the current schema
xpr.schema = fragSchema;
// ref case - indicate to the calling method that there's nothing to do
xpr.particle = null;
}
// since we are dealing with an attribute, we are on the last fragment; return
return xpr;
}
// here we are dealing with an Element
if ((fragSchema.isElementFormDefault() && !fragUri.equals(targetNS)) || (!fragSchema.isElementFormDefault() && fragUri.length() > 0)) {
// must generate a global element and create a reference to it
// if the global element exists, use it; otherwise create a new one
globalElement = fragSchema.getTopLevelElements().get(frag.getLocalName());
if (globalElement == null) {
globalElement = createGlobalElement(frag, workingSchema, fragSchema, isChoice, isUnbounded, next, (lastFrag && !isAny));
}
// if the current element doesn't exist set a ref and add it to the sequence
if (!currentElementExists) {
// use prefix from the working schema's resolver - add prefix/uri pair if necessary
String fragPrefix = workingSchema.getNamespaceResolver().resolveNamespaceURI(fragUri);
if (fragPrefix == null) {
fragPrefix = workingSchema.getNamespaceResolver().generatePrefix(frag.getPrefix());
workingSchema.getNamespaceResolver().put(fragPrefix, fragUri);
}
currentElement = createRefElement(fragPrefix + COLON + frag.getLocalName(), currentParticle);
if (frag.containsIndex() || frag.getPredicate() != null || helper.isCollectionType(next.getType())) {
currentElement.setMaxOccurs(Occurs.UNBOUNDED);
}
currentElementExists = true;
}
// set the frag's schema as it may be different than the current schema
xpr.schema = fragSchema;
// at this point, if we are dealing with the last fragment we will need to return
if (lastFrag) {
// add a second one...unless we're dealing with an 'any'
if (isAny) {
// set the particle that the 'any' will be added to by the calling method
xpr.particle = globalElement.getComplexType().getTypeDefParticle();
return xpr;
}
// ref case - indicate to the calling method that there's nothing to do
xpr.particle = null;
return xpr;
}
// make the global element current
currentElement = globalElement;
}
}
if (!lastFrag || (lastFrag && isAny)) {
// if we didn't process a global element, and the current element isn't already in the sequence, add it
if (!currentElementExists && globalElement == null) {
currentElement.setName(frag.getLocalName());
Integer minOccurs = next.getMinOccurs();
if (minOccurs != null)
currentElement.setMinOccurs(String.valueOf(minOccurs));
else
currentElement.setMinOccurs(Occurs.ZERO);
currentParticle.addElement(currentElement);
}
// set the correct particle to use/return
if (currentElement.getComplexType() != null) {
if (currentElement.getComplexType().getTypeDefParticle() == null) {
// complexType with simple-content
xpr.simpleContentType = currentElement.getComplexType();
xpr.particle = null;
} else {
xpr.particle = currentElement.getComplexType().getTypeDefParticle();
}
} else {
// If there's no complex type, we're building the path through an element with
// a simple type. In order to build the path through this
// element, switch to a complex type with simple content.
SimpleType type = currentElement.getSimpleType();
if (type != null) {
ComplexType cType = new ComplexType();
cType.setSimpleContent(new SimpleContent());
Extension extension = new Extension();
extension.setBaseType(type.getRestriction().getBaseType());
cType.getSimpleContent().setExtension(extension);
currentElement.setSimpleType(null);
currentElement.setComplexType(cType);
xpr.particle = null;
xpr.simpleContentType = cType;
} else {
String eType = currentElement.getType();
ComplexType cType = new ComplexType();
SimpleContent sContent = new SimpleContent();
Extension extension = new Extension();
extension.setBaseType(eType);
sContent.setExtension(extension);
cType.setSimpleContent(sContent);
currentElement.setType(null);
currentElement.setComplexType(cType);
xpr.particle = null;
xpr.simpleContentType = cType;
}
}
}
// if we're on the last fragment, we're done
if (lastFrag) {
return xpr;
}
// call back into this method to process the next path element
return buildSchemaComponentsForXPath(frag.getNextFragment(), xpr, isChoice, next);
}
use of org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle in project eclipselink by eclipse-ee4j.
the class SchemaGenerator method addToSchemaType.
public void addToSchemaType(TypeInfo ownerTypeInfo, java.util.List<Property> properties, TypeDefParticle compositor, ComplexType type, Schema workingSchema) {
// If there are no properties we don't want a sequence/choice or all tag written out
if (properties.size() == 0) {
type.setAll(null);
type.setSequence(null);
type.setChoice(null);
ownerTypeInfo.setCompositor(null);
return;
}
boolean extAnyAdded = false;
// generate schema components for each property
for (Property next : properties) {
if (next == null) {
continue;
}
Schema currentSchema = workingSchema;
TypeDefParticle parentCompositor = compositor;
boolean isChoice = (parentCompositor instanceof Choice);
ComplexType parentType = type;
// ignore transient and inverse reference/non-writeable properties
if (!next.isTransient() && !(next.isInverseReference() && !next.isWriteableInverseReference())) {
// handle xml extensions
if (next.isVirtual()) {
boolean extSchemaAny = false;
if (ownerTypeInfo.getXmlVirtualAccessMethods().getSchema() != null) {
extSchemaAny = ownerTypeInfo.getXmlVirtualAccessMethods().getSchema().equals(XmlVirtualAccessMethodsSchema.ANY);
}
if (extSchemaAny && !next.isAttribute()) {
if (!extAnyAdded) {
addAnyToSchema(next, compositor, true, Constants.ANY_NAMESPACE_ANY);
extAnyAdded = true;
continue;
} else {
// any already added
continue;
}
} else {
// proceed, adding the schema element as usual
}
}
// handle transformers
if (next.isSetXmlTransformation() && next.getXmlTransformation().isSetXmlWriteTransformers()) {
addTransformerToSchema(next, ownerTypeInfo, compositor, type, workingSchema);
continue;
}
// handle XmlJoinNodes
if (next.isSetXmlJoinNodes()) {
addXmlJoinNodesToSchema(next, parentCompositor, currentSchema, parentType);
continue;
}
// deal with xml-path case
if (next.getXmlPath() != null) {
// create schema components based on the XmlPath
AddToSchemaResult xpr = addXPathToSchema(next, parentCompositor, currentSchema, isChoice, type);
// if the returned object or schema component is null there is nothing to do
if (xpr == null || ((parentCompositor = xpr.particle) == null && xpr.simpleContentType == null)) {
continue;
}
// now process the property as per usual, adding to the created schema component
if (xpr.schema == null) {
// no need to generate the attribute in the target schema
continue;
}
currentSchema = xpr.schema;
if (parentCompositor == null) {
parentType = xpr.simpleContentType;
} else if (parentCompositor.getOwner() instanceof ComplexType) {
parentType = ((ComplexType) parentCompositor.getOwner());
}
// deal with the XmlElementWrapper case
} else if (!isChoice && !next.isMap() && next.isSetXmlElementWrapper()) {
AddToSchemaResult asr = addXmlElementWrapperToSchema(next, currentSchema, compositor);
// if returned object is null there is nothing to do
if (asr == null) {
continue;
}
// the returned object contains ComplexType and TypeDefParticles to use
parentType = asr.type;
parentCompositor = asr.particle;
}
// handle mixed content
if (next.isMixedContent()) {
parentType.setMixed(true);
}
// handle attribute
if (next.isAttribute() && !next.isAnyAttribute()) {
addAttributeToSchema(buildAttribute(next, currentSchema), next.getSchemaName(), currentSchema, parentType);
// handle any attribute
} else if (next.isAnyAttribute()) {
addAnyAttributeToSchema(parentType);
// handle choice
} else if (next.isChoice()) {
addChoiceToSchema(next, ownerTypeInfo, parentType, parentCompositor, currentSchema);
// handle reference
} else if (next.isReference()) {
addReferenceToSchema(next, currentSchema, parentCompositor);
// handle any
} else if (next.isAny() || next.getVariableAttributeName() != null) {
addAnyToSchema(next, parentCompositor);
// add an element
} else if (!(ownerTypeInfo.getXmlValueProperty() != null && ownerTypeInfo.getXmlValueProperty() == next)) {
Element element = buildElement(next, parentCompositor instanceof All, currentSchema, ownerTypeInfo);
addElementToSchema(element, next.getSchemaName().getNamespaceURI(), next.isPositional(), parentCompositor, currentSchema, ownerTypeInfo.getJavaClass().getPackageName());
}
}
}
}
use of org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle in project eclipselink by eclipse-ee4j.
the class SchemaGenerator method createComplexTypeForClass.
private ComplexType createComplexTypeForClass(JavaClass myClass, TypeInfo info) {
Schema schema = getSchemaForNamespace(info.getClassNamespace());
ComplexType type = new ComplexType();
JavaClass superClass = CompilerHelper.getNextMappedSuperClass(myClass, this.typeInfo, this.helper);
// Handle abstract class
if (myClass.isAbstract()) {
type.setAbstractValue(true);
}
Extension extension = null;
if (superClass != null) {
TypeInfo parentTypeInfo = this.typeInfo.get(superClass.getQualifiedName());
if (parentTypeInfo != null) {
extension = new Extension();
// may need to qualify the type
String parentPrefix = getPrefixForNamespace(schema, parentTypeInfo.getClassNamespace());
if (parentPrefix != null) {
extension.setBaseType(parentPrefix + COLON + parentTypeInfo.getSchemaTypeName());
} else {
extension.setBaseType(parentTypeInfo.getSchemaTypeName());
}
if (parentTypeInfo.getXmlValueProperty() != null) {
SimpleContent content = new SimpleContent();
content.setExtension(extension);
type.setSimpleContent(content);
return type;
} else {
ComplexContent content = new ComplexContent();
content.setExtension(extension);
type.setComplexContent(content);
}
}
}
TypeDefParticle compositor = null;
String[] propOrder = null;
if (info.isSetPropOrder()) {
propOrder = info.getPropOrder();
}
if (propOrder != null && propOrder.length == 0) {
// requires the extension case to use sequences
if (info.hasElementRefs()) {
// generate a sequence to satisfy TCK
compositor = new Sequence();
if (extension != null) {
extension.setSequence((Sequence) compositor);
} else {
type.setSequence((Sequence) compositor);
}
} else if (extension != null) {
compositor = new All();
extension.setAll((All) compositor);
} else {
compositor = new All();
type.setAll((All) compositor);
}
} else {
// generate a sequence to satisfy TCK
compositor = new Sequence();
if (extension != null) {
extension.setSequence((Sequence) compositor);
} else {
type.setSequence((Sequence) compositor);
}
}
return type;
}
use of org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle in project eclipselink by eclipse-ee4j.
the class SchemaGenerator method createGlobalElement.
/**
* Create a global element. An import is added if necessary. This method
* will typically be called when processing an XPath and a prefixed path
* element is encountered the requires an element ref.
*
* @param frag XPathFragment which wil lbe used to create the global element
* @param workingSchema current schema
* @param fragSchema frag's schema
* @param isChoice indicates if we need to construct a choice
* @param isUnbounded maxOccurs setting for choice
* @param prop property which owns the xml-path
* @param shouldSetType if this is the last fragment in the xml-path and not an 'any', we should set the type
*/
public Element createGlobalElement(XPathFragment frag, Schema workingSchema, Schema fragSchema, boolean isChoice, boolean isUnbounded, Property prop, boolean shouldSetType) {
Element gElement = new Element();
gElement.setName(frag.getLocalName());
if (shouldSetType) {
gElement.setType(getQualifiedTypeName(prop, fragSchema));
} else {
ComplexType gCType = new ComplexType();
TypeDefParticle particle;
if (isChoice) {
particle = new Choice();
if (isUnbounded) {
particle.setMaxOccurs(Occurs.UNBOUNDED);
}
} else {
particle = new Sequence();
}
gCType.setTypeDefParticle(particle);
gElement.setComplexType(gCType);
}
fragSchema.addTopLevelElement(gElement);
addImportIfRequired(workingSchema, fragSchema, frag.getNamespaceURI());
return gElement;
}
use of org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle in project eclipselink by eclipse-ee4j.
the class SchemaGenerator method addSchemaComponents.
public void addSchemaComponents(JavaClass myClass) {
// first check for type
String myClassName = myClass.getQualifiedName();
Element rootElement = null;
TypeInfo info = typeInfo.get(myClassName);
if (info.isTransient() || info.getClassNamespace().equals(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
return;
}
SchemaTypeInfo schemaTypeInfo = new SchemaTypeInfo();
schemaTypeInfo.setSchemaTypeName(new QName(info.getClassNamespace(), info.getSchemaTypeName()));
this.schemaTypeInfo.put(myClass.getQualifiedName(), schemaTypeInfo);
NamespaceInfo namespaceInfo = this.packageToPackageInfoMappings.get(myClass.getPackageName()).getNamespaceInfo();
if (namespaceInfo.getLocation() != null && !namespaceInfo.getLocation().equals(GENERATE)) {
return;
}
Schema schema = getSchemaForNamespace(info.getClassNamespace(), myClass.getPackageName());
info.setSchema(schema);
String typeName = info.getSchemaTypeName();
String pfx = EMPTY_STRING;
Property valueField = null;
if (info.isSetXmlRootElement()) {
// Create the root element and add it to the schema
org.eclipse.persistence.jaxb.xmlmodel.XmlRootElement xmlRE = info.getXmlRootElement();
rootElement = new Element();
String elementName = xmlRE.getName();
if (elementName.equals(XMLProcessor.DEFAULT) || elementName.equals(EMPTY_STRING)) {
try {
elementName = info.getXmlNameTransformer().transformRootElementName(myClassName);
} catch (Exception ex) {
throw org.eclipse.persistence.exceptions.JAXBException.exceptionDuringNameTransformation(myClassName, info.getXmlNameTransformer().getClass().getName(), ex);
}
}
rootElement.setName(elementName);
String rootNamespace = xmlRE.getNamespace();
if (rootNamespace.equals(XMLProcessor.DEFAULT)) {
Schema rootElementSchema = getSchemaForNamespace(namespaceInfo.getNamespace());
if (rootElementSchema != null) {
rootElementSchema.addTopLevelElement(rootElement);
}
schemaTypeInfo.getGlobalElementDeclarations().add(new QName(namespaceInfo.getNamespace(), rootNamespace));
rootNamespace = namespaceInfo.getNamespace();
} else {
Schema rootElementSchema = getSchemaForNamespace(rootNamespace);
if (rootElementSchema != null) {
rootElementSchema.addTopLevelElement(rootElement);
}
schemaTypeInfo.getGlobalElementDeclarations().add(new QName(rootNamespace, elementName));
}
// handle root-level imports/includes [schema = the type's schema]
Schema rootSchema = getSchemaForNamespace(rootNamespace);
addImportIfRequired(rootSchema, schema, schema.getTargetNamespace());
// setup a prefix, if necessary
if (rootSchema != null && !info.getClassNamespace().equals(EMPTY_STRING)) {
pfx = getOrGeneratePrefixForNamespace(info.getClassNamespace(), rootSchema);
pfx += COLON;
}
}
if (CompilerHelper.isSimpleType(info)) {
SimpleType type = new SimpleType();
// simple type case, we just need the name and namespace info
if (typeName.equals(EMPTY_STRING)) {
// A root elem or locally defined whenever used
if (rootElement != null) {
rootElement.setSimpleType(type);
}
} else {
type.setName(typeName);
schema.addTopLevelSimpleTypes(type);
if (rootElement != null) {
rootElement.setType(pfx + type.getName());
}
}
// Figure out schema type and set it as Restriction
QName restrictionType = null;
Restriction restriction = new Restriction();
if (info.isEnumerationType()) {
restrictionType = ((EnumTypeInfo) info).getRestrictionBase();
restriction.setEnumerationFacets(this.getEnumerationFacetsFor((EnumTypeInfo) info));
String prefix = null;
if (restrictionType.getNamespaceURI() != null && !EMPTY_STRING.equals(restrictionType.getNamespaceURI())) {
if (javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(restrictionType.getNamespaceURI())) {
prefix = Constants.SCHEMA_PREFIX;
} else {
prefix = getPrefixForNamespace(schema, restrictionType.getNamespaceURI());
}
}
String extensionTypeName = restrictionType.getLocalPart();
if (prefix != null) {
extensionTypeName = prefix + COLON + extensionTypeName;
}
restriction.setBaseType(extensionTypeName);
type.setRestriction(restriction);
} else {
valueField = info.getXmlValueProperty();
JavaClass javaType = valueField.getActualType();
QName baseType = getSchemaTypeFor(javaType);
String prefix = null;
if (baseType.getNamespaceURI() != null && !baseType.getNamespaceURI().equals(EMPTY_STRING)) {
if (baseType.getNamespaceURI().equals(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
prefix = Constants.SCHEMA_PREFIX;
} else {
prefix = getPrefixForNamespace(schema, baseType.getNamespaceURI());
}
}
String baseTypeName = baseType.getLocalPart();
if (prefix != null) {
baseTypeName = prefix + COLON + baseTypeName;
}
if (valueField.isXmlList() || (valueField.getGenericType() != null)) {
// generate a list instead of a restriction
org.eclipse.persistence.internal.oxm.schema.model.List list = new org.eclipse.persistence.internal.oxm.schema.model.List();
list.setItemType(baseTypeName);
type.setList(list);
} else {
if (helper.isAnnotationPresent(valueField.getElement(), XmlSchemaType.class)) {
XmlSchemaType schemaType = (XmlSchemaType) helper.getAnnotation(valueField.getElement(), XmlSchemaType.class);
// TODO: This assignment seems like a bug, probably this should be "baseTypeName" ?
baseType = new QName(schemaType.namespace(), schemaType.name());
}
restriction.setBaseType(baseTypeName);
type.setRestriction(restriction);
}
}
info.setSimpleType(type);
} else if ((valueField = this.getXmlValueFieldForSimpleContent(info)) != null) {
ComplexType type = new ComplexType();
SimpleContent content = new SimpleContent();
if (EMPTY_STRING.equals(typeName)) {
if (rootElement != null) {
rootElement.setComplexType(type);
}
info.setComplexType(type);
} else {
type.setName(typeName);
schema.addTopLevelComplexTypes(type);
if (rootElement != null) {
rootElement.setType(pfx + type.getName());
}
}
QName extensionType = getSchemaTypeFor(valueField.getType());
if (helper.isAnnotationPresent(valueField.getElement(), XmlSchemaType.class)) {
XmlSchemaType schemaType = (XmlSchemaType) helper.getAnnotation(valueField.getElement(), XmlSchemaType.class);
extensionType = new QName(schemaType.namespace(), schemaType.name());
}
String prefix = null;
if (extensionType.getNamespaceURI() != null && !extensionType.getNamespaceURI().equals(EMPTY_STRING)) {
if (extensionType.getNamespaceURI().equals(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
prefix = Constants.SCHEMA_PREFIX;
} else {
prefix = getPrefixForNamespace(schema, extensionType.getNamespaceURI());
}
}
String extensionTypeName = extensionType.getLocalPart();
if (prefix != null) {
extensionTypeName = prefix + COLON + extensionTypeName;
}
Extension extension = new Extension();
extension.setBaseType(extensionTypeName);
content.setExtension(extension);
type.setSimpleContent(content);
info.setComplexType(type);
} else {
ComplexType type = createComplexTypeForClass(myClass, info);
TypeDefParticle compositor = null;
if (type.getComplexContent() != null && type.getComplexContent().getExtension() != null) {
compositor = type.getComplexContent().getExtension().getTypeDefParticle();
} else {
compositor = type.getTypeDefParticle();
}
if (EMPTY_STRING.equals(typeName)) {
if (rootElement != null) {
rootElement.setComplexType(type);
}
info.setComplexType(type);
info.setCompositor(compositor);
} else {
type.setName(typeName);
if (rootElement != null) {
rootElement.setType(pfx + type.getName());
}
schema.addTopLevelComplexTypes(type);
info.setComplexType(type);
info.setCompositor(compositor);
}
}
}
Aggregations