relpipe-data/examples.xml
author František Kučera <franta-hg@frantovo.cz>
Tue, 05 Feb 2019 19:18:28 +0100
branchv_0
changeset 244 d4f401b5f90c
parent 241 f71d300205b7
permissions -rw-r--r--
examples: move each example to a separate page + add generated list of examples

<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>Examples</nadpis>
	<perex>Usage examples of Relational pipes tools</perex>
	<pořadí>40</pořadí>

	<text xmlns="http://www.w3.org/1999/xhtml">
		
		
		<p>
			All examples were tested in <a href="https://www.gnu.org/software/bash/">GNU Bash</a>.
			But they should also work in other shells.
		</p>
		
		<m:skript jazyk="bash" výstup="xhtml"><![CDATA[
			echo "<ul>";
			DIR=$(dirname "$XWG_STRANKA_SOUBOR");
			DIR="$DIR/../vstup"
			cd "$DIR";
			# TODO: use XQuery? (but Grep and Bash are everywhere)
			for f in examples-*.xml; do
				grep -oP '(?<=<m:pořadí-příkladu>).*(?=</m:pořadí-příkladu>)' $f | tr \\n ' '
				echo "<li><m:a href=\"${f//\.xml/}\">$(grep -oP '(?<=<nadpis>).*(?=</nadpis>)' $f)</m:a> – $(grep -oP '(?<=<perex>).+(?=</perex>)' $f)</li>";
			done | sort | sed -E 's/^[0-9]+ //'
			echo "</ul>";
		]]></m:skript>
		
	</text>

</stránka>