When the text of an element contains a character for which an HTML entity exists, this entity appears in the SVG output, even though this is not valid. HTML entities are not defined there; renderers/browsers will complain that they are not. For example, if the text contains "ü", the SVG output contains "\ü". Instead,
it should instead contain the literal character ü, or
it should instead contain "\ü", or
a DOCTYPE with the corresponding entity definition needs to be added, i.e., put the following between the <?xml tag and the <svg tag: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ <!ENTITY uuml "ü"> ]>
To reproduce:
The following code:
public class Test {
public static void main( final String[] args ) throws ExecuteException {
final Graphviz graphviz = Graphviz.digraph()
.addNode( Node.builder().label( "ü" ).build() )
.build();
System.out.println( graphviz.toSvgStr() );
}
}
When the text of an element contains a character for which an HTML entity exists, this entity appears in the SVG output, even though this is not valid. HTML entities are not defined there; renderers/browsers will complain that they are not. For example, if the text contains "ü", the SVG output contains "\ü". Instead,
<?xml
tag and the<svg
tag:<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ <!ENTITY uuml "ü"> ]>
To reproduce:
The following code:
creates: