DFDLUtil { public void transform(File dfdlSchemaFile, File outputDir) { assert outputDir.exists(); assert outputDir.isDirectory(); final Document schema = parseDFDLSchema(dfdlSchemaFile); final Iterator<Element> iterator = getMainTypes(schema); final PojoFactory factory = new PojoFactory(); while (iterator.hasNext()) { final Element element = iterator.next(); final Iterator<Element> sequenceIterator = element.elementIterator(sequence); final Element sequence = getSequence(sequenceIterator); final ArrayList<PojoFactory.Field> fields = new ArrayList<>(); final Iterator<Element> elementIterator = sequence.elementIterator(ELEMENT); while (elementIterator.hasNext()) { final Element elem = elementIterator.next(); fields.add(new PojoFactory.Field(Expressions.typeOf(elem.attributeValue("type")), elem.attributeValue("name"))); } final PojoFactory.PojoDescription desc = new PojoFactory.PojoDescription(element.attributeValue("name"), fields); final ClassDeclaration classDeclaration = factory.create(desc); final CodeWriter writer = new CodeWriter(4); final Generator generator = new JavaGenerator(writer); classDeclaration.write(generator); System.out.println("Class Definition"); System.out.println("----------------------------"); System.out.println(writer.getCode()); } }  void transform(File dfdlSchemaFile, File outputDir);  }
@Test public void loadDFDL() throws IOException { final File schema = new File("src/test/resources/protocol.dfdl.xsd"); Path tempDirWithPrefix = Files.createTempDirectory("plc4x-code-gen"); final File outDir = tempDirWithPrefix.toFile(); System.out.println(schema.getAbsolutePath()); final DFDLUtil util = new DFDLUtil(); util.transform(schema, outDir); }