Search in sources :

Example 1 with XSTerm

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

the class XSDSchemaReader method createGroup.

private void createGroup(XSModelGroupDecl modelGroupDecl) {
    EClass eClass = ecoreFactory.createEClass();
    eClass.setName(modelGroupDecl.getName());
    ePackage.getEClassifiers().add(eClass);
    for (XSParticle particle : modelGroupDecl.getModelGroup().getChildren()) {
        XSTerm term = particle.getTerm();
        if (term.isElementDecl()) {
            String name = term.asElementDecl().getName();
            EClassifier subClass = ePackage.getEClassifier(name);
            if (subClass != null && subClass instanceof EClass) {
                ((EClass) subClass).getESuperTypes().add(eClass);
            }
        }
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) XSParticle(com.sun.xml.xsom.XSParticle) XSTerm(com.sun.xml.xsom.XSTerm) EClassifier(org.eclipse.emf.ecore.EClassifier)

Example 2 with XSTerm

use of com.sun.xml.xsom.XSTerm 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 3 with XSTerm

use of com.sun.xml.xsom.XSTerm 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 4 with XSTerm

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

the class XmlSchemaInspector method printParticle.

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

Example 5 with XSTerm

use of com.sun.xml.xsom.XSTerm 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

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