]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.xml.sax/src/org/simantics/xml/sax/OntologyGenerator.java
Handling elements that inherit AtomicTypes
[simantics/interop.git] / org.simantics.xml.sax / src / org / simantics / xml / sax / OntologyGenerator.java
index 5ecb02e0e948b8555aeae87b7aaae6876893f074..095de9d2c20049a9f543fdae21459ebc8ef1dc91 100644 (file)
@@ -403,19 +403,32 @@ public class OntologyGenerator extends SchemaConversionBase {
        protected void handleSimpleType(SchemaObject parent, SchemaObject simpleTypeObj) {\r
                SimpleType simpleType = simpleTypeObj.getSimpleType();\r
                String name = simpleType.getName();\r
-               Restriction restriction = simpleType.getRestriction();\r
-               if (restriction == null || simpleType.getUnion() != null || simpleType.getId() != null)\r
-                       throw new RuntimeException();\r
-               QName base = restriction.getBase();\r
-               \r
-               String relationName = ontRoot+"has"+name;\r
-               if (parent != null)\r
-                       relationName = ontRoot+getName(parent)+".has"+name;\r
-               \r
-               writer.println(relationName+ " <R XML.hasAttribute : L0.FunctionalRelation");\r
                \r
-               String ontType = getL0Type(base);\r
-               writer.println("   --> " + ontType);\r
+               org.w3._2001.xmlschema.List list = simpleType.getList();\r
+               if (list != null) {\r
+                       // TODO : process restriction in lists\r
+                       String relationName = ontRoot+"has"+name;\r
+                       if (parent != null)\r
+                               relationName = ontRoot+getName(parent)+".has"+name;\r
+                       writer.println(relationName+ " <R XML.hasAttribute : L0.FunctionalRelation");\r
+                       \r
+                       String ontType = getL0Type(new QName(SCHEMA_NS, "string"));\r
+                       writer.println("   --> " + ontType);\r
+               } else {\r
+                       Restriction restriction = simpleType.getRestriction();\r
+                       if (restriction == null || simpleType.getUnion() != null || simpleType.getId() != null)\r
+                               throw new RuntimeException(simpleType.getName() + " restriction error");\r
+                       QName base = restriction.getBase();\r
+                       \r
+                       String relationName = ontRoot+"has"+name;\r
+                       if (parent != null)\r
+                               relationName = ontRoot+getName(parent)+".has"+name;\r
+                       \r
+                       writer.println(relationName+ " <R XML.hasAttribute : L0.FunctionalRelation");\r
+                       \r
+                       String ontType = getL0Type(base);\r
+                       writer.println("   --> " + ontType);\r
+               }\r
        }\r
        \r
        @Override\r