如何可视化一组互连的 XML 对象?
我有一些 XML 文档,经过非常简化,可以描述为:
<someobject id="mykey">
<relatedobject id="hiskey"/>
<relatedobject id="herkey"/>
</someobject>
<someobject ...
有什么简单的方法可以生成这样的图表,显示对象很好地放置在 2D 空间中,并且对象之间有线条?
我对 XSLT 和 Xpath 非常满意,但更喜欢不需要从头开始编写程序的解决方案。对 Saxon 进行一些命令行调用,然后生成图形就可以了。完全使用在线托管工具可以完成的任何事情都会获得奖励积分。现场(例如javascript)、交互式图表的额外奖励积分。
I have some XML documents which, grossly simplified, can be described as:
<someobject id="mykey">
<relatedobject id="hiskey"/>
<relatedobject id="herkey"/>
</someobject>
<someobject ...
What would be a simple way to produce a diagram of this, showing the objects placed nicely in 2D space, with lines between them?
I'm very comfortable with XSLT and Xpath, but would prefer a solution that doesn't require writing a program from scratch. Making a few command line calls to Saxon then a graph generating prog would be ok. Bonus points for anything that can be done totally using online hosted tools. Extra bonus points for a live (eg javascript), interactive diagram.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个可以直接粘贴到 shell 的快速解决方案,使用 GraphViz 作为 菲利普建议。这利用 xmlstarlet 来避免从头开始编写 XSLT 样式表。
示例输出:
编辑添加: 对于额外的奖励点,交互式 SVG仅使用在线工具的图表 此处。这利用了Dracula Graph Library和W3C XSLT 服务。这需要创建一个 XSLT 样式表(直接改编自 Dracula 图形库的在线示例)。用于转换的输入文档可以在此处找到。
Here's a quick solution that can can be directly pasted to a shell, using GraphViz as suggested by Philipp. This makes use of xmlstarlet to avoid having to write an XSLT stylesheet from scratch.
Sample output:
Edited to add: And for the extra bonus points, an interactive SVG diagram using only online tools here. This makes use of Dracula Graph Library and the W3C XSLT Service. This required creating an XSLT stylesheet (directly adapted from the online examples for Dracula Graph Library). The input document used for the transformation can be found here.
我建议使用 GraphViz:您使用 XSLT 创建一个文本文件,它描述了您想要的图表。请参阅此示例以获取快速概述。
我对它不太熟悉了,但我认为
应该完成这项工作。
I'd suggest to use GraphViz: You create a text file using XSLT which describes the graph you would like. See this example for a quick overview.
I'm not too familiar with it anymore, but I think
should do the job.
这不是一个简单的问题。我很早以前写了一个程序来对XML文档进行聚类,但是显示的是网格而不是图形。不过,如果您要实现某些功能,您可能会对代码感兴趣。此外,您可以为文档添加关键字,关键字以及链接将用于对文档进行聚类,并且它们还将用于命名生成的聚类。当有大量文档时,网格显示可能比图表更好。
http://media4.obspm.fr/outils/clustering/doc_en.html
This is not a simple problem. I wrote a program a long time ago to cluster XML documents, but the display is a grid instead of a graph. Still, you might be interested in the code if you're going to implement something. Additionally, you can attribute keywords to your documents, and the keywords will be used as well as the links to cluster the documents, and they will also be used to name the resulting clusters. The grid display is probably better than a graph when there are lots of documents.
http://media4.obspm.fr/outils/clustering/doc_en.html