]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Improved processing of multiple XML data files. 60/2160/2
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 11 Sep 2018 10:47:34 +0000 (13:47 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 11 Sep 2018 11:00:07 +0000 (11:00 +0000)
gitlab #3

Change-Id: Ice8db7eb7df11880f81850d7f1a714e8738ef945

org.simantics.xml.sax.base/src/org/simantics/xml/sax/base/ParserElement.java
org.simantics.xml.sax/src/org/simantics/xml/data/XmlDataConverter.java

index ca4a91a39cab329739ecbc32b039767de93e14a6..8d169bb0ca33852bf10e903f54c4311356b7bd9c 100644 (file)
@@ -95,6 +95,8 @@ public class ParserElement implements Serializable {
                        if (ns.length == 2) {
                                if ("xmlns".equals(ns[0]))
                                        continue;
+                               if ("xml".equals(ns[0]))
+                                       continue;
                                String namespace = getNS(ns[0]);
                                if (namespace != null) {
                                        if (newAttrs.put(ns[1], new Attribute(ns[1], a.qName, namespace, a.value)) != null)
index dfd1d6e059d2b2ad3d63ee02e5f8a064183f505e..ce38d5ed28a0440e622c2a70c00a992ff2551e70 100644 (file)
@@ -174,6 +174,8 @@ public class XmlDataConverter {
                                } else {
                                        schemaElement = elementMap.get(s).get(elementName);
                                }
+                               if (elementName.equals("CanvasLayers.TracingLayer") || elementName.equals("Layer"))
+                                       System.out.println();
                                Element parentElement = elementStack.peek();
                                
                                boolean newElement = false;
@@ -190,7 +192,7 @@ public class XmlDataConverter {
                                                
                                }
                                if (schemaElement == null) {
-                                       LocalElement localElement = null;
+                                       
                                        //QName type = null;
                                        if (elementStack.isEmpty()) {
                                                schemaElement = new TopLevelElement();
@@ -207,33 +209,31 @@ public class XmlDataConverter {
                                                        schemaElement = new TopLevelElement();
                                                        s.getSimpleTypeOrComplexTypeOrGroup().add(schemaElement);
                                                        //type = new QName(SchemaConversionBase.SCHEMA_NS,"element");
-                                                       localElement = new LocalElement();
-                                                       localElement.setRef(new QName(parseElement.getName().getNamespaceURI(), elementName));
+                                                       
                                                                
 //                                             }
                                        }
                                        schemaElement.setName(elementName);
-                                       elementNsMap.put(schemaElement, currentNS);
-//                                     if (sameNameSpace) {
-//                                             schemaElement.setType(new QName(parseElement.getName().getNamespaceURI(),elementName));
-//                                     } else {
-//                                             schemaElement.setType(new QName(parseElement.getName().getNamespaceURI(), elementName));
-//                                     }
-                                       if (!elementStack.isEmpty()) {
-                                               ComplexType complexType = parentElement.getComplexType(); 
-                                               ExplicitGroup choice = complexType.getChoice();
-                                               if (choice == null) {
-                                                       choice = new ExplicitGroup();
-                                                       complexType.setChoice(choice);
-                                                       choice.setMaxOccurs("unbounded");
-                                               }
-                                               addElement(choice, new QName(SchemaConversionBase.SCHEMA_NS,"element"), localElement);
-                                       }
+                                       elementNsMap.put(schemaElement, currentNS);                             
                                        
                                        
                                        elementMap.get(s).put(elementName, schemaElement);
                                        newElement = true;
                                }
+                               if (parentElement != null) {
+                                       ComplexType complexType = parentElement.getComplexType(); 
+                                       ExplicitGroup choice = complexType.getChoice();
+                                       if (choice == null) {
+                                               choice = new ExplicitGroup();
+                                               complexType.setChoice(choice);
+                                               choice.setMaxOccurs("unbounded");
+                                       }
+                                       LocalElement localElement = new LocalElement();
+                                       localElement.setRef(new QName(parseElement.getName().getNamespaceURI(), elementName));
+                                       
+                                       addElement(choice, new QName(SchemaConversionBase.SCHEMA_NS,"element"), localElement);
+                               }
+                               
                                elementStack.push(schemaElement);
                                
                                Iterator<Attribute> attributeIterator = parseElement.getAttributes();