1

Generate java file from XML file without any API

Hi, I would like to know if it's possible to generate a java class from existing model as illustrate in this picture below.enter image description here

Informations about the generated class will be found in a XML file like this:

<?xml version="1.0" encoding="UTF-8"?>
    <entity name="Balise1">
    <attribut name="a" type="List" basetypeid="1"/>
    <typedef type="List" basetypeid="2" id="1"/>
    <typedef type="String" id="2"/> 
</entity>

For exemple when I find the tagname "entity" I create a instance of MjEntity and so on. After iterating the XML file, I have just to generate my Java class.

Community
  • 1
  • 1
AKN NDIAYE
  • 11
  • 2

1 Answers1

0

I believe a costum XML format reader requires you to write your own generator.

There are formats that can generate Java classes from XML. Take a look at .XSD -> .java here.. Generate Java classes from .XSD files...?

Also, if you dont want entity relations in the class object, you can create an orm.xml (Object Relation Mapping) to define this. Take a look at https://dzone.com/articles/persisting-entity-classes

Community
  • 1
  • 1
R. Gulbrandsen
  • 3,648
  • 1
  • 22
  • 35