]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.xml.sax/src/org/simantics/xml/sax/ImporterGenerator.java
XML data based schema and ontology generation
[simantics/interop.git] / org.simantics.xml.sax / src / org / simantics / xml / sax / ImporterGenerator.java
index 3e02434e797481d721e9e1f5ac0a0290f5a8e322..58f5748e05e1d4bef1f9af01611c02bcc6dc3128 100644 (file)
@@ -39,10 +39,9 @@ public class ImporterGenerator extends JavaGenerator{
        
        public void createParser() throws IOException {
                
-               String parserPackagePostfix = "_elem";
                String importerClassPostfix = "Importer";
                String parserClassPostfix = "Parser";
-               elementPackageName = name+parserPackagePostfix;
+               
                
                importParserDir= new File(converter.getParserDir().getAbsolutePath()+"/"+elementPackageName);
                if (!importParserDir.exists())
@@ -93,6 +92,11 @@ public class ImporterGenerator extends JavaGenerator{
                mainWriter.close();
        }
        
+       @Override
+       protected String getPackagePostFix() {
+               return "_elem";
+       }
+       
        @Override
        public void handleSimpleType(SchemaObject parent, SchemaObject simpleTypeObj) {
        }
@@ -231,6 +235,8 @@ public class ImporterGenerator extends JavaGenerator{
        
        @Override
        public void createReferenceIndicator(SchemaObject parent, RefType referenceType, String refName, String objectName, String primaryClassName, String secondaryClassName, boolean useElementList, boolean useOriginalList) {
+               if (refName == null)
+                       System.out.println();
                FileWriter fw = getWriter(parent);
                if (referenceType == RefType.Type) {
                // create internal class for handling the element and child attachment
@@ -311,6 +317,8 @@ public class ImporterGenerator extends JavaGenerator{
        
        @Override
        protected void createElementIndicator(SchemaObject parent, boolean useElementList, String refName, String className, boolean useOriginalList) {
+               if (refName == null)
+                       System.out.println();
                FileWriter fw = getWriter(parent);
                //if (!reference)
                fw.writer.println("        addParser(\""+ refName +"\", "+className+".class);");
@@ -370,22 +378,18 @@ public class ImporterGenerator extends JavaGenerator{
        public void handle(SchemaObject parent, Attribute attribute) {
                if (parent == null)
                        return;
-               String name = attribute.getName();
+               String attrName = attribute.getName();
                QName primitiveType = attribute.getType();
                SimpleType simpleType = attribute.getSimpleType();
                QName ref = attribute.getRef();
                
                String relationName;
-               String attrName;
-               if (name != null) {
-                       attrName = name;
-                       relationName = ontShort+"has"+name;
-                       if (parent != null)
-                               relationName = ontShort+getName(parent)+"_has"+name;
+               if (attrName != null) {
+                       relationName = ontShort+getName(parent)+"_has"+base.getName(attribute);
                }
                else if (ref != null && parent != null) {
                        attrName = ref.getLocalPart();
-                       relationName = ontShort+getName(parent)+"_has"+ref.getLocalPart();
+                       relationName = ontShort+getName(parent)+"_has"+base.getName(ref);
                        
                        Attribute referred = this.base.getRefAttribute(ref);
                        if (referred != null) {
@@ -485,7 +489,7 @@ public class ImporterGenerator extends JavaGenerator{
                        FileWriter fw = getWriter(parent);
                        NamedAttributeGroup group = this.base.getAttributeGroup(attribute.getRef());
                        fw.writer.println(commentTag+"    AttributeGroup " + group.getName());
-                       SchemaObject obj = new SchemaObject(parent,attribute);
+                       SchemaObject obj = new SchemaObject(base,parent,attribute);
                        for (Annotated annotated : group.getAttributeOrAttributeGroup()) {
                                if (annotated instanceof Attribute) {
                                        //handle("AttributeGroups_"+group.getName(),(Attribute)annotated);