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