]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.xml.sax/src/org/simantics/xml/data/XmlDataConverter.java
Attribute namespace + multi-schema data export
[simantics/interop.git] / org.simantics.xml.sax / src / org / simantics / xml / data / XmlDataConverter.java
index ce38d5ed28a0440e622c2a70c00a992ff2551e70..7a2a5c54bf6d19ee805eb471374038d415b59208 100644 (file)
@@ -174,15 +174,12 @@ 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;
                                boolean sameNameSpace = true;
                                
                                if (parentElement != null) {
-                                       //QName parentType = parentElement.getType();
                                        String parentNs = elementNsMap.get(parentElement);
                                        sameNameSpace =currentNS.equals(parentNs);
                                        if (!sameNameSpace) {
@@ -192,26 +189,12 @@ public class XmlDataConverter {
                                                
                                }
                                if (schemaElement == null) {
-                                       
-                                       //QName type = null;
                                        if (elementStack.isEmpty()) {
                                                schemaElement = new TopLevelElement();
                                                s.getSimpleTypeOrComplexTypeOrGroup().add(schemaElement);
                                        } else {
-                                               
-                                               
-//                                             if (sameNameSpace) {
-//                                                     localElement = new LocalElement();
-//                                                     schemaElement = localElement;
-//                                                     //type = new QName(elementName);
-//                                                     
-//                                             } else {
-                                                       schemaElement = new TopLevelElement();
-                                                       s.getSimpleTypeOrComplexTypeOrGroup().add(schemaElement);
-                                                       //type = new QName(SchemaConversionBase.SCHEMA_NS,"element");
-                                                       
-                                                               
-//                                             }
+                                               schemaElement = new TopLevelElement();
+                                               s.getSimpleTypeOrComplexTypeOrGroup().add(schemaElement);
                                        }
                                        schemaElement.setName(elementName);
                                        elementNsMap.put(schemaElement, currentNS);                             
@@ -250,7 +233,7 @@ public class XmlDataConverter {
                                                Attribute attribute = attributeIterator.next();
                                                if ("http://www.w3.org/XML/1998/namespace".equals(attribute.getName().getNamespaceURI()))
                                                        continue;
-                                               addAttribute(attribute, complexType, parseElement.getNamespaceURI(attribute.getName().getPrefix()));
+                                               addAttribute(attribute, complexType, currentNS);
                                        }
                                        
                                } else {
@@ -273,7 +256,7 @@ public class XmlDataConverter {
                                                        continue;
                                                org.w3._2001.xmlschema.Attribute schemaAttribute = currentAttributes.get(attribute.getName().getLocalPart());
                                                if (schemaAttribute == null) {
-                                                       addAttribute(attribute, complexType, parseElement.getNamespaceURI(attribute.getName().getPrefix()));
+                                                       addAttribute(attribute, complexType, currentNS);
                                                } else {
                                                        QName newType = getType(attribute.getValue());
                                                        updateAttributeType(schemaAttribute, newType);
@@ -287,9 +270,9 @@ public class XmlDataConverter {
 //                             System.out.println("End " + element.getName());
                                elementStack.pop();
                        } else if (event.isAttribute()) {
-                               System.out.println(event);
+                       
                        } else if (event.isStartDocument()) {
-                               System.out.println(event);
+
                        } else if (event.isEndDocument()) {
                                
                        } else if (event.isEntityReference()) {
@@ -299,7 +282,7 @@ public class XmlDataConverter {
 //                             if (!characters.isWhiteSpace())
 //                                     System.out.println(characters.getData());
                    } else if (event.isNamespace()) {
-                       System.out.println(event);
+                   
                    }
                }
        }
@@ -352,8 +335,6 @@ public class XmlDataConverter {
        }
        
        private void addAttribute(Attribute attribute, ComplexType complexType, String currentNS) {
-               if (attribute.getName().getLocalPart().equals("Panel.ZIndex"))
-                       System.out.println();
                if (attribute.getName().getNamespaceURI().length() == 0 || attribute.getName().getNamespaceURI().equals(currentNS)) {
                        org.w3._2001.xmlschema.Attribute schemaAttribute = new org.w3._2001.xmlschema.Attribute();
                        schemaAttribute.setName(attribute.getName().getLocalPart());
@@ -406,8 +387,6 @@ public class XmlDataConverter {
                                }
                        }
                }
-               if ("Panel.ZIndex".equals(schemaAttribute.getName()))
-                       System.out.println();
                complexType.getAttributeOrAttributeGroup().add(schemaAttribute);
        }