so that a XSD restriction is not mapped to a Java class inheritance.
Here is an example:
Here is the way a field is defined in a complex type A:
<element name="qualifier" type="CR" maxOccurs="unbounded" minOccurs="0"/>
Here is the way the same field is restricted in another complex type B that restricts A:
<element name="qualifier" type="CR" minOccurs="0" maxOccurs="0"/>
In the A generated class I have:
@XmlElement(name = "qualifier")
protected List<CR> qualifiers;
And in the B generated class I have:
protected CR qualifiers;
With my poor understanding of JAXB the absence of the XmlElement
annotation tells JAXB not to marshall/unmarshall this field. Am I wrong?
If I am right is there a way to tell JAXB not to generate the qualifiers
field at all?
This would be in my opinion a much better generation as it respects the constraints.
Any idea, thougths on the topic?
Thanks!!
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
如果不需要该类型,那么单独 minOccurs="0" 就足够了,不是吗?看起来您正在尝试定义一个可能不包含在文档中的元素 - 这没有意义,尽管它是有效的。
If the type is not needed then alone minOccurs="0" should be enough, no ? Looks like you are trying to define an element that may not be included in the document - that does not make sense, although it's valid.
好吧,我想通了。
这基本上是
自定义与
自定义之间的交互问题。如果我删除简单的字段,则不再生成字段!这就是当您走在 JAXB 实验道路上时会发生的情况;)
Ok I figured it out.
This is basically an interaction issue between the
<xjc:treatRestrictionLikeNewType />
customization and the<xjc:simple />
one. If I remove the simple one the fields are not generated anymore!That's what happens when you walk on the experimental path of JAXB ;)