Search in sources :

Example 6 with XmlSchemaAttribute

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;
}
Also used : XmlSchemaSimpleTypeList(org.apache.ws.commons.schema.XmlSchemaSimpleTypeList) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaSimpleTypeContent(org.apache.ws.commons.schema.XmlSchemaSimpleTypeContent) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) Iterator(java.util.Iterator) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchemaEnumerationFacet(org.apache.ws.commons.schema.XmlSchemaEnumerationFacet) XmlSchemaObjectCollection(org.apache.ws.commons.schema.XmlSchemaObjectCollection)

Aggregations

XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)6 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)5 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)5 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)5 XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)5 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)4 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)4 XmlSchemaAny (org.apache.ws.commons.schema.XmlSchemaAny)3 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)3 ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)3 Iterator (java.util.Iterator)2 QName (javax.xml.namespace.QName)2 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)2 AegisType (org.apache.cxf.aegis.type.AegisType)1 XmlSchemaComplexContentRestriction (org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction)1 XmlSchemaEnumerationFacet (org.apache.ws.commons.schema.XmlSchemaEnumerationFacet)1 XmlSchemaSimpleTypeContent (org.apache.ws.commons.schema.XmlSchemaSimpleTypeContent)1 XmlSchemaSimpleTypeList (org.apache.ws.commons.schema.XmlSchemaSimpleTypeList)1 XmlSchemaSimpleTypeRestriction (org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction)1 Optional (org.qi4j.api.common.Optional)1