如何从给定的多个 XSD 生成 Castor mapping.xml 文件?
问问题
3979 次
1 回答
0
导入 java.io.FileNotFoundException;导入 java.io.FileOutputStream;导入 java.io.OutputStream;导入 java.io.OutputStreamWriter;导入java.io.Writer;
//import org.exolab.castor.builder.SourceGenerator; 导入 org.exolab.castor.mapping.MappingException;导入 org.exolab.castor.tools.MappingTool;
公共类 CastorMappingToolUtil {
public static void generate() throws MappingException, FileNotFoundException {
MappingTool tool = new MappingTool();
tool.setInternalContext(new org.castor.xml.BackwardCompatibilityContext());
tool.addClass(ClassType.class);
OutputStream file = new FileOutputStream("/path/to/xmlFile/gen_mapping.xml" );
Writer writer = new OutputStreamWriter(file);
tool.write(writer);
//SourceGenerator.main(options);
}
/**
* @param args
*/
public static void main(String[] args) {
try {
CastorMappingToolUtil.generate();
} catch (MappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
于 2011-02-22T09:17:36.430 回答