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