Our applications uses java classes generated from XML Schema Definition (XSD). I need to use HashMap for storing key, value pairs.
The Result class should be something like this from xsd
public class Employee{
private String name;
private Map<String, Object> dataMap;
}
Tried schemagen, jaxbcontext etc, but still unable to do it successfully . Tried below in XSD but getting "List" in the generated java class (instead of map). Using JDK 1.8
<xs:complexType name="employee">
<xs:sequence>
<xs:element name="dataMap">
<xs:complexType>
<xs:sequence>
<xs:element name="entry" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="key" minOccurs="0" type="xs:string"/>
<xs:element name="value" minOccurs="0" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="value" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
Appreciate any help/suggestions