examples: relpipe-out-xml v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 06 Dec 2018 17:11:29 +0100
branchv_0
changeset 187 c952261978e8
parent 186 e33f13c91289
child 188 5b0fab48d59e
examples: relpipe-out-xml
relpipe-data/examples.xml
--- a/relpipe-data/examples.xml	Thu Dec 06 16:15:53 2018 +0100
+++ b/relpipe-data/examples.xml	Thu Dec 06 17:11:29 2018 +0100
@@ -157,6 +157,82 @@
 			n.b. the <code>relpipe-in-fstab</code> reads the <code>/etc/fstab</code> if executed on TTY. Otherwise, it reads the STDIN.
 		</p>
 		
+		<h3>relpipe-out-xml</h3>
+		
+		<p>
+			Relational data can be converted to various formats and one of them is the XML.
+			This is a good option for further processing e.g. using XSLT transformation or passing the XML data to some other tool.
+			Just use <code>relpipe-out-xml</code> instead of <code>relpipe-out-tabular</code> and the rest of the pipeline remains unchanged:
+		</p>
+		
+		<m:pre jazyk="bash"><![CDATA[ssh example.com cat /etc/mtab | relpipe-in-fstab | relpipe-out-xml]]></m:pre>
+		
+		<p>
+			Will produce XML like this:
+		</p>
+		
+		<m:pre jazyk="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<pipe>
+	<relation>
+		<name>fstab</name>
+		<record>
+			<attribute>UUID</attribute>
+			<attribute>29758270-fd25-4a6c-a7bb-9a18302816af</attribute>
+			<attribute>/</attribute>
+			<attribute>ext4</attribute>
+			<attribute>relatime,user_xattr,errors=remount-ro</attribute>
+			<attribute>0</attribute>
+			<attribute>1</attribute>
+		</record>
+		<record>
+			<attribute></attribute>
+			<attribute>/dev/sr0</attribute>
+			<attribute>/media/cdrom0</attribute>
+			<attribute>udf,iso9660</attribute>
+			<attribute>user,noauto</attribute>
+			<attribute>0</attribute>
+			<attribute>0</attribute>
+		</record>
+		<record>
+			<attribute></attribute>
+			<attribute>/dev/sde</attribute>
+			<attribute>/mnt/data</attribute>
+			<attribute>ext4</attribute>
+			<attribute>relatime,user_xattr,errors=remount-ro</attribute>
+			<attribute>0</attribute>
+			<attribute>2</attribute>
+		</record>
+		<record>
+			<attribute>UUID</attribute>
+			<attribute>a2b5f230-a795-4f6f-a39b-9b57686c86d5</attribute>
+			<attribute>/home</attribute>
+			<attribute>btrfs</attribute>
+			<attribute>relatime</attribute>
+			<attribute>0</attribute>
+			<attribute>2</attribute>
+		</record>
+		<record>
+			<attribute></attribute>
+			<attribute>/dev/mapper/sdf_crypt</attribute>
+			<attribute>/mnt/private</attribute>
+			<attribute>xfs</attribute>
+			<attribute>relatime</attribute>
+			<attribute>0</attribute>
+			<attribute>2</attribute>
+		</record>
+	</relation>
+</pipe>]]></m:pre>
+
+		<p>
+			Thanks to XSLT, this XML can be easily converted e.g. to an XHTML table (<code>table|tr|td</code>) or other format.
+			Someone can convert such data to a (La)TeX table.
+		</p>
+		
+		<p>
+			n.b. the format is not final and will change i future versions (XML namespace, more metadata etc.).
+		</p>
+		
+		
 		<h3>relpipe-tr-validator</h3>
 		
 		<p>