Convert to XML on the fly

xmlfy 1.5

The xmlfy command is a powerful yet lightweight tool that primarily caters for converting ASCII, UTF-8, UTF-16 or UTF-32 based output into XML format on the fly and dealing with common issues associated with this kind of transformation. xmlfy can be invoked from the command line or from within a shell script to transform data quickly, easily and reliably.

xmlfy provides many features and options to capture and encapsulate data between XML tags for both simple and complex XML tree hierarchies. The behaviour of xmlfy is controlled by arguments and/or by specifying a schema file providing high levels of flexibility and customisation for differing input scenarios.

The xmlfy command reads unprocessed stdin and outputs it to stdout in XML format.
How it works

The simplest way of using xmlfy is described by the following example:

% ps | xmlfy
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xmlfy SYSTEM "xmlfy.dtd">
<xmlfy>
  <line>
    <field>PID</field>
    <field>PPID</field>
    <field>TTY</field>
    <field>UID</field>
    <field>STIME</field>
    <field>COMMAND</field>
  </line>
  <line>
    <field>1708</field>
    <field>1</field>
    <field>con</field>
    <field>1003</field>
    <field>23:18:31</field>
    <field>/usr/bin/bash</field>
  </line>
  <line>
    <field>1760</field>
    <field>1708</field>
    <field>con</field>
    <field>1003</field>
    <field>23:20:08</field>
    <field>/usr/bin/ps</field>
  </line>
</xmlfy>

A more sophisticated use of xmlfy is described by the following example:

% xmlfy -k -F2:1 : -E 'c1-1/#/' -T0 name a2ps-site-cfg -t < /etc/a2ps-site.cfg
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE a2ps-site-cfg SYSTEM "xmlfy.dtd">
<a2ps-site-cfg>
  <Options>--encoding=latin1</Options>
  <Options>--medium=A4</Options>
  <DefaultPPD>level1</DefaultPPD>
  <DefaultPrinter>¦ #{lp.default}</DefaultPrinter>
  <UnknownPrinter>¦ #{lp} #o</UnknownPrinter>
</a2ps-site-cfg>

With the increasing presence of object-oriented systems requiring well structured data presentation, xmlfy allows you to convert your raw data into XML format easily which can then be used as input for modern object-oriented systems e.g. XML style sheets (XSLT).

xmlfy is predominantly written to alleviate the need for writing custom scripts for this purpose and to produce consistent outcomes in dealing with this kind of transformation problem.

You can download xmlfy from here.

Enjoy,
Arthur Gouros, xmlfy founder, 2008.