use of eu.esdihumboldt.hale.io.xsd.reader.internal.XmlAttributeReferenceProperty in project hale by halestudio.
the class XmlSchemaReader method createAttribute.
private void createAttribute(XmlSchemaAttribute attribute, DefinitionGroup declaringGroup, String schemaLocation, String schemaNamespace) {
// create attributes
QName typeName = attribute.getSchemaTypeName();
if (typeName != null) {
QName attributeName = determineAttributeName(attribute, schemaNamespace);
// resolve type by name
XmlTypeDefinition type = getTypeForAttribute(typeName, declaringGroup, attributeName);
// create property
DefaultPropertyDefinition property = new DefaultPropertyDefinition(attributeName, declaringGroup, type);
// set metadata and constraints
setMetadataAndConstraints(property, attribute, schemaLocation);
} else if (attribute.getSchemaType() != null) {
XmlSchemaSimpleType simpleType = attribute.getSchemaType();
// create an anonymous type
QName anonymousName = new QName(getTypeIdentifier(declaringGroup) + "/" + attribute.getName(), // $NON-NLS-2$
"AnonymousType");
AnonymousXmlType anonymousType = new AnonymousXmlType(anonymousName);
configureSimpleType(anonymousType, simpleType, schemaLocation);
// create property
DefaultPropertyDefinition property = new DefaultPropertyDefinition(determineAttributeName(attribute, schemaNamespace), declaringGroup, anonymousType);
// set metadata and constraints
setMetadataAndConstraints(property, attribute, schemaLocation);
} else if (attribute.getRefName() != null) {
// <attribute ref="REF_NAME" />
// reference to a named attribute
QName attName = attribute.getRefName();
XmlAttributeReferenceProperty property = new XmlAttributeReferenceProperty(attName, declaringGroup, this.index, attName);
// set metadata and constraints
setMetadataAndConstraints(property, attribute, schemaLocation);
} else {
/*
* Attribute with no type given has anySimpleType, see
* "http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#cAttribute_Declarations"
*/
// resolve type by name
XmlTypeDefinition type = index.getOrCreateType(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "anySimpleType"));
// create property
DefaultPropertyDefinition property = new DefaultPropertyDefinition(determineAttributeName(attribute, schemaNamespace), declaringGroup, type);
// set metadata and constraints
setMetadataAndConstraints(property, attribute, schemaLocation);
}
}
Aggregations