|
1 <stránka |
|
2 xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana" |
|
3 xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"> |
|
4 |
|
5 <nadpis>Generating statistics and charts using XMLTable</nadpis> |
|
6 <perex>read a XML file and get a visual overview</perex> |
|
7 <m:pořadí-příkladu>03100</m:pořadí-příkladu> |
|
8 |
|
9 <text xmlns="http://www.w3.org/1999/xhtml"> |
|
10 |
|
11 <p> |
|
12 We are currently finalizing guidelines called <a href="https://sane-software.globalcode.info/">Sane software manifesto</a> |
|
13 (<a href="https://hg.globalcode.info/sane-software/sane-software-manifesto/">sources</a>). |
|
14 This document consists of chapters and items. An item might be a requirement, a recommendation or an information. |
|
15 In order to get a high-level overview, we generate statistics showing the counts of items of forementioned types in particular chapters. |
|
16 Whole document is built using GNU Make, so we call also <m:name/> commands from the Makefile: |
|
17 </p> |
|
18 |
|
19 <m:pre jazyk="makefile" src="examples/ssm-xmltable-1.makefile"/> |
|
20 |
|
21 <p> |
|
22 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). |
|
23 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>. |
|
24 </p> |
|
25 |
|
26 <p> |
|
27 The <code>relpipe-in-xmltable</code> simply counts items (requirements, recommendations, informations, totals) in each chapter using XPath expressions. |
|
28 So we can see how <em>heavy</em> and strict particular chapters are: |
|
29 </p> |
|
30 |
|
31 <m:pre jazyk="text" src="examples/ssm-xmltable-1.txt"/> |
|
32 |
|
33 |
|
34 <p> |
|
35 However – for such data – much better than a table is a chart. |
|
36 So we pipe the raw relational data prepared in the <code>build/statistics.rp</code> to the <code>relpipe-out-gui</code> command. |
|
37 But because this tool counts totals itself and stacks the values in the bar chart, |
|
38 we remove the <code>items_total</code> attribute from the relation using <code>relpipe-tr-cut</code> transformation. |
|
39 Thanks to regular expressions, it is very concise. But of course, we can make it more explicit: |
|
40 </p> |
|
41 |
|
42 <m:pre jazyk="bash"><![CDATA[relpipe-tr-cut "chapter" "(name|requirements|recommendations|informations)" |
|
43 # relation name ^ ^ attribute names to be passed through (others are filtered out)]]></m:pre> |
|
44 |
|
45 <p>We also set the window title (using the <code>-title</code> Qt option) and get the chart:</p> |
|
46 |
|
47 <m:img src="img/sane-software-statistics-chart-1.png"/> |
|
48 |
|
49 <p> |
|
50 |
|
51 </p> |
|
52 |
|
53 |
|
54 </text> |
|
55 |
|
56 </stránka> |