开发者

JAXB to be create a map from XSD

开发者 https://www.devze.com 2023-01-12 13:17 出处:网络
When JAXB generates this, it create the OtherProperties as a List. How can I configure the XSD so it is generated as a 开发者_如何学CMap?

When JAXB generates this, it create the OtherProperties as a List. How can I configure the XSD so it is generated as a 开发者_如何学CMap?

            <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>


Similar to the following question:

  • Can I customize JAXB @XmlElementWrapper elements for a java.util.Map

Standard JAXB has limited support for handling java.util.Map.

To get the xml representation you want you will need to use an XmlAdapter:

  • XmlAdapter - JAXB's Secret Weapon

Are you interested in this direction?

0

精彩评论

暂无评论...
验证码 换一张
取 消