当JAXB生成它时,它将OtherProperties创建为List.如何配置XSD以便将其生成为Map?
<xsd:element name="OtherProperties" minOccurs="0">
<xsd:complexType>
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="Property">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="value" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Run Code Online (Sandbox Code Playgroud)
类似于下面的问题:
标准 JAXB 对处理 java.util.Map 的支持有限。
要获得您想要的 xml 表示形式,您需要使用 XmlAdapter:
你对这个方向感兴趣吗?