[英]How to skip complexType in JAXB bindings
I use JAXB bindings to generate java class from an existing xml schema. 我使用JAXB绑定从现有的xml模式生成Java类。 But I want to skip class generation for types that endswith "Old" or declare an "obsolete" attribute or contains undescore.
但是我想跳过以“ Old”结尾的类型的类生成,或者声明“ obsolete”属性或包含undescore的类型。
I try, in vain, to modify my JAXB bindings file but I don't know what node write to declare these types skipped... 我徒劳地尝试修改我的JAXB绑定文件,但我不知道该写什么节点声明跳过了这些类型...
<!-- skip old types -->
<!-- with ie:obsolete attribute -->
<jaxb:bindings schemaLocation="external/insee/*.xsd">
<jaxb:bindings node="//*[@ie:obsolete='true']">
<!-- declare this type skipped -->
</jaxb:bindings>
</jaxb:bindings>
<!-- that endswith Old -->
<!-- that contains "_" underscore -->
Is there a solution? 有解决方案吗?
Assuming none of the types you process reference these "skipped types", then you could use an external bindings file to specify that they correspond to an existing class so that a new one won't be generated. 假设您处理的所有类型都不引用这些“跳过的类型”,那么您可以使用一个外部绑定文件来指定它们与现有类相对应,从而不会生成新的类。 If these skipped types are referenced then references to this fake class will be brought into your model.
如果引用了这些跳过的类型,则对该假类的引用将被带入模型。
binding.xml binding.xml
<jxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
version="2.1">
<jxb:bindings schemaLocation="beta.xsd">
<jxb:bindings node="//xs:element[@name='person']/complexType">
<jxb:class ref="com.FakeClass"/>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
Full Example 完整的例子
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.