[英]Jaxb: attribute fixed value in annotated class
I generate XML schema (XSD) from Java classes with JAXB. 我使用JAXB从Java类生成XML模式(XSD)。 I wonder how to specify the value of a static attribute by using annotations. 我想知道如何使用注释指定静态属性的值。
For example I define an attribute like this 例如,我定义了这样的属性
@XmlAttribute(name="tooltip")
private static final String TOOLTIP = "A string";
And I want to get in my XSD 我想进入我的XSD
<attribute name="tooltip" type="string" fixed="A string">
So, how can I force the generation of static attributes in XSD with JAXB? 那么,如何使用JAXB强制在XSD中生成静态属性?
Thanks ! 谢谢 !
As of JAXB 2.2, there isn't standard JAXB (JSR-222) metadata that can add to your model to cause the fixed
attribute to appear in the generated XML Schema. 从JAXB 2.2开始,没有标准的JAXB(JSR-222)元数据可以添加到模型中,以使fixed
属性出现在生成的XML Schema中。 The schema generation errs on the side of being too permissive rather than too restrictive. 模式生成错误地过于宽松而不是过于严格。 This means you can't do the following: 这意味着您无法执行以下操作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.