Search in sources :

Example 1 with XSModelGroup

use of com.sun.xml.xsom.XSModelGroup in project BIMserver by opensourceBIM.

the class XSDSchemaReader method fillComplexType.

private void fillComplexType(XSComplexType type) {
    EClass eClass = (EClass) ePackage.getEClassifier(type.getName());
    String superTypeName = type.getBaseType().getName();
    EClass superType = (EClass) ePackage.getEClassifier(superTypeName);
    if (superType != null) {
        eClass.getESuperTypes().add(superType);
    } else {
        if (!superTypeName.equals("Entity") && !superTypeName.equals("anyType")) {
            System.out.println("Super type not found: " + superTypeName);
        }
    }
    XSParticle particle = type.getContentType().asParticle();
    if (particle != null) {
        XSTerm term = particle.getTerm();
        if (term.isModelGroup()) {
            XSModelGroup xsModelGroup = term.asModelGroup();
            for (XSParticle p : xsModelGroup.getChildren()) {
                XSTerm pterm = p.getTerm();
                if (pterm.isModelGroup()) {
                    XSModelGroup asModelGroup = pterm.asModelGroup();
                    for (XSParticle x : asModelGroup.getChildren()) {
                        XSTerm term2 = x.getTerm();
                        if (term2.isElementDecl()) {
                            processElementDecl(eClass, term2.asElementDecl());
                        }
                    }
                } else if (pterm.isElementDecl()) {
                    processElementDecl(eClass, pterm.asElementDecl());
                }
            }
        } else if (term.isModelGroupDecl()) {
        // EReference eReference = ecoreFactory.createEReference();
        // eReference.setName(term.asModelGroupDecl().getName());
        // EClassifier eClassifier =
        // ePackage.getEClassifier(term.asModelGroupDecl().getName());
        // eReference.setEType(eClassifier);
        // eClass.getEStructuralFeatures().add(eReference);
        } else if (term.isElementDecl()) {
            System.out.println("ed");
        } else {
            System.out.println("lala");
        }
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) XSParticle(com.sun.xml.xsom.XSParticle) XSTerm(com.sun.xml.xsom.XSTerm) XSModelGroup(com.sun.xml.xsom.XSModelGroup)

Example 2 with XSModelGroup

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

the class SchemaInspector method printParticle.

private void printParticle(XSParticle particle, String rootName, XmlComplexType xmlComplexType) throws Exception {
    XSTerm term = particle.getTerm();
    if (term.isModelGroup()) {
        XSModelGroup group = term.asModelGroup();
        printGroup(group, rootName, xmlComplexType);
    } else if (term.isModelGroupDecl()) {
        printGroupDecl(term.asModelGroupDecl(), rootName, xmlComplexType);
    } else if (term.isElementDecl()) {
        CollectionType collectionType = getCollectionType(particle);
        printElement(term.asElementDecl(), rootName, xmlComplexType, collectionType);
    }
}
Also used : XSTerm(com.sun.xml.xsom.XSTerm) CollectionType(io.atlasmap.v2.CollectionType) XSModelGroup(com.sun.xml.xsom.XSModelGroup)

Example 3 with XSModelGroup

use of com.sun.xml.xsom.XSModelGroup in project narayana by jbosstm.

the class NBFSchemaParser method findElementType.

private void findElementType(XSComplexType xtype) {
    XSContentType xsContentType = xtype.getContentType();
    XSParticle particle = xsContentType.asParticle();
    if (particle != null) {
        XSTerm term = particle.getTerm();
        if (term.isModelGroup()) {
            XSModelGroup xsModelGroup = term.asModelGroup();
            XSParticle[] particles = xsModelGroup.getChildren();
            for (XSParticle p : particles) {
                XSTerm pterm = p.getTerm();
                if (pterm.isElementDecl()) {
                    XSElementDecl element = pterm.asElementDecl();
                    String name = element.getName();
                    log.debug(name);
                    XSType type = element.getType();
                    while (type != null) {
                        String typeName = type.getName();
                        if (typeName != null && (typeName.equals("long") || typeName.equals("string") || typeName.equals("integer") || typeName.equals("float") || typeName.endsWith("_type"))) {
                            log.debug(typeName);
                            flds.put(name, typeName);
                            break;
                        }
                        type = type.getBaseType();
                    }
                }
            }
        }
    }
}
Also used : XSType(com.sun.xml.xsom.XSType) XSContentType(com.sun.xml.xsom.XSContentType) XSParticle(com.sun.xml.xsom.XSParticle) XSTerm(com.sun.xml.xsom.XSTerm) XSElementDecl(com.sun.xml.xsom.XSElementDecl) XSModelGroup(com.sun.xml.xsom.XSModelGroup)

Aggregations

XSModelGroup (com.sun.xml.xsom.XSModelGroup)3 XSTerm (com.sun.xml.xsom.XSTerm)3 XSParticle (com.sun.xml.xsom.XSParticle)2 XSContentType (com.sun.xml.xsom.XSContentType)1 XSElementDecl (com.sun.xml.xsom.XSElementDecl)1 XSType (com.sun.xml.xsom.XSType)1 CollectionType (io.atlasmap.v2.CollectionType)1 EClass (org.eclipse.emf.ecore.EClass)1