comparison api/Exporters/WarFoundryHtmlExporter.cs @ 153:dd892567f054

Fixes #174: HTML output can add empty tables for stat lines * Check if table has rows before outputting it
author IBBoard <dev@ibboard.co.uk>
date Sat, 26 Sep 2009 19:57:06 +0000
parents 7f13ffcb8765
children 4a02c07278e7
comparison
equal deleted inserted replaced
152:0c0e14f03785 153:dd892567f054
55 header.InnerText = Translation.GetTranslation("armyHtmlOutputBodyHeader", "{0} - {1}pts", army.Name, army.Points); 55 header.InnerText = Translation.GetTranslation("armyHtmlOutputBodyHeader", "{0} - {1}pts", army.Name, army.Points);
56 body.AppendChild(header); 56 body.AppendChild(header);
57 57
58 foreach (XmlElement table in CreateTables(army, doc)) 58 foreach (XmlElement table in CreateTables(army, doc))
59 { 59 {
60 body.AppendChild(table); 60 if (!IsTableOnlyHeader(table))
61 {
62 body.AppendChild(table);
63 }
61 } 64 }
62 65
63 StreamWriter writer = new StreamWriter(path, false); 66 StreamWriter writer = new StreamWriter(path, false);
64 67
65 try 68 try
68 } 71 }
69 finally 72 finally
70 { 73 {
71 writer.Close(); 74 writer.Close();
72 } 75 }
76 }
77
78 private bool IsTableOnlyHeader(XmlElement table)
79 {
80 return table.ChildNodes.Count == 1;
73 } 81 }
74 82
75 private XmlElement[] CreateTables(Army army, XmlDocument doc) 83 private XmlElement[] CreateTables(Army army, XmlDocument doc)
76 { 84 {
77 Dictionary<string, XmlElement> tables = new Dictionary<string, XmlElement>(); 85 Dictionary<string, XmlElement> tables = new Dictionary<string, XmlElement>();