use of eu.esdihumboldt.hale.io.xsd.model.ComplexContentHasValue in project hale by halestudio.
the class XmlSchemaReader method createProperties.
/**
* Create the properties for the given complex type
*
* @param typeDef the definition of the declaring type
* @param item the complex type item
* @param schemaLocation the schema location
* @param schemaNamespace the scheme namspace
*/
private void createProperties(XmlTypeDefinition typeDef, XmlSchemaComplexType item, String schemaLocation, String schemaNamespace) {
// item:
// <complexType ...>
XmlSchemaContentModel model = item.getContentModel();
if (model != null) {
XmlSchemaContent content = model.getContent();
if (content instanceof XmlSchemaComplexContentExtension) {
// <complexContent>
// <extension base="...">
XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension) content;
// particle (e.g. sequence)
if (extension.getParticle() != null) {
XmlSchemaParticle particle = extension.getParticle();
createPropertiesFromParticle(typeDef, particle, schemaLocation, schemaNamespace, false);
}
// attributes
XmlSchemaObjectCollection attributeCollection = extension.getAttributes();
if (attributeCollection != null) {
createAttributesFromCollection(attributeCollection, typeDef, null, schemaLocation, schemaNamespace);
}
// complex content may have a value in certain cases
// (if it is mixed it definitely has, which will override this
// setting)
typeDef.setConstraintIfNotSet(new ComplexContentHasValue(typeDef));
// </extension>
// </complexContent>
} else if (content instanceof XmlSchemaComplexContentRestriction) {
// <complexContent>
// <restriction base="...">
XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) content;
// particle (e.g. sequence)
if (restriction.getParticle() != null) {
XmlSchemaParticle particle = restriction.getParticle();
createPropertiesFromParticle(typeDef, particle, schemaLocation, schemaNamespace, false);
}
// attributes
XmlSchemaObjectCollection attributeCollection = restriction.getAttributes();
if (attributeCollection != null) {
createAttributesFromCollection(attributeCollection, typeDef, null, schemaLocation, schemaNamespace);
}
// complex content does not have a value
// (only if it is mixed, which can override this setting)
typeDef.setConstraintIfNotSet(HasValueFlag.DISABLED);
// </restriction>
// </complexContent>
} else if (content instanceof XmlSchemaSimpleContentExtension) {
// <simpleContent>
// <extension base="...">
XmlSchemaSimpleContentExtension extension = (XmlSchemaSimpleContentExtension) content;
// attributes
XmlSchemaObjectCollection attributeCollection = extension.getAttributes();
if (attributeCollection != null) {
createAttributesFromCollection(attributeCollection, typeDef, null, schemaLocation, schemaNamespace);
}
// </extension>
// </simpleContent>
} else if (content instanceof XmlSchemaSimpleContentRestriction) {
// <simpleContent>
// <restriction base="...">
XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction) content;
// attributes
XmlSchemaObjectCollection attributeCollection = restriction.getAttributes();
if (attributeCollection != null) {
createAttributesFromCollection(attributeCollection, typeDef, null, schemaLocation, schemaNamespace);
}
// </restriction>
// </simpleContent>
}
} else {
// no complex content (instead e.g. <sequence>)
XmlSchemaComplexType complexType = item;
// particle (e.g. sequence)
if (item.getParticle() != null) {
XmlSchemaParticle particle = complexType.getParticle();
createPropertiesFromParticle(typeDef, particle, schemaLocation, schemaNamespace, false);
}
// attributes
XmlSchemaObjectCollection attributeCollection = complexType.getAttributes();
if (attributeCollection != null) {
createAttributesFromCollection(attributeCollection, typeDef, null, schemaLocation, schemaNamespace);
}
}
// </complexType>
}
Aggregations