Graph XML to Visual Representation

2020-02-15 08:32发布

问题:

I have an XML document and want a visual representation (eg. an SVG graphic). Eg.

<set>
   <A>
      <B>bla</B>
      foo
   </A>
   <A>blub</A>
</set>

Should render to something like:

or something similar like a dendrogram. I don't have any preferences regarding the technology. The easiest way will do.

回答1:

As @Javier suggested in the comments, checkout Graphviz. Specifically:

  1. Write XSLT to map from your XML to DotML, an XML representation of the DOT graph description language. You can validate DotML against the DotML schema.
  2. Run generate-svg-graphics.bash, which uses generate-svg-graphics.xsl, to convert from DotML to SVG.

See also: Michael Kay's DotML ant build.