[英]How to influence class generation of group declarations with XJC
We have the following problem. 我们有以下问题。 We try to generate Java code from XSD files that contain group declarations and multiple group references to these group declarations.
我们尝试从XSD文件生成Java代码,这些文件包含组声明和对这些组声明的多个组引用。 Here a simplified version:
这里是一个简化的版本:
<xs:group name="Information">
<xs:sequence>
<xs:element name="Name">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="updated" type="xs:boolean"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:group>
<xs:element name="Address">
<xs:complexType>
<xs:sequence>
<xs:group ref="Information" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:group ref="Information"/>
</xs:sequence>
</xs:complexType>
</xs:element>
The main points are: 要点如下:
Information
is references twice Information
被引用两次 Name
element inside the group Name
元素也没有单独的类型 The problem we face now is that xjc generates non-deterministically depending on the machine where we build, sometimes the type Address.Name
and sometimes the type Customer.Name
, because the Name
element is a complex type and requires a type. 现在我们面临的问题是xjc会不确定地生成,具体取决于我们构建的机器,有时是
Address.Name
类型,有时是Customer.Name
类型,因为Name
元素是复杂类型,需要类型。
Is there any way to tell xjc to always generate the same type? 有什么办法告诉xjc总是生成相同的类型?
jaxb:class
binding and specify the class name. jaxb:class
绑定定制匿名复杂类型,并指定类名称。 <jaxb:globalBindings localScoping="toplevel"/>
to generate inner classes on the top level instead. <jaxb:globalBindings localScoping="toplevel"/>
可以在<jaxb:globalBindings localScoping="toplevel"/>
生成内部类。 A combination of these two will give you a predictable class. 两者的结合将为您提供可预测的课程。
You could try the -episode
command line option of XJC . 您可以尝试XJC的
-episode
命令行选项 。 It is primarily meant for compilation in multiple steps, but I think it basically "dumps decisions" taken by XJC during a compilation into a (binding) configuration file. 它主要用于多步编译,但是我认为它基本上是将XJC在编译过程中做出的决定“转储”到(绑定)配置文件中。 If you are lucky, you find suitable settings related to the
Name
element/type in the episode file which you can copy into your binding configuration file to make XJC behave deterministically. 如果幸运的话,您可以在情节文件中找到与
Name
元素/类型相关的合适设置,您可以将这些设置复制到绑定配置文件中,以使XJC具有确定性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.