Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB to be create a map from XSD

Tags:

xml

jaxb

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>
like image 430
user423368 Avatar asked Aug 17 '10 22:08

user423368


1 Answers

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?

like image 52
bdoughan Avatar answered Oct 24 '22 17:10

bdoughan