in src/XmlStats/XmlStats.cs [355:463]
public void WriteReport(string path, TextWriter output)
{
output.Write("*** " + path); // filename or "Summary"
this._watch.Stop();
float time = this._watch.ElapsedMilliseconds;
if (time > 1000)
{
output.Write(" ({0,1:F} secs)", time / 1000f);
}
else
{
output.Write(" ({0,1:F} msecs)", time);
}
output.Write(this._newLine);
output.Write(this._newLine);
// count how many unique attributes
long attrsCount = 0;
foreach (NodeStats ns in this._elements.Values)
{
if (ns.Attrs != null)
{
attrsCount += ns.Attrs.Count;
}
}
// overall stats
output.Write("elements");
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " unique", this._elements.Count);
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " empty", this._emptyCount);
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " total", this._elemCount);
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " chars", this._elemChars);
output.Write(this._newLine);
output.Write("attributes");
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " unique", attrsCount);
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " total", this._attrCount);
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " chars", this._attrChars);
output.Write(this._newLine);
output.Write("comments");
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " total", this._commentCount);
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " chars", this._commentChars);
output.Write(this._newLine);
output.Write("PIs");
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " total", this._piCount);
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " chars", this._piChars);
output.Write(this._newLine);
if (this._whiteSpace != WhitespaceHandling.None)
{
output.Write("whitespace");
output.Write(this._newLine);
output.Write("{0,-20} {1,9:D}", " chars", this._whiteChars);
output.Write(this._newLine);
if (this._whiteSpace == WhitespaceHandling.Significant ||
this._whiteSpace == WhitespaceHandling.All)
{
output.Write("{0,-20} {1,9:D}", " significant", this._whiteSChars);
output.Write(this._newLine);
}
}
// elem/attr stats
output.Write(this._newLine);
output.Write(this._newLine);
output.Write("elem/attr count chars");
output.Write(this._newLine);
output.Write("----------------------------------------");
output.Write(this._newLine);
// sort the list.
SortedList slist = new SortedList(this._elements, new NodeStatsComparer());
foreach (NodeStats es in slist.Values)
{
output.Write("{0,-20} {1,9:D} {2,9:D}", es.Name, es.Count, es.Chars);
output.Write(this._newLine);
if (es.Attrs != null)
{
var list = new List<NodeStats>(es.Attrs.Values);
list.Sort(new Comparison<NodeStats>((a, b) =>
{
return a.Name.CompareTo(b.Name);
}));
foreach (NodeStats ns in list)
{
output.Write(" @{0,-17} {1,9:D} {2,9:D}", ns.Name, ns.Count, ns.Chars);
output.Write(this._newLine);
}
}
}
output.Write(this._newLine);
}