Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml graphml或dotml如何_Xml_Perl_Graph_Graphml - Fatal编程技术网

Xml graphml或dotml如何

Xml graphml或dotml如何,xml,perl,graph,graphml,Xml,Perl,Graph,Graphml,对于一个任务,我们被告知,对于附加功能,可以使用GraphViz输出一个图。这就是我们得到的所有信息 赋值是perl输出XML。我很确定我可以输出代码,我只需要知道如何从那里处理它 我做了一些研究,我一直在尝试测试一些简单的代码 对于DOTML,我从 及 它抛出了这个错误 Error: graph_test.dotml:1: syntax error near line 1 context: <graph file-name="graph" >>> ra

对于一个任务,我们被告知,对于附加功能,可以使用GraphViz输出一个图。这就是我们得到的所有信息

赋值是perl输出XML。我很确定我可以输出代码,我只需要知道如何从那里处理它

我做了一些研究,我一直在尝试测试一些简单的代码

对于DOTML,我从

它抛出了这个错误

Error: graph_test.dotml:1: syntax error near line 1
context: <graph         file-name="graph" >>>  rankdir="LR"> <<<
Error:graph\u test.dotml:1:第1行附近的语法错误

上下文:>>rankdir=“LR”>encoding=“UTF-8”>您需要将图形转换为点。您可以在此处获得完整的XSLT样式表:

http://graphml.graphdrawing.org/download.html
要转换作为示例发布的XML图形,您可以使用类似于以下的XSLT样式表(这非常有限,仅适用于非常简单的图形-我将其用作教学示例):

将上面的代码重命名为
something.dot
,并使用Graphviz或
dot
运行它,它将生成一个图形


您可以使用CPAN模块运行XSLT。

这在
dot
命令行中不起作用(除非它现在有一些指定XML输入的选项)。您必须将
dot
语言文本输入
dot
程序。但是,您可以使用XSLT将其转换为有效的
dot
语言?我贴出了答案。您应该在GraphML站点获得完整的样式表。但是我碰巧用了一个非常简单的例子来教如何用XSLT生成文本。我用你的代码试过了,成功了。所以你也可以使用它,但请记住它非常有限,不能用于任何图形。我不确定(我不记得命令-通常检查文档:)我使用了
Graphviz
应用程序来运行它。我认为pdf是
dot-Tpdf file.dot file.pdf
,SVG是
-Tsvg
,等等。
dot -Tps graph1.dot -o graph
Error: graph_test.dotml:1: syntax error near line 1
context: <graph         file-name="graph" >>>  rankdir="LR"> <<<
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
     http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <graph id="G" edgedefault="undirected">
Error: simple.graphml:1: syntax error near line 1
context: <?xml version="1.0" >>>  encoding="UTF-8"?> <<
http://graphml.graphdrawing.org/download.html
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="text"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="graph|digraph">
        <xsl:value-of select="name()"/>
        <xsl:text> {&#xa;</xsl:text>
        <xsl:apply-templates select="@rankdir|node()"/>
        <xsl:text>}</xsl:text>
    </xsl:template>

    <xsl:template match="@rankdir">
        <xsl:text>rankdir = </xsl:text>
        <xsl:value-of select="."/>
        <xsl:text>;&#xa;</xsl:text>
    </xsl:template>

    <xsl:template match="node">
        <xsl:value-of select="@id"/>
        <xsl:if test="@*[not(name()='id')]">
            <xsl:text> [</xsl:text>
            <xsl:for-each select="@*[not(name()='id')]">
                <xsl:value-of select="name()"/>
                <xsl:text>=&quot;</xsl:text>
                <xsl:value-of select="."/>
                <xsl:text>&quot;</xsl:text>
                <xsl:if test="not(position()=last())">
                    <xsl:text>, </xsl:text>
                </xsl:if>
            </xsl:for-each>
            <xsl:text>];&#xa;</xsl:text>
        </xsl:if>
    </xsl:template>

    <xsl:template match="edge">
        <xsl:value-of select="@from"/>
        <xsl:choose>
            <xsl:when test="parent::*[name()='graph']">
                <xsl:text> -- </xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text> -> </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:value-of select="@to"/>
        <xsl:if test="@*[not(name()='from')][not(name()='to')]">
            <xsl:text> [</xsl:text>
            <xsl:for-each select="@*[not(name()='from')][not(name()='to')]">
                <xsl:value-of select="name()"/>
                <xsl:text>=&quot;</xsl:text>
                <xsl:value-of select="."/>
                <xsl:text>&quot;</xsl:text>
                <xsl:if test="not(position()=last())">
                    <xsl:text>, </xsl:text>
                </xsl:if>
            </xsl:for-each>
            <xsl:text>];&#xa;</xsl:text>
        </xsl:if>
    </xsl:template>

</xsl:stylesheet>
graph {
rankdir = LR;
a [label="node1", fontsize="9", fontname="Arial"];
b [label="node2", fontsize="9", fontname="Arial"];
c [label="node3", fontsize="9", fontname="Arial"];
d [label="node4", fontsize="9", fontname="Arial"];
a -- b [fontname="Arial", fontsize="9", label="edge1"];
a -- c [fontname="Arial", fontsize="9", label="edge2"];
b -- c [fontname="Arial", fontsize="9", label="edge3"];
b -- d [fontname="Arial", fontsize="9", label="edge4"];
c -- d [fontname="Arial", fontsize="9", label="edge5"];
}