Search in sources :

Example 1 with XSComplexType

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

the class XSDSchemaReader method start.

@SuppressWarnings("deprecation")
private void start() {
    ePackage = ecoreFactory.createEPackage();
    ePackage.setName("ifc2x3");
    ePackage.setNsPrefix("iai");
    ePackage.setNsURI("http:///buildingsmart.ifc.ecore");
    XSOMParser parser = new XSOMParser();
    try {
        parser.parse(getClass().getResource("IFC2X3.xsd"));
        XSSchemaSet schemas = parser.getResult();
        for (XSSchema schema : schemas.getSchemas()) {
            if (schema.getTargetNamespace().equals("http://www.iai-tech.org/ifcXML/IFC2x3/FINAL")) {
                for (XSComplexType type : schema.getComplexTypes().values()) {
                    createComplexType(type);
                }
                for (XSSimpleType simpleType : schema.getSimpleTypes().values()) {
                    createSimpleType(simpleType);
                }
            }
        }
        for (XSSchema schema : schemas.getSchemas()) {
            if (schema.getTargetNamespace().equals("http://www.iai-tech.org/ifcXML/IFC2x3/FINAL")) {
                for (XSComplexType type : schema.getComplexTypes().values()) {
                    fillComplexType(type);
                }
                for (XSModelGroupDecl modelGroupDecl : schema.getModelGroupDecls().values()) {
                    createGroup(modelGroupDecl);
                }
            }
        }
        writeEMF("test.ecore");
    } catch (SAXException e) {
        e.printStackTrace();
    }
}
Also used : XSOMParser(com.sun.xml.xsom.parser.XSOMParser) XSSimpleType(com.sun.xml.xsom.XSSimpleType) XSComplexType(com.sun.xml.xsom.XSComplexType) XSModelGroupDecl(com.sun.xml.xsom.XSModelGroupDecl) XSSchemaSet(com.sun.xml.xsom.XSSchemaSet) XSSchema(com.sun.xml.xsom.XSSchema) SAXException(org.xml.sax.SAXException)

Example 2 with XSComplexType

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

the class ComplexTypeImpl method getAttributeUses.

public Collection<XSAttributeUse> getAttributeUses() {
    XSComplexType baseType = getBaseType().asComplexType();
    if (baseType == null)
        return super.getAttributeUses();
    // TODO: this is fairly inefficient
    Map<UName, XSAttributeUse> uses = new HashMap<UName, XSAttributeUse>();
    for (XSAttributeUse a : baseType.getAttributeUses()) uses.put(new UName(a.getDecl()), a);
    uses.keySet().removeAll(prohibitedAtts);
    for (XSAttributeUse a : super.getAttributeUses()) uses.put(new UName(a.getDecl()), a);
    return uses.values();
}
Also used : XSComplexType(com.sun.xml.xsom.XSComplexType) HashMap(java.util.HashMap) XSAttributeUse(com.sun.xml.xsom.XSAttributeUse)

Example 3 with XSComplexType

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

the class SchemaTreeTraverser method complexType.

/* (non-Javadoc)
     * @see com.sun.xml.xsom.visitor.XSVisitor#complexType(com.sun.xml.xsom.XSComplexType)
     */
public void complexType(XSComplexType type) {
    SchemaTreeNode newNode = new SchemaTreeNode(MessageFormat.format("ComplexType {0}", new Object[] { type.isLocal() ? "" : " name=\"" + type.getName() + "\"" }), type.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;
    if (type.getContentType().asSimpleType() != null) {
        // simple content
        SchemaTreeNode newNode2 = new SchemaTreeNode("Simple content", type.getContentType().getLocator());
        this.currNode.add(newNode2);
        this.currNode = newNode2;
        XSType baseType = type.getBaseType();
        if (type.getDerivationMethod() == XSType.RESTRICTION) {
            // restriction
            String str = MessageFormat.format("Restriction base=\"<{0}>{1}\"", new Object[] { baseType.getTargetNamespace(), baseType.getName() });
            SchemaTreeNode newNode3 = new SchemaTreeNode(str, baseType.getLocator());
            this.currNode.add(newNode3);
            this.currNode = newNode3;
            dumpComplexTypeAttribute(type);
            this.currNode = (SchemaTreeNode) this.currNode.getParent();
        } else {
            // extension
            String str = MessageFormat.format("Extension base=\"<{0}>{1}\"", new Object[] { baseType.getTargetNamespace(), baseType.getName() });
            SchemaTreeNode newNode3 = new SchemaTreeNode(str, baseType.getLocator());
            this.currNode.add(newNode3);
            this.currNode = newNode3;
            // check if have redefine tag
            if ((type.getTargetNamespace().compareTo(baseType.getTargetNamespace()) == 0) && (type.getName().compareTo(baseType.getName()) == 0)) {
                SchemaTreeNode newNodeRedefine = new SchemaTreeNode("redefine", type.getLocator());
                this.currNode.add(newNodeRedefine);
                this.currNode = newNodeRedefine;
                baseType.visit(this);
                this.currNode = (SchemaTreeNode) newNodeRedefine.getParent();
            }
            dumpComplexTypeAttribute(type);
            this.currNode = (SchemaTreeNode) this.currNode.getParent();
        }
        this.currNode = (SchemaTreeNode) this.currNode.getParent();
    } else {
        // complex content
        SchemaTreeNode newNode2 = new SchemaTreeNode("Complex content", type.getContentType().getLocator());
        this.currNode.add(newNode2);
        this.currNode = newNode2;
        XSComplexType baseType = type.getBaseType().asComplexType();
        if (type.getDerivationMethod() == XSType.RESTRICTION) {
            // restriction
            String str = MessageFormat.format("Restriction base=\"<{0}>{1}\"", new Object[] { baseType.getTargetNamespace(), baseType.getName() });
            SchemaTreeNode newNode3 = new SchemaTreeNode(str, baseType.getLocator());
            this.currNode.add(newNode3);
            this.currNode = newNode3;
            type.getContentType().visit(this);
            dumpComplexTypeAttribute(type);
            this.currNode = (SchemaTreeNode) this.currNode.getParent();
        } else {
            // extension
            String str = MessageFormat.format("Extension base=\"'{'{0}'}'{1}\"", new Object[] { baseType.getTargetNamespace(), baseType.getName() });
            SchemaTreeNode newNode3 = new SchemaTreeNode(str, baseType.getLocator());
            this.currNode.add(newNode3);
            this.currNode = newNode3;
            // check if have redefine tag
            if ((type.getTargetNamespace().compareTo(baseType.getTargetNamespace()) == 0) && (type.getName().compareTo(baseType.getName()) == 0)) {
                SchemaTreeNode newNodeRedefine = new SchemaTreeNode("redefine", type.getLocator());
                this.currNode.add(newNodeRedefine);
                this.currNode = newNodeRedefine;
                baseType.visit(this);
                this.currNode = (SchemaTreeNode) newNodeRedefine.getParent();
            }
            type.getExplicitContent().visit(this);
            dumpComplexTypeAttribute(type);
            this.currNode = (SchemaTreeNode) this.currNode.getParent();
        }
        this.currNode = (SchemaTreeNode) this.currNode.getParent();
    }
    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
Also used : XSType(com.sun.xml.xsom.XSType) XSComplexType(com.sun.xml.xsom.XSComplexType)

Example 4 with XSComplexType

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

the class SchemaTreeTraverser method schema.

/* (non-Javadoc)
     * @see com.sun.xml.xsom.visitor.XSVisitor#schema(com.sun.xml.xsom.XSSchema)
     */
public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace)) {
        return;
    }
    SchemaTreeNode newNode = new SchemaTreeNode("Schema " + s.getLocator().getSystemId(), s.getLocator());
    this.currNode = newNode;
    this.model.addSchemaNode(newNode);
    for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) {
        attGroupDecl(groupDecl);
    }
    for (XSAttributeDecl attrDecl : s.getAttributeDecls().values()) {
        attributeDecl(attrDecl);
    }
    for (XSComplexType complexType : s.getComplexTypes().values()) {
        complexType(complexType);
    }
    for (XSElementDecl elementDecl : s.getElementDecls().values()) {
        elementDecl(elementDecl);
    }
    for (XSModelGroupDecl modelGroupDecl : s.getModelGroupDecls().values()) {
        modelGroupDecl(modelGroupDecl);
    }
    for (XSSimpleType simpleType : s.getSimpleTypes().values()) {
        simpleType(simpleType);
    }
}
Also used : XSAttGroupDecl(com.sun.xml.xsom.XSAttGroupDecl) XSSimpleType(com.sun.xml.xsom.XSSimpleType) XSComplexType(com.sun.xml.xsom.XSComplexType) XSModelGroupDecl(com.sun.xml.xsom.XSModelGroupDecl) XSAttributeDecl(com.sun.xml.xsom.XSAttributeDecl) XSElementDecl(com.sun.xml.xsom.XSElementDecl)

Example 5 with XSComplexType

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

the class ComplexTypeImpl method getSubtypes.

public List<XSComplexType> getSubtypes() {
    ArrayList subtypeList = new ArrayList();
    Iterator<XSComplexType> cTypes = getRoot().iterateComplexTypes();
    while (cTypes.hasNext()) {
        XSComplexType cType = cTypes.next();
        XSType base = cType.getBaseType();
        if ((base != null) && (base.equals(this))) {
            subtypeList.add(cType);
        }
    }
    return subtypeList;
}
Also used : XSType(com.sun.xml.xsom.XSType) XSComplexType(com.sun.xml.xsom.XSComplexType) ArrayList(java.util.ArrayList)

Aggregations

XSComplexType (com.sun.xml.xsom.XSComplexType)9 XSModelGroupDecl (com.sun.xml.xsom.XSModelGroupDecl)3 XSSimpleType (com.sun.xml.xsom.XSSimpleType)3 XSType (com.sun.xml.xsom.XSType)3 XSAttGroupDecl (com.sun.xml.xsom.XSAttGroupDecl)2 XSAttributeDecl (com.sun.xml.xsom.XSAttributeDecl)2 XSElementDecl (com.sun.xml.xsom.XSElementDecl)2 XSAttributeUse (com.sun.xml.xsom.XSAttributeUse)1 XSSchema (com.sun.xml.xsom.XSSchema)1 XSSchemaSet (com.sun.xml.xsom.XSSchemaSet)1 XSOMParser (com.sun.xml.xsom.parser.XSOMParser)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 EAttribute (org.eclipse.emf.ecore.EAttribute)1 EClassifier (org.eclipse.emf.ecore.EClassifier)1 EReference (org.eclipse.emf.ecore.EReference)1 SAXException (org.xml.sax.SAXException)1