]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Schema parsing can access data from other schemas (work in progress)
authorMarko Luukkainen <marko.luukkainen@vtt.fi>
Thu, 2 Feb 2017 12:45:59 +0000 (14:45 +0200)
committerMarko Luukkainen <marko.luukkainen@vtt.fi>
Thu, 2 Feb 2017 12:49:09 +0000 (14:49 +0200)
refs #6985

Change-Id: Ieb98b942605b85ab81e25c7fa93fcc62e387ed32

org.simantics.xml.sax/src/org/simantics/xml/sax/ExporterGenerator.java
org.simantics.xml.sax/src/org/simantics/xml/sax/ImporterGenerator.java
org.simantics.xml.sax/src/org/simantics/xml/sax/JavaGenerator.java
org.simantics.xml.sax/src/org/simantics/xml/sax/OntologyGenerator.java
org.simantics.xml.sax/src/org/simantics/xml/sax/SchemaConversionBase.java
org.simantics.xml.sax/src/org/simantics/xml/sax/SchemaConverter.java

index d1f67a426c7ff73a138c02dd25517f91f9407574..dc82a9fdf16542e8923d156deb42e0f539268d80 100644 (file)
@@ -456,7 +456,7 @@ public class ExporterGenerator extends JavaGenerator{
                                return;\r
                    } else {\r
                        if (simpleType == null) {\r
-                               SchemaObject simpleTypeObj = base.simpleTypeName.get(primitiveType.getLocalPart());\r
+                               SchemaObject simpleTypeObj = base.getSimpleType(primitiveType);\r
                                if (simpleTypeObj != null)\r
                                        simpleType = simpleTypeObj.getSimpleType();\r
                        }       \r
@@ -524,7 +524,7 @@ public class ExporterGenerator extends JavaGenerator{
        public void handle(SchemaObject parent, AttributeGroup attribute) {\r
                if (parent != null) {\r
                        FileWriter fw = getWriter(parent);\r
-                       NamedAttributeGroup group = this.base.getAttributeGroup(attribute.getRef().getLocalPart());\r
+                       NamedAttributeGroup group = this.base.getAttributeGroup(attribute.getRef());\r
                        fw.writer.println(commentTag+"    AttributeGroup " + group.getName());\r
                        SchemaObject obj = new SchemaObject(parent,attribute);\r
                        for (Annotated annotated : group.getAttributeOrAttributeGroup()) {\r
@@ -667,7 +667,7 @@ public class ExporterGenerator extends JavaGenerator{
                fw.writer.println("        "+getOntologyImport());\r
                fw.writer.println("        for (Statement attribute : attributes) {");\r
                if (complexType != null) {\r
-                       SchemaObject obj = this.base.complexTypes.get(complexType);\r
+                       SchemaObject obj = this.base.getComplexType(complexType);\r
                        this.base.handleElementComplexTypeAttributes(obj);\r
                } \r
                fw.writer.println("        }");\r
@@ -717,7 +717,7 @@ public class ExporterGenerator extends JavaGenerator{
                fw.writer.println("      super(graph);");\r
                fw.writer.println("      "+getOntologyImport());\r
                if (complexType != null) {\r
-                       SchemaObject obj = this.base.complexTypes.get(complexType);\r
+                       SchemaObject obj = this.base.getComplexType(complexType);\r
                        this.base.handleComplexTypeExtension(obj);\r
                } else if (simpleType != null) {\r
                        \r
index 2e5fb272438b917481ab6fd67fe24d3aa76ea939..3d137cf33b7357cba1decc999bc3e32852c419ea 100644 (file)
@@ -390,7 +390,7 @@ public class ImporterGenerator extends JavaGenerator{
                                return;\r
                    } else {\r
                        if (simpleType == null) {\r
-                               SchemaObject simpleTypeObj = this.base.simpleTypeName.get(primitiveType.getLocalPart());\r
+                               SchemaObject simpleTypeObj = this.base.getSimpleType(primitiveType);//this.base.simpleTypeName.get(primitiveType.getLocalPart());\r
                                if (simpleTypeObj != null)\r
                                        simpleType = simpleTypeObj.getSimpleType();\r
                        }       \r
@@ -458,7 +458,7 @@ public class ImporterGenerator extends JavaGenerator{
        public void handle(SchemaObject parent, AttributeGroup attribute) {\r
                if (parent != null) {\r
                        FileWriter fw = getWriter(parent);\r
-                       NamedAttributeGroup group = this.base.getAttributeGroup(attribute.getRef().getLocalPart());\r
+                       NamedAttributeGroup group = this.base.getAttributeGroup(attribute.getRef());\r
                        fw.writer.println(commentTag+"    AttributeGroup " + group.getName());\r
                        SchemaObject obj = new SchemaObject(parent,attribute);\r
                        for (Annotated annotated : group.getAttributeOrAttributeGroup()) {\r
@@ -470,6 +470,9 @@ public class ImporterGenerator extends JavaGenerator{
                                        handle(obj,(AttributeGroup)annotated);\r
                                }\r
                        }\r
+                       //dd\r
+                       if(true)\r
+                               System.out.println();\r
                        fw.writer.println(commentTag+"    End of AttributeGroup " + group.getName());\r
                }\r
                \r
@@ -593,7 +596,7 @@ public class ImporterGenerator extends JavaGenerator{
                LocalSimpleType simpleType = element.getSimpleType();\r
                \r
                if (complexType != null) {\r
-                       SchemaObject obj = this.base.complexTypes.get(complexType);\r
+                       SchemaObject obj = this.base.getComplexType(complexType);\r
                        this.base.handleElementComplexTypeAttributes(obj);\r
                } \r
                fw.writer.println("   }");\r
@@ -620,7 +623,7 @@ public class ImporterGenerator extends JavaGenerator{
                fw.writer.println("      super();");\r
                \r
                if (complexType != null) {\r
-                       SchemaObject obj = this.base.complexTypes.get(complexType);\r
+                       SchemaObject obj = this.base.getComplexType(complexType);\r
                        this.base.handleComplexTypeExtension(obj);\r
                } else if (simpleType != null) {\r
                        \r
index 126dcf45691cb3110cf5d66c3ae422479082a126..72b2956a7016073ee910d04d700bccf5a19892f1 100644 (file)
@@ -258,8 +258,8 @@ public abstract class JavaGenerator implements SchemaConversionComponent {
                        \r
                        String binding = this.base.getBindingFromPrimitiveType(refType);\r
                        if (binding == null) {\r
-                               SchemaObject refElement = this.base.elementName.get(refType.getLocalPart());\r
-                               SchemaObject refComplexType = this.base.complexTypeName.get(refType.getLocalPart());\r
+                               SchemaObject refElement = this.base.getElement(refType);\r
+                               SchemaObject refComplexType = this.base.getComplexType(refType);\r
        \r
                                // prefer element reference over complex type reference\r
                                String primaryClassName = null;\r
index f98a85f5673785e292347149b5865cde0454f392..2de5908f48374a85667f66ba1443f5465b56cd6e 100644 (file)
@@ -144,7 +144,7 @@ public class OntologyGenerator implements SchemaConversionComponent {
                                type = base.getL0TypeFromPrimitiveType(refType);\r
                        }\r
                        if (type == null) {\r
-                               SchemaObject obj = base.getWithName(parent, refType.getLocalPart());\r
+                               SchemaObject obj = base.getWithName(refType);\r
                                types.add(getName(obj,"has"));\r
                        } \r
                }\r
@@ -197,7 +197,7 @@ public class OntologyGenerator implements SchemaConversionComponent {
                        if (refType == RefType.Type) {\r
                                referenceType = element.getElement().getType();\r
                                //refName = element.getElement().getName()\r
-                               SchemaObject eObj = base.elements.get(element.getElement());\r
+                               SchemaObject eObj = base.getElement(element.getElement());//base.elements.get(element.getElement());\r
                                if (refName == null)\r
                                        refName = eObj.getName();\r
                        } else {\r
@@ -208,7 +208,7 @@ public class OntologyGenerator implements SchemaConversionComponent {
                        String type = base.getL0TypeFromPrimitiveType(referenceType);\r
                        SchemaObject obj = null;\r
                        if (type == null) {\r
-                               obj = base.getWithName(parent, referenceType.getLocalPart());\r
+                               obj = base.getWithName(referenceType);\r
                                \r
                                writer.println(getName(parent)+".has"+refName + " <R " +  getName(obj,"has"));\r
                                writer.println("   --> " + getName(obj));\r
@@ -524,11 +524,11 @@ public class OntologyGenerator implements SchemaConversionComponent {
                LocalSimpleType simpleType = element.getSimpleType();\r
                \r
                if (complexType != null) {\r
-                       SchemaObject complexTypeObj = this.base.complexTypes.get(complexType);\r
+                       SchemaObject complexTypeObj = this.base.getComplexType(complexType);\r
                        this.base.handleElementComplexTypeAttributes(complexTypeObj);\r
                        this.base.handleComplexTypeExtension(complexTypeObj);\r
                } else if (simpleType != null) {\r
-                       SchemaObject simpleTypeObj = this.base.simpleTypes.get(simpleType);\r
+                       SchemaObject simpleTypeObj = this.base.getSimpleType(simpleType);\r
                        this.base.handleElementSimpleTypeAttributes(simpleTypeObj);\r
                }\r
                \r
index 3e6c8818732a102cd5b56601e1847eaeff2963be..2bca88d64f5dfd666fee38f5d5cdf6a956fc4e84 100644 (file)
@@ -196,41 +196,147 @@ public final class SchemaConversionBase {
                }\r
        }\r
        \r
-       protected Map<String,SchemaObject> elementName = new HashMap<>();\r
-       protected Map<String,SchemaObject> complexTypeName = new HashMap<>();\r
-       protected Map<String,SchemaObject> simpleTypeName = new HashMap<>();\r
-       protected Map<String,SchemaObject> modelGroupName = new HashMap<>();\r
-       protected Map<Element,SchemaObject> elements = new HashMap<>();\r
-       protected Map<ComplexType,SchemaObject> complexTypes = new HashMap<>();\r
-       protected Map<SimpleType,SchemaObject> simpleTypes = new HashMap<>();\r
-       protected Map<NamedGroup,SchemaObject> modelGroups = new HashMap<>();\r
-       \r
-       \r
-       protected SchemaObject getWithName(SchemaObject referrer, String name) {\r
-               SchemaObject obj = elementName.get(name);\r
+       private Map<String,SchemaObject> elementName = new HashMap<>();\r
+       private Map<String,SchemaObject> complexTypeName = new HashMap<>();\r
+       private Map<String,SchemaObject> simpleTypeName = new HashMap<>();\r
+       private Map<String,SchemaObject> modelGroupName = new HashMap<>();\r
+       private Map<Element,SchemaObject> elements = new HashMap<>();\r
+       private Map<ComplexType,SchemaObject> complexTypes = new HashMap<>();\r
+       private Map<SimpleType,SchemaObject> simpleTypes = new HashMap<>();\r
+       private Map<NamedGroup,SchemaObject> modelGroups = new HashMap<>();\r
+       \r
+       private SchemaObject _getWithName(QName name) {\r
+               SchemaObject obj = elementName.get(name.getLocalPart());\r
                if (obj == null)\r
-                       obj = complexTypeName.get(name);\r
+                       obj = complexTypeName.get(name.getLocalPart());\r
                if (obj == null)\r
-                       obj = simpleTypeName.get(name);\r
-               if (obj == null) {\r
-                       throw new RuntimeException("Cannot locate referred type " + name + " when handling " + referrer.getName());\r
-               }\r
+                       obj = simpleTypeName.get(name.getLocalPart());\r
                return obj;\r
        }\r
        \r
-       protected SchemaObject getWithName(String name) {\r
-               SchemaObject obj = elementName.get(name);\r
-               if (obj == null)\r
-                       obj = complexTypeName.get(name);\r
-               if (obj == null)\r
-                       obj = simpleTypeName.get(name);\r
-               if (obj == null) {\r
-                       throw new RuntimeException("Cannot locate referred type " + name);\r
+       protected SchemaObject getWithName(QName name) {\r
+               SchemaObject obj = _getWithName(name);\r
+               if (obj != null)\r
+                       return obj;\r
+               if (name.getNamespaceURI() != null) {\r
+                       for (SchemaConverter sc : converter.getConverter(name.getNamespaceURI())) {\r
+                               if (sc.base != null) {\r
+                                       obj = sc.base._getWithName(name);\r
+                                       if (obj != null) {\r
+                                               return obj;\r
+                                       }\r
+                               }\r
+                       }               \r
                }\r
-               return obj;\r
+               return null;\r
+       }\r
+       \r
+       private NamedAttributeGroup _getAttributeGroup(QName name) {\r
+               for (OpenAttrs attrs : schema.getSimpleTypeOrComplexTypeOrGroup()) {\r
+                       if (attrs instanceof NamedAttributeGroup) {\r
+                               NamedAttributeGroup group = (NamedAttributeGroup)attrs;\r
+                               if (group.getName().equals(name.getLocalPart()))\r
+                                       return group;\r
+                       }\r
+               }\r
+               return null;\r
+       }\r
+\r
+       public NamedAttributeGroup getAttributeGroup(QName name) {\r
+               NamedAttributeGroup group = _getAttributeGroup(name);\r
+               if (group != null)\r
+                       return group;\r
+               if (name.getNamespaceURI() != null) {\r
+                       for (SchemaConverter sc : converter.getConverter(name.getNamespaceURI())) {\r
+                               if (sc.base != null) {\r
+                                       group = sc.base._getAttributeGroup(name);\r
+                                       if (group != null) {\r
+                                               return group;\r
+                                       }\r
+                               }\r
+                       }       \r
+               }\r
+               return null;\r
+       }\r
+       \r
+       private SchemaObject _getElement(QName name) {\r
+               return elementName.get(name.getLocalPart());\r
+       }\r
+       \r
+       protected SchemaObject getElement(QName name) {\r
+               SchemaObject obj = _getElement(name);\r
+               if (obj != null)\r
+                       return obj;\r
+               if (name.getNamespaceURI() != null) {\r
+                       for (SchemaConverter sc : converter.getConverter(name.getNamespaceURI())) {\r
+                               if (sc.base != null) {\r
+                                       obj = sc.base._getElement(name);\r
+                                       if (obj != null) {\r
+                                               return obj;\r
+                                       }\r
+                               }\r
+                       }               \r
+               }\r
+               return null;\r
+       }\r
+       \r
+       protected SchemaObject getElement(Element element) {\r
+               return elements.get(element);\r
+       }\r
+       \r
+       \r
+       private SchemaObject _getComplexType(QName name) {\r
+               return complexTypeName.get(name.getLocalPart());\r
+       }\r
+       \r
+       protected SchemaObject getComplexType(QName name) {\r
+               SchemaObject obj = _getComplexType(name);\r
+               if (obj != null)\r
+                       return obj;\r
+               if (name.getNamespaceURI() != null) {\r
+                       for (SchemaConverter sc : converter.getConverter(name.getNamespaceURI())) {\r
+                               if (sc.base != null) {\r
+                                       obj = sc.base._getComplexType(name);\r
+                                       if (obj != null) {\r
+                                               return obj;\r
+                                       }\r
+                               }\r
+                       }               \r
+               }\r
+               return null;\r
+       }\r
+       \r
+       protected SchemaObject getComplexType(ComplexType complexType) {\r
+               return complexTypes.get(complexType);\r
+       }\r
+       \r
+       private SchemaObject _getSimpleType(QName name) {\r
+               return simpleTypeName.get(name.getLocalPart());\r
+       }\r
+       \r
+       protected SchemaObject getSimpleType(QName name) {\r
+               SchemaObject obj = _getSimpleType(name);\r
+               if (obj != null)\r
+                       return obj;\r
+               if (name.getNamespaceURI() != null) {\r
+                       for (SchemaConverter sc : converter.getConverter(name.getNamespaceURI())) {\r
+                               if (sc.base != null) {\r
+                                       obj = sc.base._getSimpleType(name);\r
+                                       if (obj != null) {\r
+                                               return obj;\r
+                                       }\r
+                               }\r
+                       }               \r
+               }\r
+               return null;\r
+       }\r
+       \r
+       protected SchemaObject getSimpleType(SimpleType simpleType) {\r
+               return simpleTypes.get(simpleType);\r
        }\r
        \r
        protected SchemaObject getWithObj(SchemaObject referrer, OpenAttrs attrs) {\r
+               // FIXME : this method cannot handle references to other schemas.\r
                SchemaObject obj = null;\r
                if (attrs instanceof Element)\r
                        obj = elements.get(attrs);\r
@@ -492,13 +598,6 @@ public final class SchemaConversionBase {
                return null;\r
        }\r
        \r
-\r
-       \r
-       \r
-       \r
-       \r
-       \r
-       \r
        private void handleAttributes(SchemaObject complexType, List<Annotated> attributeOrAttributeGroup) {\r
                //name = getComplexTypePrefix()+complexType.getName()\r
                \r
@@ -763,6 +862,17 @@ public final class SchemaConversionBase {
                                        }\r
                                }\r
                        } else {\r
+                               if (choices.size() == 1 && sequences.size() == 0 && alls.size() == 0 && groups.size() == 0) {\r
+                                       // special case: handle lone choice inside sequence with maxOccurs > 1 \r
+                                       SchemaElement choice = choices.get(0);\r
+                                       // move multiplicity restrictions to choice\r
+                                       if (indicator.getRestriction().max == -1 || (choice.getRestriction().max > 0 && indicator.getRestriction().max > choice.getRestriction().max))\r
+                                               choice.getRestriction().max = indicator.getRestriction().max;\r
+                                       if (indicator.getRestriction().min == 0 || choice.getRestriction().min > indicator.getRestriction().min)\r
+                                               choice.getRestriction().min = indicator.getRestriction().min;\r
+                                       handle(parent, choice, elements);\r
+                                       return;\r
+                               }\r
                                if (sequences.size() > 0 || choices.size() > 0 || alls.size() > 0 || groups.size() > 0) {\r
                                        throw new RuntimeException("Cannot handle Sequence with inner ExplicitGroups");\r
                                }\r
@@ -915,17 +1025,6 @@ public final class SchemaConversionBase {
                return simpleTypeName.containsKey(ref);\r
        }\r
        \r
-       public NamedAttributeGroup getAttributeGroup(String name) {\r
-               for (OpenAttrs attrs : schema.getSimpleTypeOrComplexTypeOrGroup()) {\r
-                       if (attrs instanceof NamedAttributeGroup) {\r
-                               NamedAttributeGroup group = (NamedAttributeGroup)attrs;\r
-                               if (group.getName().equals(name))\r
-                                       return group;\r
-                       }\r
-               }\r
-               return null;\r
-       }\r
-       \r
        public IDProvider getIDProvider(Element element) {\r
                List<IDProvider> idProviders = new ArrayList<IDProvider>(2);\r
                for (JAXBElement<?> e : configuration.getConversionRule()) {\r
@@ -1279,7 +1378,7 @@ public final class SchemaConversionBase {
                                QName type = getElementBase(topLevelElement);\r
                                if (type != null) {\r
                                        if (!type.getNamespaceURI().equals(SCHEMA_NS)) {\r
-                                               SchemaObject obj = getWithName(topLevelObj, type.getLocalPart());\r
+                                               SchemaObject obj = getWithName(type);\r
                                                inheritance.baseClass = getName(obj);\r
                                                inheritance.type = InheritanceType.ComplexType;\r
                                        } else {\r
@@ -1295,7 +1394,7 @@ public final class SchemaConversionBase {
                                QName type = topLevelElement.getSubstitutionGroup();\r
                                if (type != null) {\r
                                        if (!type.getNamespaceURI().equals(SCHEMA_NS)) {\r
-                                               SchemaObject obj = getWithName(topLevelObj, type.getLocalPart());\r
+                                               SchemaObject obj = getWithName(type);\r
                                                inheritance.baseClass = getName(obj);\r
                                                inheritance.type = InheritanceType.ComplexType;\r
                                        } else {\r
@@ -1338,7 +1437,8 @@ public final class SchemaConversionBase {
         */\r
        public void getAtomicTypeInheritance(QName type, Inheritance inheritance) {\r
                if (!type.getNamespaceURI().equals(SCHEMA_NS)) {\r
-                       SchemaObject obj = getWithName(type.getLocalPart());\r
+                       SchemaObject obj = getWithName(type);\r
+                       System.out.println();\r
                        if (obj.getType() != ObjectType.SIMPLE_TYPE)\r
                                throw new RuntimeException("SimpleContent does not use SimpleType definition");\r
                        SimpleType simpleType = obj.getSimpleType();\r
index c7167545d31b96b58077f0e097c5a8d3d285443c..ed11c14cd7ad762f9cb4ffc81b49db92ad1387ef 100644 (file)
@@ -16,6 +16,7 @@ import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;\r
 import javax.xml.bind.Unmarshaller;\r
 \r
+import org.simantics.utils.datastructures.MapList;\r
 import org.simantics.xml.sax.configuration.Configuration;\r
 import org.w3._2001.xmlschema.Annotation;\r
 import org.w3._2001.xmlschema.Import;\r
@@ -49,8 +50,11 @@ public class SchemaConverter {
        \r
        private List<SchemaConverter> parent = new ArrayList<>();\r
        private List<SchemaConverter> subConverters = new ArrayList<>();\r
-       private Map<String,SchemaConverter> nameMap;\r
+       private Map<String,SchemaConverter> fileMap;\r
+       private MapList<String,SchemaConverter> schemaNSMap;\r
+       private MapList<String,SchemaConverter> shortNameMap;\r
        \r
+       String schemaNs;\r
        String ontologyUri;\r
        String className;\r
        String name;\r
@@ -88,9 +92,15 @@ public class SchemaConverter {
                        this.parent.add(parent);\r
                        parent.subConverters.add(this);\r
                } else {\r
-                       nameMap = new HashMap<>();\r
+                       fileMap = new HashMap<>();\r
+                       schemaNSMap = new MapList<>();\r
+                       shortNameMap = new MapList<>();\r
                }\r
-               getRoot().nameMap.put(schemaFile.getAbsolutePath(), this);\r
+               getRoot().fileMap.put(schemaFile.getAbsolutePath(), this);\r
+       }\r
+       \r
+       public List<SchemaConverter> getConverter(String schemaNS) {\r
+               return getRoot().schemaNSMap.getValues(schemaNS);\r
        }\r
        \r
        public void setFileImport(ManualSchemaFileImport fileImport) {\r
@@ -120,7 +130,7 @@ public class SchemaConverter {
                        if (!schemaFile.exists())\r
                                throw new FileNotFoundException(schemaFile.getAbsolutePath());\r
                }\r
-               SchemaConverter subConverter = getRoot().nameMap.get((schemaFile.getAbsolutePath()));\r
+               SchemaConverter subConverter = getRoot().fileMap.get((schemaFile.getAbsolutePath()));\r
                if (subConverter == null) {\r
                        subConverter = new SchemaConverter(this,schemaFile, conversionFile, outputPlugin);\r
                        subConverter.createPGraph = this.createPGraph;\r
@@ -147,6 +157,38 @@ public class SchemaConverter {
        \r
        boolean init = false;\r
        \r
+       protected void assignShortName() {\r
+               shortName = name.substring(0, 3).toUpperCase();\r
+               SchemaConverter root = getRoot();\r
+               if (!root.shortNameMap.containsKey(shortName)) {\r
+                       root.shortNameMap.add(shortName, this);\r
+                       return;\r
+               } else {\r
+                       SchemaConverter sc = root.shortNameMap.getValues(shortName).get(0);\r
+                       if (sc.schemaNs.equals(schemaNs)) {\r
+                               root.shortNameMap.add(shortName, this);\r
+                               return;\r
+                       }\r
+               }\r
+               int i = 1;\r
+               while (true) {\r
+                       String n = shortName+i;\r
+                       if (!root.shortNameMap.containsKey(n)) {\r
+                               shortName = n;\r
+                               root.shortNameMap.add(shortName, this);\r
+                               return;\r
+                       } else {\r
+                               SchemaConverter sc = root.shortNameMap.getValues(n).get(0);\r
+                               if (sc.schemaNs.equals(schemaNs)) {\r
+                                       shortName = n;\r
+                                       root.shortNameMap.add(shortName, this);\r
+                                       return;\r
+                               }\r
+                       }\r
+                       i++;\r
+               }\r
+       }\r
+       \r
        protected void init() throws IOException, JAXBException {\r
                if (init)\r
                        return;\r
@@ -172,8 +214,8 @@ public class SchemaConverter {
                header[2] = "File " + schemaFile.getAbsolutePath();\r
                header[3] = "Date " + new Date().toString();\r
                \r
-               \r
-               ontologyUri = schema.getTargetNamespace();\r
+               schemaNs = schema.getTargetNamespace();\r
+               ontologyUri = schemaNs;\r
                if (ontologyUri == null) {\r
                        ontologyUri = getSchemaFile().getName();\r
                        \r
@@ -197,7 +239,9 @@ public class SchemaConverter {
 \r
                \r
                className = getPluginName() + "." + name;\r
-               shortName = name.substring(0, 3).toUpperCase();\r
+               assignShortName();\r
+               if (schemaNs != null)\r
+                       getRoot().schemaNSMap.add(schemaNs, this);\r
                \r
                \r
                for (OpenAttrs attrs : schema.getIncludeOrImportOrRedefine()) {\r