Search in sources :

Example 6 with XSComplexType

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

the class SchemaWriter method schema.

public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace))
        return;
    println(MessageFormat.format("<schema targetNamespace=\"{0}\">", s.getTargetNamespace()));
    indent++;
    Iterator itr;
    itr = s.iterateAttGroupDecls();
    while (itr.hasNext()) attGroupDecl((XSAttGroupDecl) itr.next());
    itr = s.iterateAttributeDecls();
    while (itr.hasNext()) attributeDecl((XSAttributeDecl) itr.next());
    itr = s.iterateComplexTypes();
    while (itr.hasNext()) complexType((XSComplexType) itr.next());
    itr = s.iterateElementDecls();
    while (itr.hasNext()) elementDecl((XSElementDecl) itr.next());
    itr = s.iterateModelGroupDecls();
    while (itr.hasNext()) modelGroupDecl((XSModelGroupDecl) itr.next());
    itr = s.iterateSimpleTypes();
    while (itr.hasNext()) simpleType((XSSimpleType) itr.next());
    indent--;
    println("</schema>");
}
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) Iterator(java.util.Iterator) XSElementDecl(com.sun.xml.xsom.XSElementDecl)

Example 7 with XSComplexType

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

the class SchemaWriter method complexType.

public void complexType(XSComplexType type) {
    println(MessageFormat.format("<complexType{0}>", type.isLocal() ? "" : " name=\"" + type.getName() + '\"'));
    indent++;
    if (type.getContentType().asSimpleType() != null) {
        // simple content
        println("<simpleContent>");
        indent++;
        XSType baseType = type.getBaseType();
        if (type.getDerivationMethod() == XSType.RESTRICTION) {
            // restriction
            println(MessageFormat.format("<restriction base=\"<{0}>{1}\">", baseType.getTargetNamespace(), baseType.getName()));
            indent++;
            dumpComplexTypeAttribute(type);
            indent--;
            println("</restriction>");
        } else {
            // extension
            println(MessageFormat.format("<extension base=\"<{0}>{1}\">", baseType.getTargetNamespace(), baseType.getName()));
            // check if have redefine tag - Kirill
            if (type.isGlobal() && type.getTargetNamespace().equals(baseType.getTargetNamespace()) && type.getName().equals(baseType.getName())) {
                indent++;
                println("<redefine>");
                indent++;
                baseType.visit(this);
                indent--;
                println("</redefine>");
                indent--;
            }
            indent++;
            dumpComplexTypeAttribute(type);
            indent--;
            println("</extension>");
        }
        indent--;
        println("</simpleContent>");
    } else {
        // complex content
        println("<complexContent>");
        indent++;
        XSComplexType baseType = type.getBaseType().asComplexType();
        if (type.getDerivationMethod() == XSType.RESTRICTION) {
            // restriction
            println(MessageFormat.format("<restriction base=\"'{'{0}'}'{1}\">", baseType.getTargetNamespace(), baseType.getName()));
            indent++;
            type.getContentType().visit(this);
            dumpComplexTypeAttribute(type);
            indent--;
            println("</restriction>");
        } else {
            // extension
            println(MessageFormat.format("<extension base=\"'{'{0}'}'{1}\">", baseType.getTargetNamespace(), baseType.getName()));
            // check if have redefine - Kirill
            if (type.isGlobal() && type.getTargetNamespace().equals(baseType.getTargetNamespace()) && type.getName().equals(baseType.getName())) {
                indent++;
                println("<redefine>");
                indent++;
                baseType.visit(this);
                indent--;
                println("</redefine>");
                indent--;
            }
            indent++;
            type.getExplicitContent().visit(this);
            dumpComplexTypeAttribute(type);
            indent--;
            println("</extension>");
        }
        indent--;
        println("</complexContent>");
    }
    indent--;
    println("</complexType>");
}
Also used : XSType(com.sun.xml.xsom.XSType) XSComplexType(com.sun.xml.xsom.XSComplexType)

Example 8 with XSComplexType

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

the class redefine method action2.

private void action2() throws SAXException {
    XSComplexType oldCt = $runtime.currentSchema.getComplexType(newCt.getName());
    if (oldCt == null) {
        $runtime.reportError(Messages.format(Messages.ERR_UNDEFINED_COMPLEXTYPE, newCt.getName()));
    } else {
        newCt.redefine((ComplexTypeImpl) oldCt);
        $runtime.currentSchema.addComplexType(newCt, true);
    }
}
Also used : XSComplexType(com.sun.xml.xsom.XSComplexType)

Example 9 with XSComplexType

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

the class XSDSchemaReader method processElementDecl.

private void processElementDecl(EClass eClass, XSElementDecl asElementDecl) {
    String propertyName = asElementDecl.getName();
    String propertyType = null;
    if (asElementDecl.getType().getName() != null) {
        propertyType = asElementDecl.getType().getName();
        if (propertyType.equals("double")) {
            EAttribute eAttribute = ecoreFactory.createEAttribute();
            eAttribute.setName(propertyName);
            eAttribute.setEType(ecorePackage.getEDouble());
            eClass.getEStructuralFeatures().add(eAttribute);
        } else if (propertyType.equals("long")) {
            EAttribute eAttribute = ecoreFactory.createEAttribute();
            eAttribute.setName(propertyName);
            eAttribute.setEType(ecorePackage.getELong());
            eClass.getEStructuralFeatures().add(eAttribute);
        } else if (propertyType.equals("boolean") || propertyType.equals("logical")) {
            EAttribute eAttribute = ecoreFactory.createEAttribute();
            eAttribute.setName(propertyName);
            eAttribute.setEType(ecorePackage.getEBoolean());
            eClass.getEStructuralFeatures().add(eAttribute);
        } else if (propertyType.equals("anyType")) {
            XSComplexType asComplexType = asElementDecl.getType().asComplexType();
            EReference eReference = ecoreFactory.createEReference();
            eReference.setEType(createComplexType(asComplexType));
            eReference.setName(propertyName);
            eClass.getEStructuralFeatures().add(eReference);
        } else {
            EClassifier eClassifier = ePackage.getEClassifier(propertyType);
            if (eClassifier != null) {
                EReference eReference = ecoreFactory.createEReference();
                eReference.setName(propertyName);
                eReference.setEType(eClassifier);
                eClass.getEStructuralFeatures().add(eReference);
            } else {
                System.out.println(propertyType + " not found");
            }
        }
    }
}
Also used : EAttribute(org.eclipse.emf.ecore.EAttribute) XSComplexType(com.sun.xml.xsom.XSComplexType) EClassifier(org.eclipse.emf.ecore.EClassifier) EReference(org.eclipse.emf.ecore.EReference)

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