Click here to Skip to main content
12,444,635 members (51,387 online)
Click here to Skip to main content

Stats

127.6K views
2.9K downloads
47 bookmarked
Posted

XML optimization

, 11 Sep 2002
This is a set of techniques aimed to audit design metadata from any XML stream
// betterxml.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "betterxml.h"
#include "betterxmlDlg.h"


#include "AppLogic.h"
#include "HtmlWriter.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBetterxmlApp

BEGIN_MESSAGE_MAP(CBetterxmlApp, CWinApp)
	//{{AFX_MSG_MAP(CBetterxmlApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBetterxmlApp construction

CBetterxmlApp::CBetterxmlApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CBetterxmlApp object

CBetterxmlApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CBetterxmlApp initialization

BOOL CBetterxmlApp::InitInstance()
{
	// Parse command line for standard shell commands, DDE, file open
	//
	BOOL bBatchDirectory = FALSE;
	char szDirectory[SAXML_URLMAXLENGTH]="";
	char szFilename[SAXML_URLMAXLENGTH]="";

	
	for (int i = 1; i < __argc; i++)
	{
		LPCTSTR pszParam = __targv[i];
		BOOL bFlag = FALSE;
		BOOL bLast = ((i + 1) == __argc);
		if (pszParam[0] == '-' || pszParam[0] == '/')
		{
			// remove flag specifier
			bFlag = TRUE;
			++pszParam;
		}
		if (strcmp(pszParam,"d")==0) // -d
		{
			bBatchDirectory = TRUE;
			szDirectory[0]='\0';
			continue;
		}
		
		if (bBatchDirectory)
		{
			strcpy(szDirectory, pszParam);
			bBatchDirectory = FALSE;
		}
		else
			strcpy(szFilename, pszParam);
	}


	CAppLogic app;

	if (strlen(szFilename)>0)
	{
	
		app.process( szFilename ); // of the form *.xml
		app.dump();

		generateReport(app, szFilename ); // of the form *.stats.html

	}
	else if (strlen(szDirectory)>0) // batch a whole directory
	{
		long nbFiles = 0;

		char szOldDir[MAX_PATH];
		long nLength = MAX_PATH;
		::GetCurrentDirectory(nLength, szOldDir);

		if (szDirectory[strlen(szDirectory)-1]!='\\')
			strcat(szDirectory,"\\");

		::SetCurrentDirectory(szDirectory);

		strcat(szDirectory,"*.xml"); // find all xml files in this directory

		// get start-time
		time_t starttime,endtime;
		time(&starttime);

		WIN32_FIND_DATA findFile;
		HANDLE hContext;
		hContext=::FindFirstFile(szDirectory, &findFile);
		if (  hContext != INVALID_HANDLE_VALUE )
		{
			do
			{
				app.process( findFile.cFileName ); // of the form *.xml
				app.dump();

				generateReport(app, findFile.cFileName ); // of the form *.stats.html

				nbFiles++;
			}
			while (	::FindNextFile(hContext, &findFile) );

			::FindClose(hContext);
		}
	
		time(&endtime);

		time_t duration = endtime-starttime; // in seconds
		char szTemp[MAX_PATH];
		sprintf(szTemp,"\n\n\n*** Finished processing of %ld files. %ld seconds total process time. ***\n",nbFiles,duration);
		trace(TRC_INFO,szTemp);

		::SetCurrentDirectory(szOldDir);
	}








	return FALSE; // temporary, of course... :-)
}




APICALL void CBetterxmlApp::generateReport(CAppLogic &app, char *szOutputFilename) // report in HTML format
{
	// replace *.xml with *.stats.html
	char szHtmlFilename[SAXML_URLMAXLENGTH];
	strcpy(szHtmlFilename,szOutputFilename);
	char *szLastDot = strrchr(szHtmlFilename,'.'); // find last dot
	if (szLastDot)
		szLastDot[0]=0; // force EOL (prepare concatenation)
	strcat(szHtmlFilename,".stats.html");

	HTMLWriter h(szHtmlFilename);

	// 
	HRSRC hHtmlRes;
	DWORD nHtmlSize;
	HGLOBAL hFile;
	CString s,s1,s2,s3,s4,s5,s6,s7,s8;
	CString szEmpty = "&nbsp;";
	CString szBytes; szBytes.LoadString(IDS_REPORTBYTES);
	CString szLong; szLong.LoadString(IDS_REPORTLONG);
	CString szFloat; szFloat.LoadString(IDS_REPORTFLOAT);
	CString szFloatBytes; szFloatBytes.LoadString(IDS_REPORTFLOATBYTES);
	CString szPercent; szPercent.LoadString(IDS_REPORTPERCENT);
	CString szLines; szLines.LoadString(IDS_REPORTLINES);
	CString ss1="m1";
	CString ss2="m2";
	
	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_REPORT_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_REPORT_BODY), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


	//
	s2.LoadString(IDS_REPORTGENERAL);
	s.Format(s2.GetBuffer(0),szOutputFilename);
	h.Output(s);


	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_GENERAL_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}

	s = "<table width=\"687\" border=\"0\" class=\"dump\">";
	h.Output(s);
	s1 = "_StreamSize";
	s2.LoadString(IDS_REPORTHSTREAMSIZE);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTSTREAMSIZE);
	s5.Format(szBytes.GetBuffer(0),app.getStatsStreamLength());
	s6 = szEmpty; if (!app.getStatsStreamIsFull()) s6.LoadString(IDS_REPORTPORTION);
	h.Output(ss1,s1,s2,s3,s4,s5,s6, TRUE);	

	s1 = "_NbTotalLines";
	s2.LoadString(IDS_REPORTHSTREAMNBTOTALLINES);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTSTREAMNBTOTALLINES);
	long nStreamLength = app.getStatsStreamLength();
	long nblines = app.getStatsNbLines() + ((nStreamLength==0)?0:1);
	s5.Format(szLong.GetBuffer(0),nblines);
	s6 = szEmpty;
	h.Output(ss2,s1,s2,s3,s4,s5,s6);

	s1 = "_NbTotalElements";
	s2.LoadString(IDS_REPORTHSTREAMNBTOTALELEMENTS);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNBTOTALELEMENTS);
	long nbelements = app.getStatsNbElements();
	s5.Format(szLong.GetBuffer(0),nbelements);
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);

	s1 = "_NbTotalAttributes";
	s2.LoadString(IDS_REPORTHSTREAMNBTOTALATTRIBUTES);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNBTOTALATTRIBUTES);
	s5.Format(szLong.GetBuffer(0),app.getStatsNbAttributes());
	s6 = szEmpty;
	h.Output(ss2,s1,s2,s3,s4,s5,s6);

	s1 = "_NbTotalComments";
	s2.LoadString(IDS_REPORTHSTREAMNBTOTALCOMMENTS);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNBTOTALCOMMENTS);
	s5.Format(szLong.GetBuffer(0),app.getStatsNbComments());
	s6 = szEmpty; if (app.getStatsNbComments()>0 && nStreamLength>0) {
		s.LoadString(IDS_REPORTPERCENTOVERALLSTREAM);
		s6.Format(s.GetBuffer(0), 100*double(app.getStatsCommentsSize())/nStreamLength);
	}
	h.Output(ss1,s1,s2,s3,s4,s5,s6);

	s1 = "_NbTotalCDATASections";
	s2.LoadString(IDS_REPORTHSTREAMNBTOTALCDATASECTIONS);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNBTOTALCDATASECTIONS);
	s5.Format(szLong.GetBuffer(0),app.getStatsCDATASections());
	s6 = szEmpty; if (app.getStatsCDATASections()>0 && nStreamLength>0) {
		s.LoadString(IDS_REPORTPERCENTOVERALLSTREAM);
		s6.Format(s.GetBuffer(0), 100*double(app.getStatsCDATASectionsSize())/nStreamLength);
	}
	h.Output(ss2,s1,s2,s3,s4,s5,s6);

	s1 = "_NbTotalPInstructions";
	s2.LoadString(IDS_REPORTHSTREAMNBTOTALPINSTRUCTIONS);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNBTOTALPINSTRUCTIONS);
	s5.Format(szLong.GetBuffer(0),app.getStatsNbPI());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);

	s1 = "_NbTotalNamespaces";
	s2.LoadString(IDS_REPORTHSTREAMNBTOTALNAMESPACES);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNBTOTALNAMESPACES);
	s5.Format(szLong.GetBuffer(0),app.getStatsNbNamespaces());
	s6 = szEmpty;
	h.Output(ss2,s1,s2,s3,s4,s5,s6);

	s = "</table>";
	h.Output(s);



	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_STRUCTURE_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}

	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_STRUCTURE_PATTERN_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


	// main pattern must be output here
/*<table width="687" border="0" class="dump">
  <tr><td>
<pre>
   &lt;COURSE&gt;
     &lt;MARK(=number)&gt;
     &lt;SECTION(=number)&gt;
     &lt;COURSENAME&gt;
</pre></td></tr></table>*/
	h.Output("<table width=\"687\" border=\"0\" class=\"dump\"><tr><td><pre>");
	if (app.getNbPatterns()==1)
	{
		long nCurDepth = 0;
		showMostSeenPattern( h, app.getRootElement(), nCurDepth);
	}
	h.Output("</pre></td></tr></table>");

	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_STRUCTURE_PATTERN2_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}

	s = "<table width=\"687\" border=\"0\" class=\"dump\">";
	h.Output(s);
	s1 = "_DistinctPatterns";
	s2.LoadString(IDS_REPORTSTRUCTHDISTPATTERNS);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTSTRUCTDISTPATTERNS);
	s5.Format(szLong.GetBuffer(0),app.getNbPatterns());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6, TRUE);	

	s1 = "_PatternOccurences";
	s2.LoadString(IDS_REPORTSTRUCTHPATTERNOCCS);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTSTRUCTPATTERNOCCS);
	s5.Format(szLong.GetBuffer(0),app.getPatternOccurences());
	s6 = szEmpty;
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	s1 = "_PatternHeight";
	s2.LoadString(IDS_REPORTSTRUCTHPATTERNHEIGHT);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTSTRUCTPATTERNHEIGHT);
	s5.Format(szLines.GetBuffer(0),app.getPatternHeight());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	

	s1 = "_PatternSize";
	s2.LoadString(IDS_REPORTSTRUCTHPATTERNSIZE);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTSTRUCTPATTERNSIZE);
	s5.Format(szBytes.GetBuffer(0),app.getPatternSize());
	s6 = szEmpty;
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	s1 = "_PatternFlattenSize";
	s2.LoadString(IDS_REPORTSTRUCTHPATTERNFLATSIZE);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTSTRUCTPATTERNFLATSIZE);
	s5.Format(szBytes.GetBuffer(0),app.getPatternFlatSize());
	long nPatternSize = app.getPatternSize();
	long nFlattenPatternSize = app.getPatternFlatSize();
	s6 = szEmpty; if (nPatternSize>0) {
		s.LoadString(IDS_REPORTPERCENTLESS);
		s6.Format(s.GetBuffer(0), 100*double(nPatternSize-nFlattenPatternSize)/nPatternSize);
	}
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	

	s1 = "_PatternGain";
	s2.LoadString(IDS_REPORTSTRUCTHPATTERNFLATGAIN);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTSTRUCTPATTERNFLATGAIN);
	long nFlattenStreamLength = nStreamLength - ( nPatternSize-nFlattenPatternSize ) * app.getPatternOccurences();
	if (nFlattenStreamLength<nStreamLength)
	{
		s5.Format(szPercent.GetBuffer(0),100*double(nStreamLength-nFlattenStreamLength)/nStreamLength);
		s6.LoadString(IDS_REPORTOVERALLSTREAM);
	}
	else
	{
		s5.LoadString(IDS_REPORTNOTAVAILABLE);
		s6 = szEmpty;
	}
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	s = "</table>";
	h.Output(s);


	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_DEPTH_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


	s = "<table width=\"687\" border=\"0\" class=\"dump\">";
	h.Output(s);
	s1 = "_DepthMax";
	s2.LoadString(IDS_REPORTSTRUCTHDEPTHMAX);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTSTRUCTDEPTHMAX);
	s5.Format(szLong.GetBuffer(0),app.getDepthMax());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6, TRUE);	

	s1 = "_DepthMean";
	s2.LoadString(IDS_REPORTSTRUCTHDEPTHMEAN);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTSTRUCTDEPTHMEAN);
	s5.Format(szFloat.GetBuffer(0),app.getDepthMean()+1);
	s6 = szEmpty;
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	s1 = "_DepthStdDev";
	s2.LoadString(IDS_REPORTSTRUCTHDEPTHSTDDEV);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTSTRUCTDEPTHSTDDEV);
	s5.Format(szFloat.GetBuffer(0),app.getDepthStdDev());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	

	long nDepthMax = app.getDepthMax();
	CString szDepthAxisH,szDepthAxisV;

	for (long i=1;i<=nDepthMax;i++)
	{
		long n = app.getDepthOccurences(i);
		if (!szDepthAxisV.IsEmpty())
			szDepthAxisV += ",";
		if (!szDepthAxisH.IsEmpty())
			szDepthAxisH += ",";

		s.Format("%ld",n);
		szDepthAxisV += s;
		s.Format("\"%02ld\"",i);
		szDepthAxisH += s;


		s1 = "_DepthElement";
		s2.LoadString(IDS_REPORTSTRUCTHDEPTHELEMENT);
		s3 = szEmpty;
		s.LoadString(IDS_REPORTSTRUCTDEPTHELEMENT);
		s4.Format(s.GetBuffer(0), i);
		s.LoadString(IDS_REPORTSTRUCTDEPTHELEMENT2);
		s5.Format(s.GetBuffer(0), n, nbelements);
		if (nbelements>0) {
			s.LoadString(IDS_REPORTPERCENT2);
			s6.Format(s.GetBuffer(0), 100*double(app.getDepthOccurences(i))/nbelements);
		}
		else
			s6 = szEmpty;
		h.Output(i%2==0 ? ss1:ss2,s1,s2,s3,s4,s5,s6);	

		if ( n >0 ) // list all elements at this depth
		{
			s4 = szEmpty + szEmpty;
			XmlArrayNode elemcoll;
			app.getDepthElementCollection(i, elemcoll);
			long jn = elemcoll.GetSize();
			if (jn>0)
			{
				for (long j=0;j<jn;j++)
				{
					s4 += "&lt;";
					IXmlNode *p = elemcoll.GetAt(j);
					if (p)
						s4 += p->getName();
					s4 += "&gt; ";
				}

				s1 = "_DepthElementListing";
				s2.LoadString(IDS_REPORTSTRUCTHDEPTHELEMENTLISTING);
				s3 = szEmpty;
				s5 = szEmpty;
				s6 = szEmpty;
				h.Output(i%2==0 ? ss1:ss2,s1,s2,s3,s4,s5,s6);	

			}
		}
	}

	s.Format("<tr><td class=\"%s\">&nbsp;</td><td class=\"%s\">&nbsp;</td><td class=\"%s\">&nbsp;</td><td class=\"%s\">&nbsp;</td><td class=\"%s\">&nbsp;</td></tr>", ss1,ss1,ss1,ss1);
	h.Output(s);

	s1 = "_DepthChart";
	s2.LoadString(IDS_REPORTSTRUCTHDEPTHCHART);
	s3 = szEmpty;
	s.LoadString(IDS_REPORTSTRUCTDEPTHCHART);
	s4.Format("<a href=\"javascript:showhelper('%s')\" title=\"%s\" class=\"link\">%s</a>", s1.GetBuffer(0), s2.GetBuffer(0), s.GetBuffer(0));
	s5 = szEmpty;
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	


	s = "</table>";
	h.Output(s);


	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_DEPTH_FTR1), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}

/* of the form :
<script language="javascript">
	var tabheight=120;
	var tabdata=new Array(1,15,83,159);
	var tabtips=new Array("01","02","03","04");
	showChart_Max("<p class='m1'>Depth histogram chart</p>",tabheight,"#4488DD",tabdata,tabtips);
</script>
*/	

	s = "<script language=\"javascript\">var tabheight=120;var tabdata=new Array(";
	s += szDepthAxisV;
	s += ");var tabtips=new Array(";
	s += szDepthAxisH;
	s2.LoadString(IDS_REPORTDEPTHHISTOGRAMCHART);
	s3.Format(");showChart_Max(\"<p class='%s'>%s</p>\",tabheight,\"#4488DD\",tabdata,tabtips);</script>", ss1.GetBuffer(0), s2.GetBuffer(0));
	s += s3;
	h.Output(s);

	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_DEPTH_FTR2), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_NAMING_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


	s = "<table width=\"687\" border=\"0\" class=\"dump\">";
	h.Output(s);
	s1 = "_NamingMin";
	s2.LoadString(IDS_REPORTHNAMINGMIN);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNAMINGMIN);
	s5.Format(szBytes.GetBuffer(0),app.getStructStatsMin());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6, TRUE);	

	s1 = "_NamingMax";
	s2.LoadString(IDS_REPORTHNAMINGMAX);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNAMINGMAX);
	s5.Format(szBytes.GetBuffer(0),app.getStructStatsMax());
	s6 = szEmpty;
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	s1 = "_NamingMean";
	s2.LoadString(IDS_REPORTHNAMINGMEAN);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNAMINGMEAN);
	s5.Format(szFloatBytes.GetBuffer(0),app.getStructStatsMean());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	

	s1 = "_NamingStdDev";
	s2.LoadString(IDS_REPORTHNAMINGSTDDEV);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNAMINGSTDDEV);
	s5.Format(szFloat.GetBuffer(0),app.getStructStatsStdDev());
	s6 = szEmpty;
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	long nTotal = app.getStructStatsTotalOccurences();
	long nTotalSize = app.getStructStatsTotalSize();

	CString szNamingAxisH,szNamingAxisV;

	for (i=1;i<=app.getStructStatsMax();i++) // browse the 5 first depths
	{
		long n = app.getStructStatsNameOccurences(i);
		if (!szNamingAxisV.IsEmpty())
			szNamingAxisV += ",";
		if (!szNamingAxisH.IsEmpty())
			szNamingAxisH += ",";

		s.Format("%ld",n);
		szNamingAxisV += s;
		s.Format("\"%02ld\"",i);
		szNamingAxisH += s;


		s1 = "_NamingElement";
		s2.LoadString(IDS_REPORTHNAMINGELEMENT);
		s3 = szEmpty;
		s.LoadString(IDS_REPORTNAMINGELEMENT);
		s4.Format(s.GetBuffer(0),i);
		s.LoadString(IDS_REPORTTIMES);
		s5.Format(s.GetBuffer(0),n);
		if (n>0)
		{
			s.LoadString(IDS_REPORTNAMINGELEMENT2);
			s6.Format(s.GetBuffer(0),app.getStructStatsNameSizes(i),100*double(app.getStructStatsNameSizes(i))/nTotalSize);
		}
		else
			s6 = szEmpty;
		h.Output(i%2==0 ? ss1:ss2,s1,s2,s3,s4,s5,s6);	

		s = szEmpty + szEmpty + "(";

		XmlArrayString namecoll;
		app.getStructStatsNamesCollection(i, namecoll);
		long jn = namecoll.GetSize();
		if (jn>0)
		{
			for (long j=0;j<jn;j++)
			{
				if (j>0) s += ", ";

				s += namecoll.GetAt(j)->GetData();
				
			}
			s += ")";

			namecoll.Destroy();

			s1 = "_NamingElementListing";
			s2.LoadString(IDS_REPORTHNAMINGELEMENTLISTING);
			s3 = szEmpty;
			s4 = s;
			s5 = szEmpty;
			s6 = szEmpty;
			h.Output(i%2==0 ? ss1:ss2,s1,s2,s3,s4,s5,s6);	

		}


	}

	s1 = "_NamingTotalSize";
	s2.LoadString(IDS_REPORTHNAMINGTOTALSIZE);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNAMINGTOTALSIZE);
	s5.Format(szBytes.GetBuffer(0),nTotalSize);
	if (nTotalSize==0) nTotalSize=1; // avoid GPF
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	

	s1 = "_NamingGain";
	s2.LoadString(IDS_REPORTHNAMINGGAIN);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTNAMINGGAIN);

	// potential gain with reduced node sizes
	i = 0;
	nTotal = 0;
	app.evalStructStatsIfNodesSizesOptimized( app.getRootElement(), i, nTotal);

	if (nTotal>0 && nStreamLength>0)
	{
		s.LoadString(IDS_REPORTPERCENT);
		s5.Format(s.GetBuffer(0),100*double(nStreamLength-(nStreamLength-nTotalSize+nTotal))/nStreamLength) ;

		s.LoadString(IDS_REPORTNAMINGGAIN2);
		s6.Format(s.GetBuffer(0),nTotal);
	}
	else
	{
		s5.LoadString(IDS_REPORTNOTAVAILABLE);
		s6 = szEmpty;
	}
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	s.Format("<tr><td class=\"%s\">&nbsp;</td><td class=\"%s\">&nbsp;</td><td class=\"%s\">&nbsp;</td><td class=\"%s\">&nbsp;</td><td class=\"%s\">&nbsp;</td></tr>", ss1,ss1,ss1,ss1);
	h.Output(s);

	s1 = "_NamingChart";
	s2.LoadString(IDS_REPORTHNAMINGCHART);
	s3 = szEmpty;
	s.LoadString(IDS_REPORTNAMINGCHART);
	s4.Format("<a href=\"javascript:showhelper('%s')\" title=\"%s\" class=\"link\">%s</a>", s1.GetBuffer(0), s2.GetBuffer(0), s.GetBuffer(0));
	s5 = szEmpty;
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	


	s = "</table>";
	h.Output(s);


	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_NAMING_FTR1), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


/* of the form :
<script language="javascript">
	var tabheight=120;
	var tabdata=new Array(0,0,0,53,30,53,68,0,0,54);
	var tabtips=new Array("01","02","03","04","05","06","07","08","09","10");
	showChart_Max("<p class='m1'>Nodename sizes histogram chart</p>",tabheight,"#4488DD",tabdata,tabtips);
</script>
*/
	s = "<script language=\"javascript\">var tabheight=120;var tabdata=new Array(";
	s += szNamingAxisV;
	s += ");var tabtips=new Array(";
	s += szNamingAxisH;
	s2.LoadString(IDS_REPORTNAMINGHISTOGRAMCHART);
	s3.Format(");showChart_Max(\"<p class='%s'>%s</p>\",tabheight,\"#4488DD\",tabdata,tabtips);</script>", ss1.GetBuffer(0), s2.GetBuffer(0));
	s += s3;
	h.Output(s);



	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_NAMING_FTR2), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_ATTRIBUTES_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


	s = "<table width=\"687\" border=\"0\" class=\"dump\">";
	h.Output(s);
	s1 = "_AttributesMin";
	s2.LoadString(IDS_REPORTHATTRIBSMIN);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTATTRIBSMIN);
	s5.Format(szLong.GetBuffer(0),app.getStructStatsMinNbAttributsPerElement());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6, TRUE);	

	s1 = "_AttributesMax";
	s2.LoadString(IDS_REPORTHATTRIBSMAX);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTATTRIBSMAX);
	s5.Format(szLong.GetBuffer(0),app.getStructStatsMaxNbAttributsPerElement());
	s6 = szEmpty;
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	s1 = "_AttributesMean";
	s2.LoadString(IDS_REPORTHATTRIBSMEAN);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTATTRIBSMEAN);
	s5.Format(szFloat.GetBuffer(0),app.getStructStatsMeanNbAttributsPerElement());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	

	s1 = "_AttributesStdDev";
	s2.LoadString(IDS_REPORTHATTRIBSSTDDEV);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTATTRIBSSTDDEV);
	s5.Format(szFloat.GetBuffer(0),app.getStructStatsStdDevNbAttributsPerElement());
	s6 = szEmpty;
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	s1 = "_AttributesDisorder";
	s2.LoadString(IDS_REPORTHATTRIBSDISORDER);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTATTRIBSDISORDER);
	s5.Format(szPercent.GetBuffer(0),100*app.getStructStatsAttribsDisorderRatio());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	

	s = "</table>";
	h.Output(s);


	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_NAMESPACES_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


	s = "<table width=\"687\" border=\"0\" class=\"dump\">";
	h.Output(s);

	XmlArrayString namecoll;
	app.getNamespaces(namecoll);
	if (namecoll.GetSize()>0)
	{

		s1 = "_NamespacesRatio";
		s2.LoadString(IDS_REPORTHNAMESPACES);
		s3 = szEmpty;
		s4.LoadString(IDS_REPORTNAMESPACES);
		s5.Format(szPercent.GetBuffer(0),100*app.getNamespacesUseRatio());
		s6 = szEmpty;
		h.Output(ss1,s1,s2,s3,s4,s5,s6, TRUE);	

		s = szEmpty + szEmpty;

		long i;
		long nSize = namecoll.GetSize();
		for (i=0;i<nSize;i++)
		{
			if(i>0)
				s += ", ";
	
			String *st = namecoll.GetAt(i);
			if (st)
			{
				s += st->GetData();
				s += ":"; // for decoration...
			}
		}

		s1 = "_NamespacesList";
		s2.LoadString(IDS_REPORTHNAMESPACESLIST);
		s3 = szEmpty;
		s4.LoadString(IDS_REPORTNAMESPACESLIST);
		s5 = s;
		s6 = szEmpty;
		h.Output(ss2,s1,s2,s3,s4,s5,s6);	

		namecoll.Destroy();
	}
	else
	{
		s1 = "_NamespacesRatio";
		s2.LoadString(IDS_REPORTHNAMESPACES);
		s3 = szEmpty;
		s4.LoadString(IDS_REPORTNAMESPACES);
		s5.LoadString(IDS_REPORTNOTAVAILABLE);
		s6 = szEmpty;
		h.Output(ss1,s1,s2,s3,s4,s5,s6, TRUE);	

		s1 = "_NamespacesList";
		s2.LoadString(IDS_REPORTHNAMESPACESLIST);
		s3 = szEmpty;
		s4.LoadString(IDS_REPORTNAMESPACESLIST);
		s5.LoadString(IDS_REPORTNOTAVAILABLE);
		s6 = szEmpty;
		h.Output(ss2,s1,s2,s3,s4,s5,s6);	
	}

	s = "</table>";
	h.Output(s);


	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_CONTENT_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


	s = "<table width=\"687\" border=\"0\" class=\"dump\">";
	h.Output(s);
	s1 = "_ContentMin";
	s2.LoadString(IDS_REPORTHCONTENTMIN);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTCONTENTMIN);
	s5.Format(szBytes.GetBuffer(0),app.getMinContentLength());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6, TRUE);	

	s1 = "_ContentMax";
	s2.LoadString(IDS_REPORTHCONTENTMAX);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTCONTENTMAX);
	s5.Format(szBytes.GetBuffer(0),app.getMaxContentLength());
	s6 = szEmpty;
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	s1 = "_ContentMean";
	s2.LoadString(IDS_REPORTHCONTENTMEAN);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTCONTENTMEAN);
	s5.Format(szFloatBytes.GetBuffer(0),app.getMeanContentLength());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	

	s1 = "_ContentEmptyElement";
	s2.LoadString(IDS_REPORTHCONTENTEMPTYELEMENT);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTCONTENTEMPTYELEMENT);
	if (nbelements>0)
	{
		long nbEmptyElements = app.getNbEmptyElementTags();
		s5.Format("%ld / %ld",nbEmptyElements, nbelements);
		s.LoadString(IDS_REPORTPERCENT2);
		s6.Format(s.GetBuffer(0),100*double(nbEmptyElements)/nbelements);
	}
	else
	{
		s5.LoadString(IDS_REPORTNOTAVAILABLE);
		s6 = szEmpty;
	}
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	s1 = "_ContentEmptyAttribute";
	s2.LoadString(IDS_REPORTHCONTENTEMPTYATTRIBUTE);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTCONTENTEMPTYATTRIBUTE);
	long nbattributes = app.getStatsNbAttributes();
	if (nbattributes>0)
	{
		long nbEmptyAttributes = app.getNbEmptyAttributeTags();
		s5.Format("%ld / %ld",nbEmptyAttributes, nbattributes);
		s.LoadString(IDS_REPORTPERCENT2);
		s6.Format(s.GetBuffer(0),100*double(nbEmptyAttributes)/nbattributes);
	}
	else
	{
		s5.LoadString(IDS_REPORTNOTAVAILABLE);
		s6 = szEmpty;
	}
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	

	s1 = "_ContentMultipleParts";
	s2.LoadString(IDS_REPORTHCONTENTMULTIPLEPARTS);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTCONTENTMULTIPLEPARTS);
	double nbMultiplePartsValuesRatio = 100*app.getMultiplePartValuesRatio();
	if (nbMultiplePartsValuesRatio<0.1)
		s6 = szEmpty;
	else if (nbMultiplePartsValuesRatio<10.0)
		s6.LoadString(IDS_REPORTCONTENTMULTIPLEPARTS_NOTSIGNIF);//(not significant)
	else if (nbMultiplePartsValuesRatio>=10.0 && nbMultiplePartsValuesRatio<30.0)
		s6.LoadString(IDS_REPORTCONTENTMULTIPLEPARTS_SIGNIF);//(significant)
	else if (nbMultiplePartsValuesRatio>=30.0)
		s6.LoadString(IDS_REPORTCONTENTMULTIPLEPARTS_QUESTIONA);//(questionable)

	s5.Format(szPercent.GetBuffer(0),nbMultiplePartsValuesRatio);
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	


	s = "</table>";
	h.Output(s);



	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_CONTENT_CORRELATION_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}


	s = "<table width=\"687\" border=\"0\" class=\"dump\">";
	h.Output(s);
	s1 = "_ContentDuplicationMax";
	s2.LoadString(IDS_REPORTHDUPLICATIONMAX);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTDUPLICATIONMAX);
	s5.Format(szPercent.GetBuffer(0),100*app.getMaxDuplicate());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6, TRUE);	

	s1 = "_ContentDuplicationMean";
	s2.LoadString(IDS_REPORTHDUPLICATIONMEAN);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTDUPLICATIONMEAN);
	double nbMeanDuplicate = 100*app.getMeanDuplicate();
	s5.Format(szPercent.GetBuffer(0),nbMeanDuplicate);
	s6 = szEmpty;
	if (nbMeanDuplicate<10.0)
		s6.LoadString(IDS_REPORTDUPLICATIONLOW);//(content is highly uncorrelated)
	else if (nbMeanDuplicate>=10.0 && nbMeanDuplicate<20.0)
		s6.LoadString(IDS_REPORTDUPLICATIONAVG);//(content is somewhat uncorrelated)
	else if (nbMeanDuplicate>=20.0 && nbMeanDuplicate<35.0)
		s6.LoadString(IDS_REPORTDUPLICATIONGOOD);//(content is somewhat correlated)
	else if (nbMeanDuplicate>=35.0 && nbMeanDuplicate<50.0)
		s6.LoadString(IDS_REPORTDUPLICATIONHIGH);//(content is correlated)
	else if (nbMeanDuplicate>=50.0)
		s6.LoadString(IDS_REPORTDUPLICATIONVERYHIGH);//(content is highly correlated)
	h.Output(ss2,s1,s2,s3,s4,s5,s6);	

	s1 = "_ContentDuplicationStdDev";
	s2.LoadString(IDS_REPORTHDUPLICATIONSTDDEV);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTDUPLICATIONSTDDEV);
	s5.Format(szFloat.GetBuffer(0),100*app.getStdDevDuplicate());
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	

	s1 = "_ContentDuplication";
	s2.LoadString(IDS_REPORTHDUPLICATIONMOST);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTDUPLICATIONMOST);

	if ( 100*app.getMaxDuplicate()>30.0) // at least 30% in one of the LOV is a threshold for us to show anything relevant
	{
		s5 = szEmpty;

		XmlArrayString stringcoll;
		app.getTopDuplicateValues(0,stringcoll);
		if (stringcoll.GetSize()>0)
		{
			String *sa = stringcoll.GetAt(0);
			if (sa)
				s5.Format("\"%s\"",sa->GetData());
		}
		stringcoll.Destroy();
		s6 = szEmpty;
		h.Output(ss2,s1,s2,s3,s4,s5,s6);	
	}



	s = "</table>";
	h.Output(s);


	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_CONTENT_SPACING_HDR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}



	s = "<table width=\"687\" border=\"0\" class=\"dump\">";
	h.Output(s);
	s1 = "_ContentSpacingIndentation";
	s2.LoadString(IDS_REPORTHINDENTATIONSIZE);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTINDENTATIONSIZE);
	long nbIndentation = app.getIndentationSize();
	s5.Format(szBytes.GetBuffer(0), nbIndentation);
	s6 = szEmpty;
	if (nbIndentation>0.1 && nStreamLength>0)
	{
		s.LoadString(IDS_REPORTPERCENTOVERALLSTREAM);
		s6.Format(s.GetBuffer(0), 100*double(nbIndentation)/nStreamLength);
	}
	h.Output(ss1,s1,s2,s3,s4,s5,s6, TRUE);	

	if (nbIndentation>0.1 && nStreamLength>0)
	{
		s1 = "_ContentSpacingIndentationGain";
		s2.LoadString(IDS_REPORTHINDENTATIONGAIN);
		s3 = szEmpty;
		s4.LoadString(IDS_REPORTINDENTATIONGAIN);
		s5.Format(szPercent.GetBuffer(0), 100*double(nbIndentation)/nStreamLength);
		s6 = szEmpty;
		h.Output(ss2,s1,s2,s3,s4,s5,s6);	
	}

	s1 = "_ContentSpacingWhites";
	s2.LoadString(IDS_REPORTHWHITESPACES);
	s3 = szEmpty;
	s4.LoadString(IDS_REPORTWHITESPACES);
	s5 = szEmpty;
	BOOL bSignificantWhiteSpaces = app.getNbMultipleSpaces() > ( nStreamLength*1/100 ); // exceeds 1% of total stream size
	if (bSignificantWhiteSpaces)
		s.Format(szBytes.GetBuffer(0), app.getNbMultipleSpaces());
	else
		s.LoadString(IDS_REPORTWHITESPACES_NONE);//not significant
	s5 += s;
	s6 = szEmpty;
	h.Output(ss1,s1,s2,s3,s4,s5,s6);	


	s = "</table>";
	h.Output(s);




	hHtmlRes = ::FindResource( NULL, MAKEINTRESOURCE(IDR_REPORT_FTR), RT_HTML);
	if (!hHtmlRes) { TRACE("missing template mate\n"); return; } // stop here if there is a missing template
	nHtmlSize = ::SizeofResource( NULL, hHtmlRes);
	hFile = ::LoadResource( NULL, hHtmlRes);
	if (hFile) {
		char *ptr = (char*) ::LockResource(hFile);
		h.Output(ptr, nHtmlSize);
		::FreeResource(hFile);
	}







}



void CBetterxmlApp::showMostSeenPattern(HTMLWriter &h, IXmlNode *p, long nCurDepth)
{
	if (!p)
		return;

	char szTemp[MAX_PATH];
	char szT[MAX_PATH]="";

	CElement *pElement = (CElement *)p;

	// add contribution of this element
	BOOL bIsMostSeen = p->isMostSeen();
	if ( bIsMostSeen )
	{
		szTemp[0]='\0';
		for (long i=0;i<nCurDepth;i++) // indent <...> tag
			strcat(szTemp," ");
		strcat(szT,szTemp);

		sprintf(szTemp,"&lt;%s", p->getName());
		strcat(szT,szTemp);
		if (p->getDatatype()!=SAXML_DATATYPE_STRING)
		{
			strcat(szT,"(=");
			strcat(szT,p->getDatatypeAsString());
			strcat(szT,")");
		}
	}

	// process all attributes
	//
	long nAttributes = pElement->getAttributes().GetSize();
	for (long j=0; j<nAttributes; j++)
	{
		CAttribute *pAttribute = (CAttribute *) pElement->getAttributes().GetAt(j);
		if (pAttribute && bIsMostSeen)
		{
			sprintf(szTemp," %s", pAttribute->getName());
			strcat(szT,szTemp);
			if (pAttribute->getDatatype()!=SAXML_DATATYPE_STRING)
			{
				strcat(szT,"(=");
				strcat(szT,pAttribute->getDatatypeAsString());
				strcat(szT,")");
			}

		}
	} // end process all attributes

	if ( bIsMostSeen )
	{
		sprintf(szTemp,"&gt;\n"); // close tag
		strcat(szT,szTemp);
		h.Output(szT);
	}

	// then process all direct element children
	//
	int nChildElementsSize = pElement->getChildrenSize();
	for (int k=0; k<nChildElementsSize; k++)
	{
		CElement *pChildElement = pElement->getChildrenElement(k);
		if (pChildElement)
			showMostSeenPattern(h, pChildElement,nCurDepth+1);
	}

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Addicted to reverse engineering. At work, I am developing business intelligence software in a team of smart people (independent software vendor).

Need a fast Excel generation component? Try xlsgen.


You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160811.3 | Last Updated 12 Sep 2002
Article Copyright 2002 by Stephane Rodriguez.
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid