relpipe-data/examples-hello-world.xml
branchv_0
changeset 244 d4f401b5f90c
parent 241 f71d300205b7
child 317 fce3d6290c40
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/relpipe-data/examples-hello-world.xml	Tue Feb 05 19:18:28 2019 +0100
@@ -0,0 +1,83 @@
+<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>Hello Wordl!</nadpis>
+	<perex>generating relational data from CLI arguments</perex>
+	<m:pořadí-příkladu>00100</m:pořadí-příkladu>
+
+	<text xmlns="http://www.w3.org/1999/xhtml">
+		
+		<p>
+			Let's start with an obligatory Hello World example.
+		</p>
+		
+		<m:pre jazyk="bash"><![CDATA[relpipe-in-cli generate "relation_from_cli" 3 \
+	"a" "integer" \
+	"b" "string" \
+	"c" "boolean" \
+	"1" "Hello" "true" \
+	"2" "World!" "false"]]></m:pre>
+	
+		<p>
+			This command generates relational data.
+			In order to see them, we need to convert them to some other format.
+			For now, we will use the "tabular" format and pipe relational data to the <code>relpipe-out-tabular</code>.
+		</p>
+		
+		<m:pre jazyk="bash"><![CDATA[relpipe-in-cli generate "relation_from_cli" 3 \
+		"a" "integer" \
+		"b" "string" \
+		"c" "boolean" \
+		"1" "Hello" "true" \
+		"2" "World!" "false" \
+	| relpipe-out-tabular]]></m:pre>
+	
+		<p>Output:</p>
+
+		<pre><![CDATA[relation_from_cli:
+ ╭─────────────┬────────────┬─────────────╮
+ │ a (integer) │ b (string) │ c (boolean) │
+ ├─────────────┼────────────┼─────────────┤
+ │           1 │ Hello      │        true │
+ │           2 │ World!     │       false │
+ ╰─────────────┴────────────┴─────────────╯
+Record count: 2
+]]></pre>
+
+		<p>
+			The syntax is simple as we see above. We specify the name of the relation, number of attributes,
+			and then their definitions (names and types),
+			followed by the data.
+		</p>
+
+		<p>
+			A single stream may contain multiple relations:
+		</p>		
+		
+		<m:pre jazyk="bash"><![CDATA[(relpipe-in-cli generate a 1 x string hello; \
+ relpipe-in-cli generate b 1 y string world) \
+	| relpipe-out-tabular]]></m:pre>
+			
+		<p>
+			Thus we can combine various commands or files and pass the result to a single relational output filter (<code>relpipe-out-tabular</code> in this case) and get:
+		</p>
+		
+		<pre><![CDATA[a:
+ ╭────────────╮
+ │ x (string) │
+ ├────────────┤
+ │ hello      │
+ ╰────────────╯
+Record count: 1
+b:
+ ╭────────────╮
+ │ y (string) │
+ ├────────────┤
+ │ world      │
+ ╰────────────╯
+Record count: 1]]></pre>
+		
+	</text>
+
+</stránka>