]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Export XML Namespaces
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 30 Jan 2017 11:04:51 +0000 (11:04 +0000)
committerMarko Luukkainen <marko.luukkainen@vtt.fi>
Thu, 2 Feb 2017 12:01:36 +0000 (14:01 +0200)
refs #6985

git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@33441 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.xml.sax.base/src/org/simantics/xml/sax/base/XMLWriter.java

index ac2d3682704f1962e8815744dd9ef6917ee2021a..ce5cb90068aa16cedfa7483ae04d00dbeb0c4780 100644 (file)
@@ -163,8 +163,6 @@ public class XMLWriter {
                                                        c = childWriterClass.getConstructor();\r
                                                        childWriter = c.newInstance();\r
                                                }\r
-                                               //childWriter = childWriterClass.newInstance();\r
-                                               \r
                                                namedWriters.put(childWriterClass, childWriter);\r
                                        } catch (IllegalAccessException|InstantiationException|NoSuchMethodException|SecurityException|InvocationTargetException e) {\r
                                                String err = "Error processing " + childWriterClass.getName() + " : element writers must have accessible constructor with ReadGraph parameter";\r
@@ -177,6 +175,7 @@ public class XMLWriter {
                        childWriter = writers.get(type);\r
                }\r
                if (childWriter == null) {\r
+                       // try child ontology/schema\r
                        Resource type = graph.getSingleType(child.instance);\r
                        Resource ontology = getOntology(type);\r
                        if (ontology != null) {\r
@@ -184,10 +183,12 @@ public class XMLWriter {
                                if (xmlWriter != null) {\r
                                        childWriter = xmlWriter.writers.get(type);\r
                                        // wrap the child writer with namespace writer\r
-                                       if (childWriter instanceof XMLElementNamedChildWriter) {\r
-                                               childWriter = new XMLNSNamedChildWriter((XMLElementNamedChildWriter)childWriter, xmlWriter.schemaURI);\r
-                                       } else {\r
-                                               childWriter = new XMLNSElementWriter(childWriter, xmlWriter.schemaURI);\r
+                                       if (childWriter != null) {\r
+                                               if (childWriter instanceof XMLElementNamedChildWriter) {\r
+                                                       childWriter = new XMLNSNamedChildWriter((XMLElementNamedChildWriter)childWriter, xmlWriter.schemaURI);\r
+                                               } else {\r
+                                                       childWriter = new XMLNSElementWriter(childWriter, xmlWriter.schemaURI);\r
+                                               }\r
                                        }\r
                                }\r
                        }\r