From: Marko Luukkainen Date: Tue, 11 Sep 2018 10:47:34 +0000 (+0300) Subject: Improved processing of multiple XML data files. X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F60%2F2160%2F2;p=simantics%2Finterop.git Improved processing of multiple XML data files. gitlab #3 Change-Id: Ice8db7eb7df11880f81850d7f1a714e8738ef945 --- diff --git a/org.simantics.xml.sax.base/src/org/simantics/xml/sax/base/ParserElement.java b/org.simantics.xml.sax.base/src/org/simantics/xml/sax/base/ParserElement.java index ca4a91a..8d169bb 100644 --- a/org.simantics.xml.sax.base/src/org/simantics/xml/sax/base/ParserElement.java +++ b/org.simantics.xml.sax.base/src/org/simantics/xml/sax/base/ParserElement.java @@ -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) diff --git a/org.simantics.xml.sax/src/org/simantics/xml/data/XmlDataConverter.java b/org.simantics.xml.sax/src/org/simantics/xml/data/XmlDataConverter.java index dfd1d6e..ce38d5e 100644 --- a/org.simantics.xml.sax/src/org/simantics/xml/data/XmlDataConverter.java +++ b/org.simantics.xml.sax/src/org/simantics/xml/data/XmlDataConverter.java @@ -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 attributeIterator = parseElement.getAttributes();