jaxb2-annotate-plugin
jaxb2-annotate-plugin copied to clipboard
Add annotation to simpleContent (with extension)
Hi, I have an issue that requires me to add the @XmlValueExtension annotation to an object attribute that is generated by a Simple content extending double. I can't find how to bind this in my xjb file. My XSD looks like :
<xs:complexType name="level1">
<xs:sequence>
<xs:element name="level2" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="level3" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:double">
<xs:attribute name="level4" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
I get the following classes
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "level1")
public class Level1
implements Serializable
{
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "level2")
public static class Level2
implements Serializable
{
protected UIList<Level1.Level2.Level3> level3 = new UIArrayList<Level1.Level2.Level3>();
public UIList<Level1.Level2.Level3> getLevel3() {
return this.level3;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "level3")
public static class Level3
implements Serializable
{
@XmlValue
@XmlSchemaType(name = "double")
protected Value<Double>value;
@XmlAttribute(name = "level4", required = true)
protected Value<Double> level4;
/**
* Obtient la valeur de la propriété value.
*
* @return
* possible object is
* {@link String }
*
*/
public Value<Double>getValue() {
return value;
}
/**
* Définit la valeur de la propriété value.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setValue(Value<Double>value) {
this.value = value;
}
}
}
}
I would like to add the annotation @XmlValueExtension to the protected Value<Double>value;
I've tried the following :
<jaxb:bindings node="xs:complexType[@name='level1']/xs:sequence/xs:element[@name='level2']/xs:complexType/xs:sequence/xs:element[@name='level3']/xs:complexType/xs:simpleContent">
<annox:annotate target="class">@java.lang.SuppressWarnings("something")</annox:annotate>
</jaxb:bindings>
But I can only annotate the class, not the value attribute.
Thanks for the help
Hi @MDesharnaisX
For reference, another issue have been linked to this one with same problem and the user found the way to acheive the annotation with some adjustments to xjb bindings file.
We are also moving this repo to the maven-jaxb2-plugin repository, now renamed jaxb-tools. You'll find a new 2.0.5 version of this plugin with same groupId for all artifacts. Also, documentation from unavailable confluence have been restored in the wiki
Regards