Message Set to DFDL Automatic Conversion


Recently we’ve started working on migrating stuffs from WMBv7 to ACEv12. The biggest challenge we’ve encountered is so far is, converting the message sets to DFDLs. Please note I’m talking about Custom Wire Formats not Cobol copy books.

I’d say it is one of the most difficult task I’ve encountered so far because the messages sets are all EDIFACT ( IBM 500 ) messages with different initiators, separators and terminators along with various padding characters and justification configuration.

So, thought of finding some automatic solution in Google but no luck. There are 100+ models need to be converted in next couple of months. All I can do so far is, write a java program to read the MXSD files and clean up the unnecessary stuffs. Also, tried to have the group indicators/terminators and delimiters converted into DFDL annotations.

This is not a 100% working solution but definitely helping a lot to quickly have the DFDL created. If you’ve any better solution, please feel free to add in the comments.

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileSystemView;

import org.apache.commons.lang3.StringUtils;

public class TDSCleaner {

	 * @param args
	 * @throws IOException 
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		JFileChooser jfc = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());

        int returnValue = jfc.showOpenDialog(null);

        if (returnValue == JFileChooser.APPROVE_OPTION) {
            File selectedFile = jfc.getSelectedFile();
            Path path = Paths.get(selectedFile.getAbsolutePath());
            List<String> lines = Files.readAllLines(path, StandardCharsets.UTF_8);
            List<String> newLine = new ArrayList<>();
            /*String rootElm = JOptionPane.showInputDialog("Enter the root element name");
            if (rootElm != null) {
				rootElm = "       01  "+FilenameUtils.getBaseName(selectedFile.getAbsolutePath())+".";
            String rootElm =  "       01  "+FilenameUtils.getBaseName(selectedFile.getAbsolutePath())+".";
            String delimiter,groupTerminator,groupIndicator;
            delimiter = null;
    		groupTerminator = null;
    		groupIndicator = null;
            for (String line : lines) {
            	if (!StringUtils.containsAny(line, "annotation","appinfo",
            			"MRMessage","MRMessage","MRComplexType","tdsElemRep"))  {
            		if (line.contains("tdsStructRep")) {
            			line = StringUtils.replace(line, "<U+001D>", "%GS;");
            			line = StringUtils.replace(line, "<U+001C>", "%FS;");
            			if (line.contains("groupIndicator")) {
							groupIndicator = "dfdl:initiator="+StringUtils.substringBetween(line, "groupIndicator=", " ");
            			if (line.contains("groupTerminator")) {
            				groupTerminator = "dfdl:terminator="+StringUtils.substringBetween(line, "groupTerminator=", " ");
            			if (line.contains("delimiter")) {
            				delimiter = "dfdl:separator="+StringUtils.substringBetween(line, "delimiter=", " ");
            		if (line.contains("<xsd:sequence")) {
            			if (delimiter != null) {
            				line = StringUtils.replace(line, ">", " ")+delimiter+">";
            			if (groupIndicator != null) {
            				line = StringUtils.replace(line, ">", " ")+groupIndicator+">";
            			if (groupTerminator != null) {
            				line = StringUtils.replace(line, ">", " ")+groupTerminator+">";
            		delimiter = null;
            		groupTerminator = null;
            		groupIndicator = null;
            if (!lines.isEmpty()) {
            	String cpyFileName = FilenameUtils.getFullPath(selectedFile.getAbsolutePath())
            	FileUtils.writeLines(new File(cpyFileName), newLine);
            	JOptionPane.showMessageDialog(null, "File created successfully");
			} else {
				JOptionPane.showMessageDialog(null, "Lines are empty check your source file");



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.