relpipe-data/examples/xhtml-table-sql-statistics.sh
author František Kučera <franta-hg@frantovo.cz>
Tue, 27 Aug 2019 13:50:37 +0200
branchv_0
changeset 268 1b8576c9640c
permissions -rwxr-xr-x
examples: XHTML table processing in SQL

#!/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