relpipe-data/examples-in-xmltable-ssm-gui.xml
author František Kučera <franta-hg@frantovo.cz>
Mon, 21 Feb 2022 01:21:22 +0100
branchv_0
changeset 330 70e7eb578cfa
parent 326 ab7f333f1225
permissions -rw-r--r--
Added tag relpipe-v0.18 for changeset 5bc2bb8b7946

<stránka
	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
	
	<nadpis>Generating statistics and charts using XMLTable</nadpis>
	<perex>read a XML file and get a visual overview</perex>
	<m:pořadí-příkladu>03100</m:pořadí-příkladu>

	<text xmlns="http://www.w3.org/1999/xhtml">
		
		<p>
			We are currently finalizing guidelines called <a href="https://sane-software.globalcode.info/">Sane software manifesto</a> 
			(<a href="https://hg.globalcode.info/sane-software/sane-software-manifesto/">sources</a>).
			This document consists of chapters and items. An item might be a requirement, a recommendation or an information.
			In order to get a high-level overview, we generate statistics showing the counts of items of forementioned types in particular chapters.
			Whole document is built using GNU Make, so we call also <m:name/> commands from the Makefile:
		</p>
		
		<m:pre jazyk="makefile" src="examples/ssm-xmltable-1.makefile"/>

		<p>
			The first Makefile target stores relational data in the file <code>statistics.rp</code> (which is re/generated only if <code>ssm.en.xml</code> has been changed).
			And then this file is used twice: for terminal output using <code>relpipe-out-tabular</code> and for visual output with a chart using <code>relpipe-out-gui</code>.
		</p>
		
		<p>
			The <code>relpipe-in-xmltable</code> simply counts items (requirements, recommendations, informations, totals) in each chapter using XPath expressions.
			So we can see how <em>heavy</em> and strict particular chapters are:
		</p>
		
		<m:pre jazyk="text" src="examples/ssm-xmltable-1.txt"/>
		
		
		<p>
			However – for such data – much better than a table is a chart.
			So we pipe the raw relational data prepared in the <code>build/statistics.rp</code> to the <code>relpipe-out-gui</code> command.
			But because this tool counts totals itself and stacks the values in the bar chart,
			we remove the <code>items_total</code> attribute from the relation using <code>relpipe-tr-cut</code> transformation.
			Thanks to regular expressions, it is very concise. But of course, we can make it more explicit:
		</p>
		
		<m:pre jazyk="bash"><![CDATA[relpipe-tr-cut --relation "chapter" --attribute "(name|requirements|recommendations|informations)"
#            relation name ^                     ^ attribute names to be passed through (others are filtered out)]]></m:pre>
		
		<p>We also set the window title (using the <code>-title</code> Qt option) and get the chart:</p>
		
		<m:img src="img/sane-software-statistics-chart-1.png"/>
		
		<p>
			Using these tools we can get statistics and charts from any XML or other supported format like CSV, Recfile or a <a href="https://sql-dk.globalcode.info/">database</a>.
			We can also do advanced computations using SQL, Guile or AWK before piping the data to the GUI.
		</p>

		
	</text>

</stránka>