I search for an option to transform xml-files. Now i had found antlr4 and I ask me it is possible to write a Parser for xml-files? What I want is to read a xml-file in my program. Than I want to analyse the format of the file and than I want to restructure it. Is it possible? This example demonstrate my Question:
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1">
<xmi:Documentation exporter="MalteFalk" exporterVersion="1.0"/>
<person>
<personelement type="aaa">
<name value="Max" id="1"/>
<lastname value="Hampelmann" id="2"/>
</personelement>
<personelement type="bbb">
<name value="Hannes" id="3"/>
<lastname value="Mustermann" id="4"/>
</personelement>
</person>
<job>
<jobelement type="ccc">
<jobtitle value="barber"/>
<salary value="50000"/>
</jobelement>
<jobelement type="ddd">
<jobtitle value="doctor"/>
<salary value="100000"/>
</jobelement>
</job>
<relationship>
<relation1>
<source id="1"/>
<target id="ddd"/>
</relation1>
<relation2>
<source id="3"/>
<source id="ccc"/>
</relation2>
</relationship>
</xmi:XMI>
Now I want to read in this file in my parser and restructure it into this xml-file:
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1">
<xmi:Documentation exporter="XXX" exporterVersion="1.0"/>
<taggedvalues>
<tag type="Max">
<firstname value="Max"/>
<lastname value="Mustermann"/>
<jobtitle value="baber"/>
<salary value="50000"/>
</tag>
<tag type="Hannes">
<firstname value="Hannes"/>
<lastname value="Hampelmann"/>
<jobtitle value="doctor"/>
<salary value="100000"/>
</tag>
</taggedvalues>
</xmi:XMI>