开发者

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

How to generate Castor 开发者_StackOverflow中文版mapping.xml file from given multiple XSDs?


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

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜