我使用maven-jaxb2-plugin来生成基于.wsdl文件的模型。现在,我需要向其中一个类添加注释。我试着使用jaxb2-basics-annotate,并且非常接近成功,但现在我被困住了。
我的目标是实现这一目标:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BinaryObjectType", propOrder = {
"value"
})
public class BinaryObjectType {
@XmlValue
@XmlJavaTypeAdapter(BinaryObjectTypeValueAdapter.class)
protected byte[] value;
}但我目前的产出是:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BinaryObjectType", propOrder = {
"value"
})
@XmlJavaTypeAdapter(BinaryObjectTypeValueAdapter.class)
public class BinaryObjectType {
@XmlValue
protected byte[] value;
}我的bunding.xjb看起来是这样的:
<jxb:bindings schemaLocation="file:./schema.wsdl"
node="//xs:complexType[@name='BinaryObjectType']/xs:simpleContent">
<annox:annotate>
<annox:annotate annox:class="javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter"
value="example.mapper.BinaryObjectTypeValueAdapter">
</annox:annotate>
</annox:annotate>
</jxb:bindings>.wsdl的相关片段
<xsd:complexType name="BinaryObjectType">
<xsd:annotation...>
<xsd:simpleContent>
<xsd:extension base="xsd:base64Binary">
<xsd:attribute name="format" type="xsd:normalizedString" use="optional">
...
</xsd:extension>
</xsd:simpleContent>我不能修改它。基本上,我的问题是我不知道如何将XPath指定为BinaryObjectType类的value属性。我试着使用simpleContent、分机等,但是没有什么对我有用。我看到我可以在target级别上指定annox:annotate,但这并没有帮助。
发布于 2022-08-16 16:31:38
整天谷歌和我都发现了JAXB bindings - address content of an xs:string extension with xpath。还没有实现,但看起来像是一个答案。
https://stackoverflow.com/questions/73375652
复制相似问题