# HG changeset patch # User František Kučera # Date 1570353880 -7200 # Node ID a19312ab9db73c1349a090336690790969c778f7 # Parent e6bac9ff0d8788eecffe1a217755c6be6c07a960 examples: Sane software manifesto statistics using XMLTable/XPath diff -r e6bac9ff0d87 -r a19312ab9db7 relpipe-data/examples-in-xmltable-ssm-gui.xml --- /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 @@ + + + Generating statistics and charts using XMLTable + read a XML file and get a visual overview + 03100 + + + +

+ We are currently finalizing guidelines called Sane software manifesto + (sources). + 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 commands from the Makefile: +

+ + + +

+ The first Makefile target stores relational data in the file statistics.rp (which is re/generated only if ssm.en.xml has been changed). + And then this file is used twice: for terminal output using relpipe-out-tabular and for visual output with a chart using relpipe-out-gui. +

+ +

+ The relpipe-in-xmltable simply counts items (requirements, recommendations, informations, totals) in each chapter using XPath expressions. + So we can see how heavy and strict particular chapters are: +

+ + + + +

+ However – for such data – much better than a table is a chart. + So we pipe the raw relational data prepared in the build/statistics.rp to the relpipe-out-gui command. + But because this tool counts totals itself and stacks the values in the bar chart, + we remove the items_total attribute from the relation using relpipe-tr-cut transformation. + Thanks to regular expressions, it is very concise. But of course, we can make it more explicit: +

+ + + +

We also set the window title (using the -title Qt option) and get the chart:

+ + + +

+ +

+ + +
+ +
\ No newline at end of file diff -r e6bac9ff0d87 -r a19312ab9db7 relpipe-data/examples/ssm-xmltable-1.makefile --- /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" diff -r e6bac9ff0d87 -r a19312ab9db7 relpipe-data/examples/ssm-xmltable-1.txt --- /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 diff -r e6bac9ff0d87 -r a19312ab9db7 relpipe-data/img/sane-software-statistics-chart-1.png Binary file relpipe-data/img/sane-software-statistics-chart-1.png has changed