relpipe-data/examples/xhtml-table-sql-statistics.sh
author František Kučera <franta-hg@frantovo.cz>
Wed, 30 Oct 2019 18:05:46 +0100
branchv_0
changeset 282 ec02133045a3
parent 268 1b8576c9640c
permissions -rwxr-xr-x
Release v0.14 – SQL, AWK, Bash completion, GPLv3

#!/bin/bash

URL="https://relational-pipes.globalcode.info/v_0/implementation.xhtml";

# or we can use wget, if curl is missing or we like wget more:
# curl() { wget -O - "$1"; }

curl "$URL" \
	| relpipe-in-xmltable \
		--namespace "h" "http://www.w3.org/1999/xhtml" \
		--relation "implementation" \
			--records "//h:table[1]/h:tbody/h:tr" \
			--attribute "name"     string "h:td[1]" \
			--attribute "type"     string "h:td[2]" \
			--attribute "subtype"  string "h:td[3]" \
	| relpipe-tr-sql \
		--relation \
			"relpipe_commands" \
			"SELECT
				subtype AS type,
				count(*) AS count
			FROM implementation
			WHERE type = 'executable'
			GROUP BY type, subtype
			ORDER BY count DESC" \
	| relpipe-out-tabular