Search in sources :

Example 1 with XSSchema

use of com.sun.xml.xsom.XSSchema in project midpoint by Evolveum.

the class SchemaProcessor method getComplexTypeToElementName.

private Map<QName, List<QName>> getComplexTypeToElementName(ClassOutline classOutline) {
    Map<QName, List<QName>> complexTypeToElementName = new HashMap<QName, List<QName>>();
    XSSchemaSet schemaSet = classOutline.target.getSchemaComponent().getRoot();
    for (XSSchema schema : schemaSet.getSchemas()) {
        Map<String, XSElementDecl> elemDecls = schema.getElementDecls();
        for (Entry<String, XSElementDecl> entry : elemDecls.entrySet()) {
            XSElementDecl decl = entry.getValue();
            XSType xsType = decl.getType();
            if (xsType.getName() == null) {
                continue;
            }
            QName type = new QName(xsType.getTargetNamespace(), xsType.getName());
            List<QName> qnames = complexTypeToElementName.get(type);
            if (qnames == null) {
                qnames = new ArrayList<QName>();
                complexTypeToElementName.put(type, qnames);
            }
            qnames.add(new QName(decl.getTargetNamespace(), decl.getName()));
        }
    }
    return complexTypeToElementName;
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) XSSchemaSet(com.sun.xml.xsom.XSSchemaSet) XSSchema(com.sun.xml.xsom.XSSchema) XSType(com.sun.xml.xsom.XSType) PrismReferenceArrayList(com.evolveum.midpoint.prism.xjc.PrismReferenceArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PrismContainerArrayList(com.evolveum.midpoint.prism.xjc.PrismContainerArrayList) XSElementDecl(com.sun.xml.xsom.XSElementDecl)

Example 2 with XSSchema

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

the class SchemaInspector method printSchemaSet.

private void printSchemaSet(XSSchemaSet schemaSet) throws Exception {
    if (schemaSet == null) {
        throw new XmlInspectionException("Schema set is null");
    }
    XSSchema schema = rootNamespace != null ? schemaSet.getSchema(rootNamespace) : schemaSet.getSchema("");
    // we only care about declared elements...
    Iterator<XSElementDecl> jtr = schema.iterateElementDecls();
    while (jtr.hasNext()) {
        XSElementDecl e = jtr.next();
        String rootName = getNameNS(e);
        if (e.getType().isComplexType()) {
            XmlComplexType rootComplexType = getXmlComplexType();
            rootComplexType.setName(rootName);
            rootComplexType.setPath("/" + rootName);
            rootComplexType.setFieldType(FieldType.COMPLEX);
            xmlDocument.getFields().getField().add(rootComplexType);
            printComplexType(e.getType().asComplexType(), "/" + rootName, rootComplexType);
        } else if (e.getType().isSimpleType()) {
            XmlField xmlField = AtlasXmlModelFactory.createXmlField();
            xmlField.setName(rootName);
            xmlField.setPath("/" + rootName);
            xmlDocument.getFields().getField().add(xmlField);
            printSimpleType(e.getType().asSimpleType(), xmlField);
        }
    }
}
Also used : XmlComplexType(io.atlasmap.xml.v2.XmlComplexType) XmlField(io.atlasmap.xml.v2.XmlField) XSElementDecl(com.sun.xml.xsom.XSElementDecl) XSSchema(com.sun.xml.xsom.XSSchema)

Aggregations

XSElementDecl (com.sun.xml.xsom.XSElementDecl)2 XSSchema (com.sun.xml.xsom.XSSchema)2 PrismContainerArrayList (com.evolveum.midpoint.prism.xjc.PrismContainerArrayList)1 PrismReferenceArrayList (com.evolveum.midpoint.prism.xjc.PrismReferenceArrayList)1 XSSchemaSet (com.sun.xml.xsom.XSSchemaSet)1 XSType (com.sun.xml.xsom.XSType)1 XmlComplexType (io.atlasmap.xml.v2.XmlComplexType)1 XmlField (io.atlasmap.xml.v2.XmlField)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 QName (javax.xml.namespace.QName)1