]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.xml.sax/src/org/simantics/xml/sax/SchemaConverter.java
Several updates to interoperability.
[simantics/interop.git] / org.simantics.xml.sax / src / org / simantics / xml / sax / SchemaConverter.java
index 1b2b3722606832c8f55fc62cc7c082e97cc1eab6..adab7f2af75112da339adba44dabab01fceb50f5 100644 (file)
@@ -16,6 +16,7 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
 
 import org.simantics.utils.datastructures.MapList;
 import org.simantics.xml.sax.configuration.Configuration;
@@ -221,6 +222,7 @@ public class SchemaConverter {
                header[3] = "Date " + new Date().toString();
                
                schemaNs = schema.getTargetNamespace();
+               
                ontologyUri = schemaNs;
                if (ontologyUri == null) {
                        ontologyUri = getSchemaFile().getName();
@@ -228,6 +230,7 @@ public class SchemaConverter {
                        int index = ontologyUri.lastIndexOf(".");
                        if (index > 0)
                                ontologyUri = ontologyUri.substring(0, index);
+                       schemaNs = "";
                } 
                ontologyUri = ontologyUri.replaceAll(" ", "_");
                String parts[] = ontologyUri.split("/");
@@ -335,7 +338,25 @@ public class SchemaConverter {
        }
        
        public boolean isPrimary() {
-               return getRoot().schemaNSMap.getValues(schemaNs).indexOf(this) == 0;
+               return getRoot() == this;
+       }
+
+       public String getShortName(String namespaceURI) {
+               List<SchemaConverter> converters = getRoot().getConverter(namespaceURI);
+               for (SchemaConverter conv : converters) {
+                       if (conv.shortName != null)
+                               return conv.shortName;
+               }
+               return null;
+       }
+       
+       public String getOntologyClassName(String namespaceURI) {
+               List<SchemaConverter> converters = getRoot().getConverter(namespaceURI);
+               for (SchemaConverter conv : converters) {
+                       if (conv.className != null)
+                               return conv.className;
+               }
+               return null;
        }