Search in sources :

Example 1 with XSSimpleType

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

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

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

the class SchemaTreeTraverser method dump.

/**
 * Creates node for attribute declaration with additional attributes.
 *
 * @param decl           Attribute declaration.
 * @param additionalAtts Additional attributes.
 */
private void dump(XSAttributeDecl decl, String additionalAtts) {
    XSSimpleType type = decl.getType();
    String str = MessageFormat.format("Attribute \"{0}\"{1}{2}{3}{4}", new Object[] { decl.getName(), additionalAtts, type.isLocal() ? "" : MessageFormat.format(" type=\"'{'{0}'}'{1}\"", new Object[] { type.getTargetNamespace(), type.getName() }), decl.getFixedValue() == null ? "" : " fixed=\"" + decl.getFixedValue() + "\"", decl.getDefaultValue() == null ? "" : " default=\"" + decl.getDefaultValue() + "\"" });
    SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;
    if (type.isLocal()) {
        simpleType(type);
    }
    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
Also used : XSSimpleType(com.sun.xml.xsom.XSSimpleType)

Example 4 with XSSimpleType

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

the class SchemaTreeTraverser method listSimpleType.

/* (non-Javadoc)
     * @see com.sun.xml.xsom.visitor.XSSimpleTypeVisitor#listSimpleType(com.sun.xml.xsom.XSListSimpleType)
     */
public void listSimpleType(XSListSimpleType type) {
    XSSimpleType itemType = type.getItemType();
    if (itemType.isLocal()) {
        SchemaTreeNode newNode = new SchemaTreeNode("List", type.getLocator());
        this.currNode.add(newNode);
        this.currNode = newNode;
        simpleType(itemType);
        this.currNode = (SchemaTreeNode) this.currNode.getParent();
    } else {
        // global type
        String str = MessageFormat.format("List itemType=\"'{'{0}'}'{1}\"", new Object[] { itemType.getTargetNamespace(), itemType.getName() });
        SchemaTreeNode newNode = new SchemaTreeNode(str, itemType.getLocator());
        this.currNode.add(newNode);
    }
}
Also used : XSSimpleType(com.sun.xml.xsom.XSSimpleType)

Example 5 with XSSimpleType

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

the class SchemaTreeTraverser method restrictionSimpleType.

/* (non-Javadoc)
     * @see com.sun.xml.xsom.visitor.XSSimpleTypeVisitor#restrictionSimpleType(com.sun.xml.xsom.XSRestrictionSimpleType)
     */
public void restrictionSimpleType(XSRestrictionSimpleType type) {
    if (type.getBaseType() == null) {
        // don't print anySimpleType
        if (!type.getName().equals("anySimpleType")) {
            throw new InternalError();
        }
        if (!Const.schemaNamespace.equals(type.getTargetNamespace())) {
            throw new InternalError();
        }
        return;
    }
    XSSimpleType baseType = type.getSimpleBaseType();
    String str = MessageFormat.format("Restriction {0}", new Object[] { baseType.isLocal() ? "" : " base=\"{" + baseType.getTargetNamespace() + "}" + baseType.getName() + "\"" });
    SchemaTreeNode newNode = new SchemaTreeNode(str, baseType.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;
    if (baseType.isLocal()) {
        simpleType(baseType);
    }
    Iterator itr = type.iterateDeclaredFacets();
    while (itr.hasNext()) {
        facet((XSFacet) itr.next());
    }
    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
Also used : XSSimpleType(com.sun.xml.xsom.XSSimpleType) Iterator(java.util.Iterator)

Aggregations

XSSimpleType (com.sun.xml.xsom.XSSimpleType)14 XSAttributeDecl (com.sun.xml.xsom.XSAttributeDecl)4 XSComplexType (com.sun.xml.xsom.XSComplexType)3 XSModelGroupDecl (com.sun.xml.xsom.XSModelGroupDecl)3 Iterator (java.util.Iterator)3 XSAttGroupDecl (com.sun.xml.xsom.XSAttGroupDecl)2 XSAttributeUse (com.sun.xml.xsom.XSAttributeUse)2 XSElementDecl (com.sun.xml.xsom.XSElementDecl)2 XSIdentityConstraint (com.sun.xml.xsom.XSIdentityConstraint)2 FieldType (io.atlasmap.v2.FieldType)2 XmlField (io.atlasmap.xml.v2.XmlField)2 XSFacet (com.sun.xml.xsom.XSFacet)1 XSSchema (com.sun.xml.xsom.XSSchema)1 XSSchemaSet (com.sun.xml.xsom.XSSchemaSet)1 XSOMParser (com.sun.xml.xsom.parser.XSOMParser)1 SAXException (org.xml.sax.SAXException)1