The TreeML file format is a for the
2003 InfoVis Conference Contest to represent data trees based on a nested Branch/Leaf model. Unlike GraphML, this is a relatively unofficial file format.
TreeML Specification
TreeML documents begin with an opening tag followed by a list of declarations defining attribute names and types. Supported data types are :
- Integer
- Long
- Float
- Real
- String
- Date
<tree>
<declarations>
<attributeDecl name="name" type="String"/>
<attributeDecl name="number" type="Real"/>
</declarations>
Tree structure is constructed through the use of and tags. Branches are nested within each other, and contain leaves. Leaves cannot be nested, and are representative of individual data nodes, a representation of the tree structure created is below :
<branch>
<attribute name="name" value="Root Branch">
<branch>
<attribute name="name" value="Sub Branch 1">
<leaf>
<attribute name="name" value="Leaf 1">
<attribute name="number" value="1">
</leaf>
<leaf>
<attribute name="name" value="Leaf 2">
<attribute name="number" value="2">
</leaf>
</branch>
<branch>
<attribute name="name" value="Sub Branch 2">
<leaf>
<attribute name="name" value="Leaf 3">
<attribute name="number" value="3">
</leaf>
<leaf>
<attribute name="name" value="Leaf 4">
<attribute name="number" value="4">
</leaf>
</branch>
</branch>
Loading the TreeML File
TreeML Files are loaded in the same manner as a GraphML File. Build a TreeML reader and use it to load the TreeML file into a graph. This also throws a DataIOException, so it has to be wrapped in a try/catch loop.
Graph myTree = null;
try {
myTree = new TreeMLReader().readGraph("/TreeFile.xml");
} catch(Exception e){
e.printStackTrace();
System.out.println("Died trying to open TreeML File");
System.exit(1);
}