How to generate Castor mapping.xml file from given multiple XSDs?

匆匆过客 提交于 2019-12-12 01:08:33

问题


How to generate Castor mapping.xml file from given multiple XSDs?


回答1:


import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer;

//import org.exolab.castor.builder.SourceGenerator; import org.exolab.castor.mapping.MappingException; import org.exolab.castor.tools.MappingTool;

public class 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();
    }
}

}



来源:https://stackoverflow.com/questions/4737063/how-to-generate-castor-mapping-xml-file-from-given-multiple-xsds

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!