Hitachi Vantara Pentaho Community Forums
Results 1 to 1 of 1

Thread: Table to GraphML (Recursive XML)

  1. #1
    Join Date
    Jun 2013
    Posts
    5

    Default Table to GraphML (Recursive XML)

    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:
    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>
    In yED:
    Name:  yED.PNG
Views: 65
Size:  1.5 KB


    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>";    
    }
    Would anyone be able to point in the right direction?
    Last edited by DuckieHo; 02-02-2017 at 06:42 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.