Hi,
I had to come up with a solution to derive an Avro schema when the input is
XSD or JSON schema. As a solution, I have tried the following process to
convert XSD to AVRO.
1. XSD to POJO generation
2. POJO to Avro schema generation
*XSD to POJO generation*
Runtime execution of xjc was used.
String xjcCommand = "xjc -d src/main/java/temp/tempPojo -p gen
resource/employee.xsd";
Process child = Runtime.getRuntime().exec(xjcCommand);
*POJO to Avro schema generation*
Java reflection was used.
Schema s = ReflectData.get().getSchema(Employee.class);
For JSON schema, following is the implementation.
*JSON schema to Avro schema*
JCodeModel codeModel = new JCodeModel();
URL source = new File("./resource/mySchema.json").toURI().toURL();
new SchemaMapper().generate(codeModel, "GenPojo", "com.example", source);
codeModel.build(new File("output"));
*
*
WDYT about performing a double conversion like this? Do you find a better
way?
--
*Gayan Kaushalya Yalpathwala*
Software Engineer
WSO2 Inc.; http://wso2.com
lean.enterprise.middleware
mobile: +94 71 8682704
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev