XML-ECHO(1)

NAME
xml-echo - generate an XML file on the standard output.

SYNOPSIS

xml-echo [OPTION]... [STRING]...

DESCRIPTION

xml-echo prints the STRING(s) to the standard output as an XML file.

If the -e switch is used, then each STRING is interpreted as a concatenated sequence of echo-leaves "[PATH]TEXT" as described in xml-coreutils (7). Otherwise, the STRING(s) are printed as a list that is merely surrounded by a pair of root tags.

When using the -e switch, xml-echo builds the output XML file one node at a time in order of the supplied echo-leaves, opening and closing tags automatically as necessary to ensure that the output is well formed XML.

The name of the root tag is inferred from the PATH component of the first echo-leaf. If the first echo-leaf is "TEXT", then a default root tag is chosen. It is an error to subsequently refer to a different root tag.

Line breaks and indenting are automatic after each PATH and after each TEXT. The -n switch prevents this behaviour.

If the -e switch is used, the following escape sequences in TEXT are also recognized:

\\  backslash

\n  line break and (maybe) indent following.

\t  horizontal tab.

\b  backspace.

\I  do not indent following elements whose depth is greater than the current depth.

\i  indent following elements to their proper depth, with immediate effect (default).

\C  end of comment.

\c  write following as a comment, until \C is seen or the document ends. No path fragments which occur within a comment are expanded.

\Q  quote following as CDATA, until \q is seen or the tag context changes. Characters prohibited by XML can be freely printed.

\q  explicitly close CDATA if open. Characters prohibited by XML are converted to entities (default).

A processing instruction is generated by a string of the form "[?TARGET DATA]". This cannot be confused with a path, since it starts with a '?'. The DATA substring can contain attribute/value pairs as in a PATH. The TARGET must not begin with the string "xml".

OPTIONS

-n  do not output line breaks automatically.

-e  enable interpretation of echo-leaves and backslash escapes in text.

-E  disable interpretation of echo-leaves and backslash escapes (default).

--path-separator CHAR
    use CHAR instead of '/' as the PATH tag separator inside []. This is not recommended in general, but can be convenient if the attribute values contain many slashes, which would otherwise have to be escaped.

EXIT STATUS
xml-echo returns 0 on successful creation of a well formed XML file. If the STRING(s) result in a broken XML file, then the command is aborted immediately and 1 is returned.

EXAMPLE
    xml-echo -e "[greeting@mood=jovial]hello \c[name]Joe"

BUGS

Currently, there is no direct support for doctypes due to their complexity. A doctype declaration can be added using sed (1), for example:
    xml-echo hello | sed '1a<!DOCTYPE xyz SYSTEM "uvw">'

AUTHORS

Laird A. Breyer (laird@lbreyer.com) is the original author of this software. The source code (GPLv3 or later) for the latest version is available at the following locations:

http://www.lbreyer.com/gpl.html
http://xml-coreutils.sourceforge.net

SEE ALSO

xml-coreutils(7)