Search in sources :

Example 1 with XSRestrictionSimpleType

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

the class SchemaInspector method printElement.

private void printElement(XSElementDecl element, String root, XmlComplexType xmlComplexType, CollectionType collectionType) throws Exception {
    String rootName = root;
    if (element.getType().isComplexType()) {
        XmlComplexType complexType = getXmlComplexType();
        rootName = rootName + "/" + getNameNS(element);
        complexType.setName(getNameNS(element));
        complexType.setPath(rootName);
        complexType.setCollectionType(collectionType);
        xmlComplexType.getXmlFields().getXmlField().add(complexType);
        printComplexType(element.getType().asComplexType(), rootName, complexType);
    } else {
        if (element.getType() != null && element.getType().asSimpleType() != null) {
            XmlField xmlField = AtlasXmlModelFactory.createXmlField();
            xmlField.setName(getNameNS(element));
            xmlField.setPath(rootName + "/" + getNameNS(element));
            xmlComplexType.getXmlFields().getXmlField().add(xmlField);
            if (element.getDefaultValue() != null) {
                xmlField.setValue(element.getDefaultValue());
            } else if (element.getFixedValue() != null) {
                xmlField.setValue(element.getFixedValue());
            }
            XSRestrictionSimpleType typeRestriction = element.getType().asSimpleType().asRestriction();
            if (typeRestriction != null) {
                xmlField.setFieldType(XS_TYPE_TO_FIELD_TYPE_MAP.get(typeRestriction.getBaseType().getName()));
                mapRestrictions(xmlField, typeRestriction);
            }
            printSimpleType(element.getType().asSimpleType(), xmlField);
        }
    }
}
Also used : XmlComplexType(io.atlasmap.xml.v2.XmlComplexType) XSRestrictionSimpleType(com.sun.xml.xsom.XSRestrictionSimpleType) XmlField(io.atlasmap.xml.v2.XmlField)

Aggregations

XSRestrictionSimpleType (com.sun.xml.xsom.XSRestrictionSimpleType)1 XmlComplexType (io.atlasmap.xml.v2.XmlComplexType)1 XmlField (io.atlasmap.xml.v2.XmlField)1