我有一个 RDF 文件,我想从中生成一个 .dot 文件。我想创建一些规则来设计节点和这些节点之间的链接的样式(例如表示婚姻关系的特定类型的箭头)。
以下是此类转换“规则”的示例:
<person rdf:about="http://www.something.com/EGAnne"
<j: DateBirth>1981</j: DateBirth>
<j:Profession>Comptable</j:Profession>
<j:Gender>Female</j:Gender>
</j:person>
我想将这些行转换为以下结果:
a [label = "Anne \ n \ nD.Birth: 1981 \ nProfession: Accounting \ n", shape = circle, fillcolor = "pink" style = "filled", fontsize = "9", fontname = " Arial, bold "];
然后,为了表示类 person 的两个实例之间的婚姻,箭头的类型将为“ odot”和颜色“goldenrod”:
a -> j [arrowhead = "odot" arrowtail = "odot", dir = both, color = "goldenrod"]
如何按照上述规则从 RDF 文件自动生成 .dot 文件?
I have an RDF file, from which I would like to generate a .dot file. I'd like to create a number of rules to style the nodes and the links between these nodes (such as a specific kind of arrow to represent a marriage relationship).
Here is an example of such a conversion "rule":
<person rdf:about="http://www.something.com/EGAnne"
<j: DateBirth>1981</j: DateBirth>
<j:Profession>Comptable</j:Profession>
<j:Gender>Female</j:Gender>
</j:person>
I want to convert these lines to this result:
a [label = "Anne \ n \ nD.Birth: 1981 \ nProfession: Accounting \ n", shape = circle, fillcolor = "pink" style = "filled", fontsize = "9", fontname = " Arial, bold "];
Then, to represent the marriage between two instances of the class person, the type of arrow will be "odot" and color "goldenrod":
a -> j [arrowhead = "odot" arrowtail = "odot", dir = both, color = "goldenrod"]
How can I automatically generate the .dot file from RDF file, following rules like the one above?
发布评论
评论(4)
这看起来对你有用: RDF-到点。
This looks like it could work for you: RDF-to-Dot.
xslt 是我从 xml 创建 graphviz 文件的首选方法。
对你来说,关键部分可能是这样的......
xslt is my preferred way to create graphviz files from xml.
For you, the key part might look like this...
这似乎足以完成任务: https://metacpan.org/pod/rdfdot
This seems to be plenty up for the task: https://metacpan.org/pod/rdfdot
这个问题很老了(当时人们习惯把粉红色与女性联系起来:)但让我通过推广我的宠物来回答项目,因为它完全提供了所请求的定制类型。
以下规则(另存为 .n3 并用作 playground 中的自定义规则)涵盖了该示例:
应用于 RDF 数据(用海龟表示,因为现在 XML 较少使用):
生成请求的图表:
the question is old (these were the days when people used to associate the color pink with the female gender :) but let me answer by promoting my pet project because it provides exactly the kind of customization requested.
The following rules (save as .n3 and use as custom rules in the playground) cover the example:
Applied to the RDF data (expressed in turtle because XML is less used these days):
produce the requested diagram: