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