Back to menu command

Draw a hierarchy from an XML file

This function draws a hierarchical graph from an XML file. One example of the generated image is shown as follows, which is the hierarchy of body joints.

The xml file that is used to generate this image is here.

Don't be intimidated by this. Actually it is quite straightforward even if you are not familiar with XML. Let's look at the definition of the xml file, which itself is a DTD file.

There are three attributes for the root of the hierarchy.

  • The charset. The default value is "utf-8" for English. You can use other character set. For example, use "GB2312" for Chinese. (Change the encoding attribute of the XML file as well)
  • The orientation of the graph. Use either "hori" (horizontal) or "vert" (vertical). The default value is "hori". The above example uses horizontal orientation, which means sibling nodes of the graph are aligned horizontally. The vertical version of this example is here.
  • The flag (bindex) of whether draw node index or not. The default value is "no". If it is yes, the image of the above example will change as follows. The order is based on a Depth-First-Search of the hierarchy.

The attributes for each child node are.
  • Name
  • Shape which can be a rectangle, rounded-rectangle, diamond and ellipse. The default is rectangle
  • Text color
  • Background color
  • Line width of the text box
  • The flag (boundingbox) of whether draw bounding box or not and the color of the bounding box (boundingboxcolor). Take the above example. If we change to
    ,
    which means we want to draw a blue bounding box around the node "rhipjoint" and its descendant nodes, the generated image will change to

  • The ratio of margin (horizontal and vertical) between text and the text box
  • The horizontal and vertical space between two adjacent sibling nodes.

VIPBase © 2006 Fengjun Lv
Last update: 08/01/2006 (check html)