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();
}
}
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);
}
}
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();
}
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);
}
}
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();
}
Aggregations