Name

lxconvert, lxconvertn — Convert data between XML and other formats, using XSLT-style templates

Synopsis

lxconvert -w [ -v ] [ -p param value ...] -q item-query -s stylesheet [ xml-file ]

lxconvert -r [ -v ] [ -p param value ...] -q item-query -s stylesheet -x xml-file [ text-file ]

Description

lxconvert is program for converting data from and to XML for use by non-XML programs. XSLT-style templates are used to specify the conversion. The conversion direction is specified by the -w/-r option. -w converts XML to text and writes it to the non-XML program; -r reads from the non-XML program and converts text to XML.

The xml-file argument may be a URI instead of a filenames. If no xml-file argument is given in the -w case, or no text-file argument in the -r case, standard input is used.

-v

verbose output; various warnings are given which would usually be considered unimportant. These are mostly cases where the XSLT spec allows for error recovery, such as multiple templates with equal priority.

-p param value

assign a value to an XSLT parameter. Only string values are allowed.

-q item-query

an XPath query identifying the nodes in the document to be converted. This might for example select elements whose text values are words, which will be processed by a program that expects one word per line.

-s stylesheet

an XSLT stylesheet containing templates to be used in converting between XML and text formats. Templates should be provided for read and write modes, as described below.

-w

write data to a non-XML program. In this case, each node in the XML input document that matches the item-query has templates applied to it, as if by <xsl:apply-templates mode="write" select="item-query"/> . The template should extract the relevant text from the node and output it in the format required by the non-XML program. Output is in text mode by default.

-r

read data from a non-XML program. In this case, each node in the XML input document that matches the item-query has templates applied to it, as if by <xsl:apply-templates mode="read" select="item-query"/> . The template should use the function read-line() (see below) to receive a line of input from the non-XML program, and use it to construct the new version of the node (for example, by adding attributes to an element).

functions

read-line()

reads the next line from the text file, splitting it at whitespace into a set of text nodes. If, for example, the resulting node-set is assigned to a variable line, the fields can then be accessed as $line[1], $line[2], ...

Example

There should be some examples here!

Bugs

There should be more functions provided for handling the non-XML input.