【发布时间】:2010-10-03 18:05:41
【问题描述】:
对于如何编写我自己的自定义 JAXB 注释处理类来支持 xsd 模式中 xs:annotation/xs:documentation 元素的生成,人们有什么建议吗?我想创建一个新的 java 注释“@XmlAnnotation”,其中包含一个“文档”属性。然后,我将通过类路径将这些类提供给 JAXB 模式生成器。然后模式生成器将采用这个示例 java 代码
@XmlRootElement(name="ClientData")
public class ClientData {
/**
* The first address field of the person
*/
@XmlAnnotation(documentation="The first address field of the client")
private String address1 = null;
}
并创建此 xsd 架构
<xs:complexType name="clientData">
<xs:sequence>
<xs:element minOccurs="0" name="address1" type="xs:string">
<xs:annotation>
<xs:documentation>The first address field of the client</xs:documentation>
</xs:annotation>
从现有的@XmlElement 注释类扩展会更容易,并且只添加对额外文档属性的支持吗?
【问题讨论】: