use of org.apache.ws.commons.schema.XmlSchemaAttribute in project tomee by apache.
the class CommonsSchemaInfoBuilder method createXmlTypeInfo.
public static XmlTypeInfo createXmlTypeInfo(QName qname, XmlSchemaType type) {
if (qname == null)
throw new NullPointerException("qname is null");
if (type == null)
throw new NullPointerException("type is null");
XmlTypeInfo typeInfo = new XmlTypeInfo();
typeInfo.qname = qname;
typeInfo.anonymous = qname.getLocalPart().indexOf('>') >= 0;
if (type instanceof XmlSchemaSimpleType) {
XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) type;
XmlSchemaSimpleTypeContent content = simpleType.getContent();
if (content instanceof XmlSchemaSimpleTypeList) {
XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList) content;
typeInfo.simpleBaseType = list.getItemType().getQName();
// this is a list
typeInfo.listType = true;
} else if (content instanceof XmlSchemaSimpleTypeRestriction) {
XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
typeInfo.simpleBaseType = restriction.getBaseTypeName();
// is this an enumeration?
for (Iterator iterator = restriction.getFacets().getIterator(); iterator.hasNext(); ) {
if (iterator.next() instanceof XmlSchemaEnumerationFacet) {
typeInfo.enumType = true;
break;
}
}
}
} else if (type instanceof XmlSchemaComplexType) {
XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
// SOAP array component type
typeInfo.arrayComponentType = extractSoapArrayComponentType(complexType);
// process attributes (skip soap arrays which have non-mappable attributes)
if (!isSoapArray(complexType)) {
XmlSchemaObjectCollection attributes = complexType.getAttributes();
for (Iterator iterator = attributes.getIterator(); iterator.hasNext(); ) {
Object item = iterator.next();
if (item instanceof XmlSchemaAttribute) {
XmlSchemaAttribute attribute = (XmlSchemaAttribute) item;
Object old = typeInfo.attributes.put(attribute.getQName().getLocalPart(), attribute.getSchemaTypeName());
if (old != null) {
throw new IllegalArgumentException("Complain to your expert group member, spec does not support attributes with the same local name and differing namespaces: original: " + old + ", duplicate local name: " + attribute);
}
}
}
}
} else {
log.warn("Unknown schema type class " + typeInfo.getClass().getName());
}
return typeInfo;
}
Aggregations