]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Schema conversion updates (necessary for Proteus PID Profile schema)
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 4 Feb 2016 12:23:44 +0000 (12:23 +0000)
committerMarko Luukkainen <marko.luukkainen@vtt.fi>
Thu, 2 Feb 2017 12:01:34 +0000 (14:01 +0200)
refs #6301

git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@32344 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.xml.sax/src/org/simantics/xml/sax/ImporterGenerator.java
org.simantics.xml.sax/src/org/simantics/xml/sax/OntologyGenerator.java
org.simantics.xml.sax/src/org/simantics/xml/sax/SchemaConversionBase.java

index cff87ed72fcfc43ef3b65ac1d5090eadf687c287..eb99b5324ab2eb7e5f786bd011564b359c5b8d7f 100644 (file)
@@ -525,7 +525,8 @@ public class ImporterGenerator extends SchemaConversionBase{
                        String binding = getBindingFromPrimitiveType(base);\r
                        writeAttribute(fw, attrName, relationName, binding, isReference);\r
                } else {\r
-                       throw new RuntimeException("Cannot resolve type for Attribute " + attrName + " -> " + primitiveType.getLocalPart());\r
+                       //throw new RuntimeException("Cannot resolve type for Attribute " + attrName + " -> " + primitiveType.getLocalPart());\r
+                       //writeAttribute(fw, attrName, relationName, binding, isReference);\r
                }\r
        }\r
        \r
@@ -607,7 +608,8 @@ public class ImporterGenerator extends SchemaConversionBase{
                // FIXME : handle optional attributes properly.\r
                for (org.simantics.xml.sax.configuration.Attribute a : composition.getAttribute()) {\r
                        Attribute attribute = ((Attribute)attributes.getRight(a));\r
-                       QName atype = getBaseType(attribute);\r
+                       //QName atype = getBaseType(attribute);\r
+                       QName atype = getPrimitiveType(attribute);\r
                        String defaultValue = attribute.getDefault();\r
                        if (defaultValue == null)\r
                            defaultValue = getDefaultValue(atype);\r
index 530798ed2844bab05acb6784e4085dd69d04544b..0b7aa3c00aefa89263005c0a2fd87bf2fd3f849a 100644 (file)
@@ -101,6 +101,7 @@ public class OntologyGenerator extends SchemaConversionBase {
                        version = "1.0";\r
                \r
                name = name.replaceAll("\\.", "_");\r
+               name = name.replaceAll(" ", "_");\r
                className = converter.getPluginName() + "." + name;\r
                \r
                for (String s : converter.getHeader()) {\r
@@ -451,6 +452,9 @@ public class OntologyGenerator extends SchemaConversionBase {
        protected void handleElement(SchemaObject elementObj) {\r
                Element element = elementObj.getElement();\r
                String name = getName(elementObj);//element.getName();\r
+               \r
+//             if ("Presentation".equals(name))\r
+//                     System.out.println();\r
 \r
 //             if (parent != null)\r
 //                     name = parent +"_"+name;\r
index f35a8845acc74e7a0e081ffdf76498c67b7cf5b9..f523076ee7a8f00162238f20d905d306f68bbf6f 100644 (file)
@@ -436,6 +436,23 @@ public abstract class SchemaConversionBase {
                return null;\r
        }\r
        \r
+       protected QName getPrimitiveType(Attribute attribute) {\r
+               QName type = getBaseType(attribute);\r
+               String b = getBindingFromPrimitiveType(type);\r
+               while (b==null && type != null) {\r
+                       SchemaObject baseType = simpleTypeName.get(type.getLocalPart());\r
+                       if (baseType != null) {\r
+                               Restriction restriction = baseType.getSimpleType().getRestriction();\r
+                               if (restriction != null)\r
+                                       if (restriction.getBase() != null) {\r
+                                               type = restriction.getBase();\r
+                                               b = getBindingFromPrimitiveType(type);\r
+                                       }\r
+                       }\r
+               }\r
+               return type;\r
+       }\r
+       \r
        protected Attribute getRefAttribute(QName ref) {\r
                for (OpenAttrs attrs : schema.getSimpleTypeOrComplexTypeOrGroup()) {\r
                        if (attrs instanceof TopLevelAttribute) {\r