Why is this digraph label incorrect? graphviz says "syntax error"

Hi,

I’ve got the following node definition in a .dot file:

        21 [label=<<b>AttributeCreator_5 [AttributeCreator]</b><br/><table border="0" cellspacing="0"><tr><td valign="middle">    </td><td><table border="1" cellpadding="2" cellspacing="0"><tr><td>New Attribute</td><td>Value</td></tr><tr><td>message</td><td>&lt;li&gt;@Value(message)&lt;/li&gt;</td></tr></table></td></tr></table>>];

Graphviz says:

Error: syntax error in line 1
... <br/><table border="0" cellspacing="0"> ...
in label of node 21

Why is it wrong? There is no space before the table-tag etc?

I tried [label=< <b>AttributeCreator_5 but that did not help (same error).

Two things.

Running this label through an HTML formatter shows it is malformed. There is a spurious at the beginning of the nested table in line 7.

<b>AttributeCreator_5 [AttributeCreator]</b>
<table border="0" cellspacing="0">
   <tr>
      <td valign="middle">    </td>
      <td>
         <table border="1" cellpadding="2" cellspacing="0">
            </tr>
            <tr>
               <td>New Attribute</td>
               <td>Value</td>
            </tr>
            <tr>
               <td>message</td>
               <td>&lt;li&gt;@Value(message)&lt;/li&gt;</td>
            </tr>
         </table>
      </td>
   </tr>
</table>

Second, apologies this is not obvious, but you can’t concatenate the initial text line and an HTML table.I don’t know how well this is documented, but you can see this in the graphviz source code for the html parser:

html  : T_html fonttext T_end_html { scanner->parser.lbl = mkLabel($2,HTML_TEXT); }
      | T_html fonttable T_end_html { scanner->parser.lbl = mkLabel($2,HTML_TBL); }
      | error { cleanup(&scanner->parser); YYABORT; }
      ;

Graphviz HTML is only HTMLish, not actually HTML.

When in doubt, try to build from small examples that work quickly, to larger ones.

1 Like