---++ Summary Converts an ATerm to a comparable XML document. ---++ Description The tools [[ATermToXml][aterm2xml]] and [[XmlToATerm][xml2aterm]] support the conversion from ATerm to XML and vice versa. 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 (that is, 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 a [[https://svn.cs.uu.nl:12443/repos/StrategoXT/trunk/StrategoXT/xml-front/doc/very-explicit.rnc][RELAX NG schema]]. ---++ Future Work In a future release we will add support for a round trip in the implicit mode, based on schema/rtg information. This has already been implemented, but needs to be updated and refactored. ---++ Examples The following invocations illustrate how to invoke the tools:
$ aterm2xml -i foo.trm # convert to explicit xml $ aterm2xml -i foo.trm | xml2aterm # convert to explicit xml and back $ aterm2xml -i foo.trm --implicit # convert to implicit xml $ aterm2xml -i foo.trm --very-explicit # convert to very explicit xml
The following tables explain the differences between the three explicity modes that are support by aterm2xml. ---+++ Explicit XML
ATerm Explicit XML Back to ATerm
foo foo
foo(1) 1 foo(1)
1 1 1
"abc" abc "abc"
() ()
(1, 2) 1 2 (1,2)
[] []
[1, 2] 1 2 [1,2]
fred([foo, bar]) fred([foo,bar])
fred(None, [foo, bar]) fred(None,[foo,bar])
fred(Some(barney), [foo, bar]) fred(Some(barney),[foo,bar])
fred("foo", "bar") foo bar fred("foo","bar")
foo{fred} foo{fred}
---+++ Very Explicit XML
ATerm Very Explicit XML Back to ATerm
foo foo
foo(1) 1 foo(1)
1 1 1
"abc" abc "abc"
() ()
(1, 2) 1 2 (1,2)
[] []
[1, 2] 1 2 [1,2]
fred([foo, bar]) fred([foo,bar])
fred(None, [foo, bar]) fred(None,[foo,bar])
fred(Some(barney), [foo, bar]) fred(Some(barney),[foo,bar])
fred("foo", "bar") foo bar fred("foo","bar")
foo{fred} foo{fred}
---+++ Implicit XML
ATerm Implicit XML Back to ATerm
foo foo
foo(1) 1 foo("1")
1 not possible not possible
"abc" not possible not possible
() not possible not possible
(1, 2) not possible not possible
[] not possible not possible
[1, 2] not possible not possible
fred([foo, bar]) fred(foo,bar)
fred(None, [foo, bar]) fred(foo,bar)
fred(Some(barney), [foo, bar]) fred(barney,foo,bar)
fred("foo", "bar") foobar fred("foobar")
foo{fred} foo{fred}