--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/relpipe-data/examples-in-xmltable-ssm-gui.xml Sun Oct 06 11:24:40 2019 +0200
@@ -0,0 +1,56 @@
+<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 "chapter" "(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>
+
+ </p>
+
+
+ </text>
+
+</stránka>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/relpipe-data/examples/ssm-xmltable-1.makefile Sun Oct 06 11:24:40 2019 +0200
@@ -0,0 +1,20 @@
+build/statistics.rp: text/ssm.en.xml
+ mkdir -p build
+ cat text/ssm.en.xml \
+ | relpipe-in-xmltable \
+ --namespace "m" "tag:globalcode.info,2019:sane-software/manifesto" \
+ --relation "chapter" \
+ --records "//m:chapter" \
+ --attribute "name" string "m:name" \
+ --attribute "requirements" integer "count(descendant::m:item[m:type='requirement'])" \
+ --attribute "recommendations" integer "count(descendant::m:item[m:type='recommendation'])" \
+ --attribute "informations" integer "count(descendant::m:item[m:type='information'])" \
+ --attribute "items_total" integer "count(descendant::m:item)" \
+ > build/statistics.rp
+
+# Prints a table with number of items in particular chapters:
+statistics: build/statistics.rp
+ cat build/statistics.rp | relpipe-out-tabular
+
+statistics-chart: build/statistics.rp
+ cat build/statistics.rp | relpipe-tr-cut ".*" "(name|.*s)" | relpipe-out-gui -title "Sane software manifesto – chart of rule types"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/relpipe-data/examples/ssm-xmltable-1.txt Sun Oct 06 11:24:40 2019 +0200
@@ -0,0 +1,22 @@
+chapter:
+ ╭─────────────────────────────────────────┬────────────────────────┬───────────────────────────┬────────────────────────┬───────────────────────╮
+ │ name (string) │ requirements (integer) │ recommendations (integer) │ informations (integer) │ items_total (integer) │
+ ├─────────────────────────────────────────┼────────────────────────┼───────────────────────────┼────────────────────────┼───────────────────────┤
+ │ Free software │ 5 │ 1 │ 1 │ 7 │
+ │ Documented │ 4 │ 0 │ 1 │ 5 │
+ │ Semantic versioning and upgrades │ 4 │ 2 │ 2 │ 8 │
+ │ Interfaces, formats and protocols │ 1 │ 3 │ 1 │ 5 │
+ │ Modular architecture and extensibility │ 2 │ 1 │ 1 │ 4 │
+ │ Testable │ 0 │ 4 │ 1 │ 5 │
+ │ Safe code and sustainability │ 2 │ 4 │ 0 │ 6 │
+ │ Small code footprint │ 0 │ 3 │ 0 │ 3 │
+ │ Sane dependencies │ 3 │ 7 │ 0 │ 10 │
+ │ Easily auditable │ 0 │ 2 │ 1 │ 3 │
+ │ Reproducible builds │ 1 │ 1 │ 0 │ 2 │
+ │ Trustworthy packages and sources │ 2 │ 4 │ 0 │ 6 │
+ │ Network interactions │ 4 │ 0 │ 0 │ 4 │
+ │ Internationalization and localization │ 7 │ 5 │ 0 │ 12 │
+ │ Communication with users and developers │ 5 │ 5 │ 0 │ 10 │
+ │ Accept contributions │ 5 │ 3 │ 5 │ 13 │
+ ╰─────────────────────────────────────────┴────────────────────────┴───────────────────────────┴────────────────────────┴───────────────────────╯
+Record count: 16
Binary file relpipe-data/img/sane-software-statistics-chart-1.png has changed