Java Code Examples for org.apache.ws.commons.schema.XmlSchemaComplexType#getAttributes()

The following examples show how to use org.apache.ws.commons.schema.XmlSchemaComplexType#getAttributes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmlSchemaUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static List<XmlSchemaAnnotated> getContentAttributes(XmlSchemaComplexType type,
                                                            SchemaCollection collection) {
    List<XmlSchemaAnnotated> results = new ArrayList<>();
    QName baseTypeName = getBaseType(type);
    if (baseTypeName != null) {
        XmlSchemaComplexType baseType = (XmlSchemaComplexType)collection.getTypeByQName(baseTypeName);
        // recurse onto the base type ...
        results.addAll(getContentAttributes(baseType, collection));
        // and now process our sequence.
        List<XmlSchemaAttributeOrGroupRef> extAttrs = getContentAttributes(type);
        results.addAll(extAttrs);
        return results;
    }
    // no base type, the simple case.
    List<XmlSchemaAttributeOrGroupRef> attrs = type.getAttributes();
    results.addAll(attrs);
    return results;
}
 
Example 2
Source File: Xsd2UmlConvert.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
private static final List<Attribute> parseFields(final XmlSchemaComplexType schemaComplexType,
        final XmlSchema schema, final Xsd2UmlConfig context) {
    final List<Attribute> attributes = new LinkedList<Attribute>();
    
    final XmlSchemaObjectCollection schemaItems = schemaComplexType.getAttributes();
    for (int i = 0, count = schemaItems.getCount(); i < count; i++) {
        final XmlSchemaObject schemaObject = schemaItems.getItem(i);
        if (schemaObject instanceof XmlSchemaAttribute) {
            final XmlSchemaAttribute schemaAttribute = (XmlSchemaAttribute) schemaObject;
            attributes.add(parseAttribute(schemaAttribute, schema, context));
            
        } else {
            throw new AssertionError(schemaObject);
        }
    }
    // parseAttributes(schemaComplexType.getAttributes(), schema);
    attributes.addAll(parseParticle(schemaComplexType.getParticle(), schema, context));
    
    return Collections.unmodifiableList(attributes);
}
 
Example 3
Source File: SmooksGenerator.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
private void addComplexTypeData(XmlSchemaComplexType schemaType, ComplexTypeData complexTypeData) {
    XmlSchemaObjectCollection attributes = schemaType.getAttributes();
    int numElements = attributes.getCount();
    parseParticleForElements(extractParticle(schemaType), complexTypeData);

    // Iterate XML Schema items
    for (int i = 0; i < numElements; i++) {
        XmlSchemaAttribute schemaAttribute = (XmlSchemaAttribute) attributes.getItem(i);
        complexTypeData.getAttributes().add(schemaAttribute.getName());
    }
}
 
Example 4
Source File: SchemaJavascriptBuilder.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void complexTypeSerializeAttributes(XmlSchemaComplexType type, String string) {
    @SuppressWarnings("unused")
    List<XmlSchemaAttributeOrGroupRef> attributes = type.getAttributes();
    // work in progress.
}
 
Example 5
Source File: CommonsSchemaInfoBuilder.java    From tomee with Apache License 2.0 4 votes vote down vote up
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;
}