Search in sources :

Example 1 with XSAttributeUse

use of com.sun.xml.xsom.XSAttributeUse in project atlasmap by atlasmap.

the class SchemaInspector method printAttributes.

private void printAttributes(XSComplexType xsComplexType, String rootName, XmlComplexType xmlComplexType) {
    Collection<? extends XSAttributeUse> c = xsComplexType.getDeclaredAttributeUses();
    for (XSAttributeUse aC : c) {
        XmlField xmlField = AtlasXmlModelFactory.createXmlField();
        XSAttributeDecl attributeDecl = aC.getDecl();
        xmlField.setName(getNameNS(attributeDecl));
        if (attributeDecl.getDefaultValue() != null) {
            xmlField.setValue(attributeDecl.getDefaultValue().value);
        } else if (attributeDecl.getFixedValue() != null) {
            xmlField.setValue(attributeDecl.getFixedValue().value);
        }
        xmlField.setPath(rootName + "/" + "@" + getNameNS(attributeDecl));
        FieldType attrType = getFieldType(attributeDecl.getType().getName());
        xmlField.setFieldType(attrType);
        if (xmlField.getFieldType() == null) {
            // check the simple types in the schema....
            XSSimpleType simpleType = xsComplexType.getRoot().getSimpleType(xsComplexType.getTargetNamespace(), attributeDecl.getType().getName());
            if (simpleType != null) {
                FieldType fieldType = getFieldType(simpleType.getBaseType().getName());
                xmlField.setFieldType(fieldType);
                xmlField.setTypeName(attributeDecl.getType().getName());
                if (simpleType.asRestriction() != null) {
                    mapRestrictions(xmlField, simpleType.asRestriction());
                }
            } else {
                // cannot figure it out....
                xmlField.setFieldType(FieldType.UNSUPPORTED);
            }
        }
        xmlComplexType.getXmlFields().getXmlField().add(xmlField);
    }
}
Also used : XSSimpleType(com.sun.xml.xsom.XSSimpleType) XmlField(io.atlasmap.xml.v2.XmlField) XSAttributeDecl(com.sun.xml.xsom.XSAttributeDecl) XSAttributeUse(com.sun.xml.xsom.XSAttributeUse) FieldType(io.atlasmap.v2.FieldType)

Aggregations

XSAttributeDecl (com.sun.xml.xsom.XSAttributeDecl)1 XSAttributeUse (com.sun.xml.xsom.XSAttributeUse)1 XSSimpleType (com.sun.xml.xsom.XSSimpleType)1 FieldType (io.atlasmap.v2.FieldType)1 XmlField (io.atlasmap.xml.v2.XmlField)1