Commit bf8765c7 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when exporting whole node attributes were skipped

parent 6d78f8e1
Pipeline #28204 passed with stage
in 14 minutes and 56 seconds
......@@ -22,6 +22,8 @@ minerva (15.0.0~beta.5) unstable; urgency=medium
notes (#1287)
* Bug fix: import from GPML introduces space between inhibition and process
(#1270)
* Bug fix: map cantaining kinetic equations exported to CellDesigner was not
a valid SBML file (#1271)
-- Piotr Gawron <piotr.gawron@uni.lu> Tue, 2 Jun 2020 16:00:00 +0200
......
......@@ -266,17 +266,18 @@ final public class XmlParser {
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty(OutputKeys.METHOD, "xml");
NodeList list = node.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node element = list.item(i);
t.transform(new DOMSource(element), new StreamResult(sw));
if (includeHeadNode) {
t.transform(new DOMSource(node), new StreamResult(sw));
} else {
NodeList list = node.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node element = list.item(i);
t.transform(new DOMSource(element), new StreamResult(sw));
}
}
} catch (TransformerException te) {
logger.debug("nodeToString Transformer Exception");
}
if (includeHeadNode) {
return "<" + node.getNodeName() + ">" + sw.toString() + "</" + node.getNodeName() + ">";
}
return sw.toString();
}
......
......@@ -99,6 +99,14 @@ public class XmlParserTest extends CommonTestFunctions {
assertTrue(str.contains(xml));
}
@Test
public void testNodeToStringWithHeaderAndAttrib() throws Exception {
String xml = "<test_node x=\"y\">test_x</test_node>";
Node validDoc = XmlParser.getXmlDocumentFromString(xml).getDocumentElement();
String str = XmlParser.nodeToString(validDoc, true);
assertTrue(str.contains(xml));
}
@Test
public void testConcurrencyParse() throws Exception {
StringBuilder builder = new StringBuilder("<doc>");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment