I'm looking for a way to generate dynamically (means, every time other java class) Java class from XML. The initial XML based on a XSD, but the result class shall be a bean. Example:
XSD (just shortly):
Configuration->configuration-item->name
->value
->type
->scope
->impl-class-info
Basically one simple param with a implementation class name and list of configuration-item
XML (example):
<configuration>
<impl-class-info>desired.class.name.APPConfig</impl-class-info>
<configuration-item>
<name>ipOfSomeServer</name>
<type>string</type>
<value>8.8.8.8</value>
<scope></scope>
</configuration-item>
<configuration-item>
<name>portOfSomeServer</name>
<type>string</type>
<value>1099</value>
<scope></scope>
</configuration-item>
</configuration>
The generated java class shall be like that:
package desired.class.name;
import xxx.xxx.xxx.ConfigurationElement;
public class APPConfig extends ConfigurationElement {
private String ipOfSomeServer;
private String portOfSomeServer;
public void setIpOfSomeServer(String ipOfSomeServer){
this.ipOfSomeServer = ipOfSomeServer;
}
public void setPortOfSomeServer(String portOfSomeServer){
this.portOfSomeServer = portOfSomeServer;
}
public String getPortOfSomeServer(){
return this.portOfSomeServer;
}
public String getIpOfSomeServer(){
return this.ipOfSomeServer;
}
How can it be done? I'm getting lost. I looked (maybe not good enough) on JAXB,XStream, XMLBeans but it doesn't seems what I need.
The "complex input XML" maybe converted by XSLT (I think) to a simple one
<desired.class.name.APPConfig>
<ipOfSomeServer>8.8.8.8</ipOfSomeServer>
<portOfSomeServer>1099</portOfSomeServer>
</desired.class.name.APPConfig>
But what than?
Thanks in advance Alex
P.S. After trying a few techniques I took a challenge to use XSLT to convert XML to Text (which syntactically Java class). The XML validation made previously using maven and defined XSD.
Thanks to all for the help.