JAXB JXC 为枚举生成架构,无论@XmlTransient如何
使用 JXC 模式生成 ant 任务,我似乎无法让它忽略枚举。我有几个在内部使用的枚举来表示与生成的 XML 不相关的类型或次要配置值。
我可以使用枚举作为 @XmlTransient 来排除该字段,以将其从对象的架构中排除,但仍会为枚举生成 simpleType 描述符!
示例:
public class CustomerType {
@XmlTransient
public enum IsolationLevel { ALL, SAME_TYPE, SELECTED }
@XmlTransient
private Long id;
@XmlValue
private String name;
@XmlTransient
private IsolationLevel isolation = IsolationLevel.ALL;
}
生成的架构:
<xs:simpleType name="isolationLevel">
<xs:restriction base="xs:string">
<xs:enumeration value="ALL"/>
<xs:enumeration value="SAME_TYPE"/>
<xs:enumeration value="SELECTED"/>
</xs:restriction>
</xs:simpleType>
有人对如何使 JXC 忽略枚举有任何想法吗?它没有被任何 XML 映射属性或字段使用,并且枚举本身被标记为 @XmlTransient - 为什么它仍然是我的架构的一部分?
Using the JXC schema generation ant task, I can't seem to get it to ignore an enum. I have several enums that are used internally to denote type or minor configuration values that are not relevant to the generated XML.
I can exclude the field using the enum as @XmlTransient to exclude it from the object's schema, but a simpleType descriptor is still generated for the enum!
Example:
public class CustomerType {
@XmlTransient
public enum IsolationLevel { ALL, SAME_TYPE, SELECTED }
@XmlTransient
private Long id;
@XmlValue
private String name;
@XmlTransient
private IsolationLevel isolation = IsolationLevel.ALL;
}
Generated Schema:
<xs:simpleType name="isolationLevel">
<xs:restriction base="xs:string">
<xs:enumeration value="ALL"/>
<xs:enumeration value="SAME_TYPE"/>
<xs:enumeration value="SELECTED"/>
</xs:restriction>
</xs:simpleType>
Anyone have any ideas on how to make JXC ignore the enum? It's not being used by any XML mapped property or field, and the enum itself is marked @XmlTransient - why is it still part of my schema?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚也遇到了这个问题,并将我的 pom 更新到了 2.2.11,并且至少修复了该版本。评论中提到的 Jira bug 也指出它已在 2.2.5 中修复。为此,我必须添加三个依赖项,如下所示:
I just ran into this as well and updated my pom to 2.2.11 and it's at least fixed for that version. The Jira bug mentioned in the comments also states it's been fixed in 2.2.5. In doing this I had to add the three dependencies as shown below: