I am attempting to convert a table into GraphML and view it in yED. This is an XML-based graph format.
Since the depth/height of the stack can vary, I need a recursive solution. I am not sure the standard XML Add/Join will work due to this requirement.
Here is a sample input:
Here is the expected output:
In yED:
yED.PNG
Non-working recursive solution:
Would anyone be able to point in the right direction?
Since the depth/height of the stack can vary, I need a recursive solution. I am not sure the standard XML Add/Join will work due to this requirement.
Here is a sample input:
Node | Type | Height | Parent |
g1 | group | 2 | NULL |
g2 | group | 1 | g1 |
n1 | node | 0 | n1 |
Here is the expected output:
Code:
<node id="g1">
<graph>
<node id="g1::g2">
<graph>
<node id="g2:n1">
</node>
</graph>
</node>
</graph>
</node>
yED.PNG
Non-working recursive solution:
Code:
public String AutosysToGraphML(Object[] row) throws KettleException {
String nodeID = row.node;
if (!row.parent.isEmpty()) {
nodeID = row.parent + "::" + row.node;
}
AutosysToGraphML = AutosysToGraphML + "<node id=\"" + nodeID + "\">";
if (row.isGroup) {
AutosysToGraphML = AutosysToGraphML + "<graph>";
}
if (row.height) {
return AutosysToGraphML;
} else {
row.next;
AutosysToGraphML(row);
}
if (row.isGroup) {
AutosysToGraphML = AutosysToGraphML + "</graph>";
}
AutosysToGraphML = AutosysToGraphML + "</node>";
}