Search in sources :

Example 1 with XmlAttributeGroupReferenceProperty

use of eu.esdihumboldt.hale.io.xsd.reader.internal.XmlAttributeGroupReferenceProperty in project hale by halestudio.

the class XmlSchemaReader method createAttributesFromCollection.

private void createAttributesFromCollection(XmlSchemaObjectCollection attributeCollection, DefinitionGroup declaringType, String indexPrefix, String schemaLocation, String schemaNamespace) {
    if (indexPrefix == null) {
        // $NON-NLS-1$
        indexPrefix = "";
    }
    for (int index = 0; index < attributeCollection.getCount(); index++) {
        XmlSchemaObject object = attributeCollection.getItem(index);
        if (object instanceof XmlSchemaAttribute) {
            // <attribute ... />
            XmlSchemaAttribute attribute = (XmlSchemaAttribute) object;
            createAttribute(attribute, declaringType, schemaLocation, schemaNamespace);
        } else if (object instanceof XmlSchemaAttributeGroup) {
            XmlSchemaAttributeGroup group = (XmlSchemaAttributeGroup) object;
            createAttributes(group, declaringType, indexPrefix + index, schemaLocation, schemaNamespace);
        } else if (object instanceof XmlSchemaAttributeGroupRef) {
            XmlSchemaAttributeGroupRef groupRef = (XmlSchemaAttributeGroupRef) object;
            if (groupRef.getRefName() != null) {
                QName groupName = groupRef.getRefName();
                // XXX extend group name with namespace?
                XmlAttributeGroupReferenceProperty property = new XmlAttributeGroupReferenceProperty(groupName, declaringType, this.index, groupName, true);
                // TODO add constraints?
                // set metadata
                setMetadata(property, groupRef, schemaLocation);
            } else {
                reporter.error(new IOMessageImpl("Unrecognized attribute group reference", null, object.getLineNumber(), object.getLinePosition()));
            }
        }
    }
}
Also used : XmlAttributeGroupReferenceProperty(eu.esdihumboldt.hale.io.xsd.reader.internal.XmlAttributeGroupReferenceProperty) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) QName(javax.xml.namespace.QName) XmlSchemaAttributeGroup(org.apache.ws.commons.schema.XmlSchemaAttributeGroup) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute) XmlSchemaAttributeGroupRef(org.apache.ws.commons.schema.XmlSchemaAttributeGroupRef)

Aggregations

IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)1 XmlAttributeGroupReferenceProperty (eu.esdihumboldt.hale.io.xsd.reader.internal.XmlAttributeGroupReferenceProperty)1 QName (javax.xml.namespace.QName)1 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)1 XmlSchemaAttributeGroup (org.apache.ws.commons.schema.XmlSchemaAttributeGroup)1 XmlSchemaAttributeGroupRef (org.apache.ws.commons.schema.XmlSchemaAttributeGroupRef)1 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)1