1

Problem

Currently we are running software from Seeburger company to transform e.g Edifact to iDoc. Therefore a lot of mapping files exist to describe this transformation in a proprietary language SEEXML. It has a file ending xml but it has just a bunch of XML tags (name, NewMapping,sourceMessages, destinationMessage) and it's own language in this textline tags:

Now the goal is to:

  • transform this mapping into something else (Java/XSLT/own DSL/...)
  • execute the tranformation (e.g. EDI to iDoc) with new own mapping.

This is how a SEEXML mapping file looks like:

...
</textline>
   <textline>//Variables part start
</textline>
   <textline>
</textline>
   <textline>global UNB_TIME$;
</textline>
   <textline>global UNB_DATE$;
</textline>
   <textline>global SNDPOR$;
...
</textline>
   <textline>IF IsWorkFlowActive() = true
</textline>
   <textline>    Copy getInputValue("OWN.USER.ARCHIVE.SOURCE.FILE.IDENT") to ARCKEY$;
...
   <recordMapping>
    <fullname>UNB#1.UNH#1.G01#1.NAD#1</fullname>
    <textline>// fill buyer details
</textline>
    <textline>IF Trim(UNB.UNH.G01.NAD:3035) = "PE"
</textline>
    <textline>    Copy Trim(UNB.UNH.G01.NAD:C082.3039) to PE_PARTNER$;
...
 <destinationMessages>
  <destinationMessage kind="3">
   <name>EXAMPLE_DEST</name>
  </destinationMessage>
 </destinationMessages>
</mapping>

I have also a reference for this language (BIC Mapping Designer Command Reference) describing the commands like copy , trim and the path syntax (´UNB.UNH.G01.NAD:3035´)

Ideas

  • XSLT: First idea which cam into my mind was XSLT. Transformation of the mapping will be hard but execution is easy as there are frameworks for file transformation. Problem is here how to get this SEEXML to XSLT. Also for further adaptions XSLT is not that easy to master
  • Java: transform this mapping file to plain Java.

Questions

  • Any suggestions here beside parsing strings from SEEXML to java?
  • I would call this SEEXML a DSL.
    • Are there frameworks to describe the language and transfer it to Java later on?
    • Is ANTLR or JetBrains MPS capable of transforming the DSL to Java?
timguy
  • 2,063
  • 2
  • 21
  • 40
  • So, that language is some sort of hybrid between XML and a custom, more traditional looking one? And the XML part acts as some sort of pattern matching where in case the matching succeeds you apply the "inner" rules? – Ionuț G. Stan Jun 05 '23 at 11:10
  • yes right. They call it SEEXML but for me you could ommit all the XML stuff here with nearly everyline just "textline". – timguy Jun 05 '23 at 11:11
  • 2
    Then I guess you could write your own definition of ANTLR, or even a hand-crafted parser, that would parse that inner language to an in-memory representation. Having that you can either compile it to Java code, bytecode, or even interpret it directly. Does that make sense? Or am I maybe stating the obvious? – Ionuț G. Stan Jun 05 '23 at 11:13
  • no makes sense. I was just curious if ANTLR could translate this to pure java and after some point I could continue with just java after all mappings are transformed. Just don't know how much effort it is to create all that ANTLR definitions and than throw away after the mapping. – timguy Jun 05 '23 at 11:19
  • I know JavaCC better than ANTLR, but they're both parser generators. Neither is capable of generating Java per se though: you have to code that part. – Maurice Perry Jun 05 '23 at 11:35
  • I agree with what Maurice said. Adding the semantics is not something that's automated in any mainstream tool. You could either try ANTLR which provides some tools to help debug/develop the grammar and it will produce the parser, or write the parser yourself. Either way, for both approaches you'll have to sit down and figure out the grammar of that language (unless the company provides one). From that point on, you'll have to figure out how to traverse the tree-based representation of the parsed expressions and do the actual useful thing with it. – Ionuț G. Stan Jun 05 '23 at 11:41
  • Also, even if what I said above would be the proper™ way to do it, don't exclude the option of using regex to transform each line on its own to Java code. It might be very dirty, but since you only want to do this once, it might be acceptable. And any problematic cases, if they're rare enough, you could handle manually. – Ionuț G. Stan Jun 05 '23 at 11:45
  • thanks for the comments. Currently I also think introducing framework or parser here for this language will be too much. Well I also feel it's a bit dirty to parse line by line and than choose java strings for the new java file. – timguy Jun 05 '23 at 12:31
  • 1
    Well actually, JavaCC and ANTLR do generate Java code, but they take a grammar file as input – Maurice Perry Jun 05 '23 at 19:35
  • ok so but it seems not easily possible to: 1) make SEEXML known with grammer files 2) translate into java with grammer files and dsl lib 3) live wihtouht the DSL library and grammer files because I have the Javacode now – timguy Jun 06 '23 at 11:26

0 Answers0