我有以下 xml 类型:
<xsd:element name="FaxNumbers" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="FaxNumber" type="FaxNumber" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
FaxNumber 类型如下所示:
<xsd:simpleType name="FaxNumber">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1" />
</xsd:restriction>
</xsd:simpleType>
生成的 xml 应该是这样的:
<FaxNumbers>
<FaxNumber>3878374</FaxNumber>
<FaxNumber>387833434</FaxNumber>
<FaxNumber>3878334</FaxNumber>
</FaxNumbers>
当运行 JAXB XJC 从 XSD 生成 java 类时,它会生成以下类:
@XmlType(name = "FaxNumbers")
public class FaxNumbers {
/**
* No comment.
*/
@XmlElement(name = "FaxNumber", required = true)
protected List<String> faxNumber = new ArrayList<String>();
}
但是我想像这样将FaxNumber绑定到复合类:
@XmlType(name = "FaxNumbers")
public class FaxNumbers {
/**
* No comment.
*/
@XmlElement(name = "FaxNumber", required = true)
protected List<FaxNumber> faxNumber = new ArrayList<String>();
}
Where FaxNumber class looks like this:
public class FaxNumber{
@XmlValue
private String value;
}
有没有办法在 JAXB 绑定 xml 中定义这种绑定?
注意:不幸的是,我无法控制也无法更改 XSD