vty: fix vty_dump_element(): do not print empty <attributes>

Some attributes like CMD_ATTR_LIB_COMMAND are not being printed
to the XML VTY reference (despite being set), so we should not
print empty "<attributes scope='global'></attributes>".

Change-Id: Ie7e53b080c10564bfef6f0e8ddeb470e46fad387
Related: SYS#4937
diff --git a/src/vty/command.c b/src/vty/command.c
index d71f686..4952567 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -631,6 +631,10 @@
 	{ 0, NULL }
 };
 
+/* Public attributes (to be printed in the VTY / XML reference) */
+#define CMD_ATTR_PUBLIC_MASK \
+	(CMD_ATTR_IMMEDIATE | CMD_ATTR_NODE_EXIT)
+
 /* Get a flag character for a global VTY command attribute */
 static char cmd_attr_get_flag(unsigned int attr)
 {
@@ -670,7 +674,7 @@
 	print_func(data, "    <command id='%s'>%s", xml_string, newline);
 
 	/* Print global attributes and their description */
-	if (cmd->attr != 0x00) { /* ... if at least one flag is set */
+	if (cmd->attr & CMD_ATTR_PUBLIC_MASK) { /* ... only public ones */
 		print_func(data, "      <attributes scope='global'>%s", newline);
 
 		for (i = 0; i < ARRAY_SIZE(cmd_attr_desc) - 1; i++) {