Search in sources :

Example 11 with XmlSchemaObjectCollection

use of org.apache.ws.commons.schema.XmlSchemaObjectCollection 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

XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)11 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)10 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)10 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)9 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)9 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)8 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)6 ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)6 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)5 Iterator (java.util.Iterator)4 XmlSchemaComplexContentRestriction (org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction)4 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)4 XmlSchemaAny (org.apache.ws.commons.schema.XmlSchemaAny)3 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)3 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 XmlSchemaEnumerationFacet (org.apache.ws.commons.schema.XmlSchemaEnumerationFacet)1 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)1 XmlSchemaSimpleTypeContent (org.apache.ws.commons.schema.XmlSchemaSimpleTypeContent)1 XmlSchemaSimpleTypeList (org.apache.ws.commons.schema.XmlSchemaSimpleTypeList)1