Cairo-rendered SVG file doesn't include "id" attribute values from Dot file
svg:core
When rendering a Dot file to SVG using the svg:core
renderer, attributes such as id
, class
, comment
and URL
are included in the SVG output.
For example, here's an input file called test.dot
:
digraph FooBarTest {
"foo" [id="idNodeFoo", class="classNodeFoo", comment="commentNodeFoo", URL="http://google.com"];
"foo" -> "bar" [id="idEdgeFooBar", class="classEdgeFooBar", comment="commentEdgeFooBar", URL="http://apple.com"];
}
Command:
dot -v -Tsvg:svg:core -o test-core.svg test.dot
See the attached output file test-core.svg
:
Here's an extract from it, showing the id
, class
, comment
and URL
values rendered:
<!-- commentNodeFoo -->
<g id="idNodeFoo" class="node classNodeFoo">
<title>foo</title>
<g id="a_idNodeFoo"><a xlink:href="http://google.com" xlink:title="foo">
svg:cairo
However, when using the svg:cairo
renderer, none of those attribute values are included in the SVG output.
Command:
dot -v -Tsvg:cairo:cairo -o test-cairo.svg test.dot
See the attached output file test-cairo.svg
:
This is the basic structure:
<svg>
<defs>
<g>
<symbol id="glyph0-1"> ... </symbol>
...
</g>
</defs>
<g id="surface1">
<rect />
<path />
<g>
<use xlink:href="#glyph0-1" />
...
</g>
...
</g>
</svg>
All the nodes and edges are contained within <g id="surface1">
, but the id
, class
, comment
and URL
values from the Dot file aren't included.
Question
Is there a way to make the svg:cairo
renderer include the id
attribute values from the Dot file?
Specifically, can the svg:cairo
renderer generate a <g id="...">
container element for each node and edge, using the id
values from the Dot file? (in the same way as the svg:core
renderer does)
For example:
<g id="surface1">
<rect />
<g id="idNodeFoo"><!-- Is it possible for Cairo to generate this container element? -->
<path />
<g>
<use xlink:href="#glyph0-1" />
...
</g>
</g>
...
</g>
The documentation states:
In the formats:
-Tcmap
,-Tcmapx
,-Tsvg
,-Tvml
, the output generatesid="node#"
properties for nodes,id="edge#"
properties for edges, andid="cluster#"
properties for clusters, with the#
replaced by an internally assigned integer. These strings can be provided instead by an externally providedid=xxx
attribute on the object.
Many thanks in advance!
Environment
- Platform — macOS Sierra 10.12.6
- Package manager — MacPorts 2.4.2
graphviz @2.40.1_1+pangocairo+x11
cairo @1.14.12_0+quartz+x11
pango @1.40.9_0+quartz+x11