Permalink
Browse files

Fix for RT bug #46992: GraphML: end tag of nodes before definition of

  • Loading branch information...
1 parent c63e82d commit ededa3d787ad89ac532c578c06390e8a7b270499 @ironcamel committed Oct 22, 2010
Showing with 85 additions and 46 deletions.
  1. +10 −5 bin/graph-easy
  2. +9 −5 lib/Graph/Easy/As_graphml.pm
  3. +33 −18 t/graphml.t
  4. +33 −18 t/graphml_yed.t
View
@@ -634,13 +634,18 @@ GraphML is XML:
<key id="d0" for="edge" attr.name="label" attr.type="string"/>
<graph id="G" edgedefault="directed">
- <node id="Berlin"/>
- <node id="Bonn"/>
- <node id="Ulm"/>
- <edge source="Bonn" target="Berlin"/>
+ <node id="Berlin">
+ </node>
+ <node id="Bonn">
+ </node>
+ <node id="Ulm">
+ </node>
+ <edge source="Bonn" target="Berlin">
<data key="d0">car</data>
- <edge source="Bonn" target="Ulm"/>
+ </edge>
+ <edge source="Bonn" target="Ulm">
<data key="d0">car</data>
+ </edge>
</graph>
<graphml>
@@ -111,9 +111,9 @@ sub _as_graphml
my $txt = <<EOF
<?xml version="1.0" encoding="UTF-8"?>
-<graphml xmlns="http://graphml.graphdrawing.org/xmlns/graphml"
+<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"##Y##
- xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns/graphml
+ xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
##SCHEMA##">
<!-- Created by Graph::Easy v##VERSION## at ##DATE## -->
@@ -313,11 +313,13 @@ sub as_graphml
my ($self, $indent, $ids) = @_;
my $g = $self->{graph};
- my $txt = $indent . '<node id="' . $g->_safe_xml($self->{name}) . "\"/>\n";
+ my $txt = $indent . '<node id="' . $g->_safe_xml($self->{name}) . "\">\n";
$txt .= $g->_attributes_as_graphml($self, $indent, $ids->{node});
- $txt;
+ $txt .= "$indent</node>\n";
+
+ return $txt;
}
#############################################################################
@@ -332,10 +334,12 @@ sub as_graphml
my $g = $self->{graph};
my $txt = $indent . '<edge source="' . $g->_safe_xml($self->{from}->{name}) .
- '" target="' . $g->_safe_xml($self->{to}->{name}) . "\"/>\n";
+ '" target="' . $g->_safe_xml($self->{to}->{name}) . "\">\n";
$txt .= $g->_attributes_as_graphml($self, $indent, $ids->{edge});
+ $txt .= "$indent</edge>\n";
+
$txt;
}
View
@@ -63,12 +63,15 @@ my $result = <<EOT
</key>
<graph id="G" edgedefault="directed">
- <node id="A"/>
+ <node id="A">
<data key="d0">red</data>
- <node id="B"/>
+ </node>
+ <node id="B">
+ </node>
- <edge source="A" target="B"/>
+ <edge source="A" target="B">
<data key="d1">blue</data>
+ </edge>
</graph>
</graphml>
EOT
@@ -93,13 +96,16 @@ $result = <<EOT2
<key id="d2" for="edge" attr.name="label" attr.type="string"/>
<graph id="G" edgedefault="directed">
- <node id="A"/>
+ <node id="A">
<data key="d0">red</data>
- <node id="B"/>
+ </node>
+ <node id="B">
+ </node>
- <edge source="A" target="B"/>
+ <edge source="A" target="B">
<data key="d1">blue</data>
<data key="d2">train-station &amp; &lt;Überlingen &quot;Süd&quot;&gt;</data>
+ </edge>
</graph>
</graphml>
EOT2
@@ -122,13 +128,16 @@ $result = <<EOT3
<key id="d2" for="edge" attr.name="label" attr.type="string"/>
<graph id="G" edgedefault="directed">
- <node id="&lt;&amp;&apos;&quot;&gt;"/>
+ <node id="&lt;&amp;&apos;&quot;&gt;">
<data key="d0">red</data>
- <node id="B"/>
+ </node>
+ <node id="B">
+ </node>
- <edge source="&lt;&amp;&apos;&quot;&gt;" target="B"/>
+ <edge source="&lt;&amp;&apos;&quot;&gt;" target="B">
<data key="d1">blue</data>
<data key="d2">train-station &amp; &lt;Überlingen &quot;Süd&quot;&gt;</data>
+ </edge>
</graph>
</graphml>
EOT3
@@ -150,14 +159,19 @@ $result = <<EOT4
<key id="d0" for="edge" attr.name="label" attr.type="string"/>
<graph id="G" edgedefault="directed">
- <node id="A"/>
- <node id="B"/>
- <node id="C"/>
-
- <edge source="A" target="B"/>
+ <node id="A">
+ </node>
+ <node id="B">
+ </node>
+ <node id="C">
+ </node>
+
+ <edge source="A" target="B">
<data key="d0">car</data>
- <edge source="A" target="C"/>
+ </edge>
+ <edge source="A" target="C">
<data key="d0">train</data>
+ </edge>
</graph>
</graphml>
EOT4
@@ -176,7 +190,8 @@ $cities->add_nodes($bonn);
$result = <<EOT5
<graph id="G" edgedefault="directed">
<graph id="Cities&quot;" edgedefault="directed">
- <node id="Bonn"/>
+ <node id="Bonn">
+ </node>
</graph>
</graph>
</graphml>
@@ -199,9 +214,9 @@ sub _compare
$result = <<EOR
<?xml version="1.0" encoding="UTF-8"?>
-<graphml xmlns="http://graphml.graphdrawing.org/xmlns/graphml"
+<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns/graphml
+ xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
EOR
View
@@ -63,12 +63,15 @@ my $result = <<EOT
</key>
<graph id="G" edgedefault="directed">
- <node id="A"/>
+ <node id="A">
<data key="d0">red</data>
- <node id="B"/>
+ </node>
+ <node id="B">
+ </node>
- <edge source="A" target="B"/>
+ <edge source="A" target="B">
<data key="d1">blue</data>
+ </edge>
</graph>
</graphml>
EOT
@@ -93,13 +96,16 @@ $result = <<EOT2
<key id="d2" for="edge" attr.name="label" attr.type="string"/>
<graph id="G" edgedefault="directed">
- <node id="A"/>
+ <node id="A">
<data key="d0">red</data>
- <node id="B"/>
+ </node>
+ <node id="B">
+ </node>
- <edge source="A" target="B"/>
+ <edge source="A" target="B">
<data key="d1">blue</data>
<data key="d2">train-station &amp; &lt;Überlingen &quot;Süd&quot;&gt;</data>
+ </edge>
</graph>
</graphml>
EOT2
@@ -122,13 +128,16 @@ $result = <<EOT3
<key id="d2" for="edge" attr.name="label" attr.type="string"/>
<graph id="G" edgedefault="directed">
- <node id="&lt;&amp;&apos;&quot;&gt;"/>
+ <node id="&lt;&amp;&apos;&quot;&gt;">
<data key="d0">red</data>
- <node id="B"/>
+ </node>
+ <node id="B">
+ </node>
- <edge source="&lt;&amp;&apos;&quot;&gt;" target="B"/>
+ <edge source="&lt;&amp;&apos;&quot;&gt;" target="B">
<data key="d1">blue</data>
<data key="d2">train-station &amp; &lt;Überlingen &quot;Süd&quot;&gt;</data>
+ </edge>
</graph>
</graphml>
EOT3
@@ -150,14 +159,19 @@ $result = <<EOT4
<key id="d0" for="edge" attr.name="label" attr.type="string"/>
<graph id="G" edgedefault="directed">
- <node id="A"/>
- <node id="B"/>
- <node id="C"/>
-
- <edge source="A" target="B"/>
+ <node id="A">
+ </node>
+ <node id="B">
+ </node>
+ <node id="C">
+ </node>
+
+ <edge source="A" target="B">
<data key="d0">car</data>
- <edge source="A" target="C"/>
+ </edge>
+ <edge source="A" target="C">
<data key="d0">train</data>
+ </edge>
</graph>
</graphml>
EOT4
@@ -176,7 +190,8 @@ $cities->add_nodes($bonn);
$result = <<EOT5
<graph id="G" edgedefault="directed">
<graph id="Cities&quot;" edgedefault="directed">
- <node id="Bonn"/>
+ <node id="Bonn">
+ </node>
</graph>
</graph>
</graphml>
@@ -199,10 +214,10 @@ sub _compare
$result = <<EOR
<?xml version="1.0" encoding="UTF-8"?>
-<graphml xmlns="http://graphml.graphdrawing.org/xmlns/graphml"
+<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:y="http://www.yworks.com/xml/graphml"
- xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns/graphml
+ xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
http://www.yworks.com/xml/schema/graphml/1.0/ygraphml.xsd">
EOR

0 comments on commit ededa3d

Please sign in to comment.