user423368
user423368

Reputation: 61

JAXB to be create a map from XSD

When JAXB generates this, it create the OtherProperties as a List. How can I configure the XSD so it is generated as a 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>

Upvotes: 6

Views: 12382

Answers (1)

bdoughan
bdoughan

Reputation: 149037

Similar to the following question:

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

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

Are you interested in this direction?

Upvotes: 4

Related Questions