<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>