使用 JAXB 2.1 将多个模式编译成不同的包 [英] Compiling multiple schemas into different packages using JAXB 2.1

查看:20
本文介绍了使用 JAXB 2.1 将多个模式编译成不同的包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 CommonTypes.xsd,我使用 xs:include 将其包含在我的所有其他 XSD 中.我明白了

I have a CommonTypes.xsd which I'm including in my all other XSDs using xs:include. I get

Multiple <schemaBindings> are defined for the target namespace ""

当我尝试使用绑定文件将其编译成不同的包时.请告诉我是否有办法将它们编译成不同的包.我正在使用 jaxb 2.1

when I try to compile it into different packages using binding files. Please tell me whether there is a way to compile them into different packages. I'm using jaxb 2.1

推荐答案

正如 Ben 已经说过的,如果它们具有相同的命名空间,则无法做到这一点.但是如果你有不同的命名空间怎么办?

As stated already by Ben there is no way to do that if they have the same namespace. But how to do it if you do have different namespaces?

<jxb:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
    <jxb:bindings namespace="http://www.openapplications.org/oagis/9/unqualifieddatatypes/1.1" schemaLocation="oagi/Common/UNCEFACT/ATG/CoreComponents/UnqualifiedDataTypes.xsd" >
        <jxb:schemaBindings>
            <jxb:package name="com.test.oagi.udt"/>
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings namespace="http://www.openapplications.org/oagis/9/codelists" schemaLocation="oagi/Common/OAGi/Components/CodeLists.xsd" >
        <jxb:schemaBindings>
            <jxb:package name="com.test.oagi.cl"/>
        </jxb:schemaBindings>
    </jxb:bindings>
</jxb:bindings>

但请确保不要使用命令行参数 -p,因为这会覆盖您的配置.

but be sure you do not use the command line parameter -p, since that will override your config.

这篇关于使用 JAXB 2.1 将多个模式编译成不同的包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆