globalBindings超类

时间:2011-08-29 20:09:55

标签: jaxb

我在使用supperClass for globalBindings时遇到问题。

我的jaxb配置:

<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
  jxb:extensionBindingPrefixes="xjc"  
  xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd ">

  <jxb:globalBindings>
    <xjc:superClass name="package.Superclass"/>
  </jxb:globalBindings>

  <jxb:bindings schemaLocation="xlink.xsd" node="/xs:schema">
    <jxb:schemaBindings>
      <jxb:package name="org.w3.xlink" />
    </jxb:schemaBindings>
  </jxb:bindings>

  <jxb:bindings schemaLocation="something.xsd" node="/xs:schema">
    <jxb:schemaBindings>
      <jxb:package name="package1" />
    </jxb:schemaBindings>
  </jxb:bindings>

  <jxb:bindings schemaLocation="something2.xsd" node="/xs:schema">
    <jxb:schemaBindings>
      <jxb:package name="package2" />
    </jxb:schemaBindings>
  </jxb:bindings>
</jxb:bindings>

现在Superclass扩展了我生成的所有类。我怎么能阻止这种绑定只到package1? 对于package2可能有不同的Superclass2类型?

1 个答案:

答案 0 :(得分:1)

您可以利用剧集文件来分离XML架构的编译。通过这种方式,每个模式都可以拥有自己的绑定文件: