Name

xml2aterm — converts an XML document to a comparable ATerm.

Synopsis

xml2aterm [--explicit] [--very-explicit] [--implicit] [-i f | --input f] [-o f | --output f] [-b] [-S | --silent] [--verbose int] [-k int | --keep int] [-h | -? | --help] [--about] [--version]

Description

The xml2aterm utility is used to convert an XML document to a corresponding ATerm. The ATerm and XML languages are slightly different, so there is a tradeoff between how "natural" the result of the conversion feels and how faithfully it can be converted back into XML.

Since applications have different needs, there are three conversion modes available: implicit, explicit, and very explicit.

The explicit mode is the default mode and supports a roundtrip for almost all ATerms. This means that an ATerm can be converted to XML and back without changing its structure.

The implicit mode does not support such a roundtrip, but the XML is usually more attractive. Use this mode if you only want to export some ATerm to an XML application. The name 'implicit' is related to the more implicit structure in the resulting XML.

The very explicit mode supports a roundtrip for all ATerms. This mode is the way to go if you need the guarantee that a roundtrip preserves the structure of all your ATerms.

The structure of the XML documents in the very explicit mode is generic: there are no language specific elements in these XML documents. The structure is described as a RELAX NG schema.

Options

XML Processing Options

--explicit

Do conversion in explicit mode. This is the default. See below for details.

--very-explicit

Do conversion in very explicit mode. See below for details.

--implicit

Do conversion in implicit mode. See below for details.

Common Input/Output Options

-i file

The input term given by the file name file.

In the absence of the -i option, input will be read from stdin.

-o file

The output will be written to the file given by the file name file.

In the absence of the -o option, output will be written to stdout.

-b

The output will be written in the binary (BAF) ATerm format.

ATerms in the BAF format require a lot less space than ones in the TAF format, but the Java ATerm library does not currently support baf ATerms. ATerms in the baf format is the preferred format of exchange between Stratego tools.

Common Debugging Options

--about

See --version.

-h, -?, --help

Display usage information.

--keep int

Keep intermediate results produced by the internal stages in the pretty-printing process. This is only useful for debugging. A high value of int indicates increased eagerness for keeping intermediate results.

Default setting is 0, indicating that no intermediates will be kept.

-S, --silent

Silent execution. Same as --verbose 0.

--verbose int

Set verbosity level to numerical value int. The higher the number, the more information about pp-aterm's inner workings are printed.

Alternatively, int can be set to either of the following verbosity levels, given in increasing order of verbosity: emergency, alert, critical, error, warning, notice, info, debug, vomit.

--version

Displays the tool name and version.

Example

Consider the ATerm below.

fred(None, [foo, bar])
    

In the explicit mode, the corresponding XML would be:

<fred xmlns:at="http://aterm.org">
  <None/>
  <at:list>
    <foo/>
      <bar/>
  </at:list>
</fred>
    

In the very explicit mode, the corresponding XML would be:

<at:appl xmlns:at="http://aterm.org" at:fun="fred">
 <at:appl at:fun="None"/>
  <at:list>
   <at:appl at:fun="foo"/>
   <at:appl at:fun="bar"/>
 </at:list>
</at:appl>
    

In the implicit mode, the corresponding XML would be

<fred xmlns:at="http://aterm.org">
 <foo/>
 <bar/>
</fred>
    

The following terms cannot be encoded into XML in the implicit mode, but will work in either of the explicit noes.

1 "abc" () (1, 2) [] [1, 2] 
    

Invocation is straightforward:

$ xml2aterm --very-explicit -i tree.trm -o tree.xml

Reporting Bugs

Please report bugs to

Copyright

Copyright (C) 2002-2005 Eelco Visser

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.