KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an existing XML schema that contains a type that I would like to map to a Java Map of some sort using JAXB. My build process takes the schema and creates the beans. I would like to customize this process by having one of the complexTypes in my schema map to a java.util.Map. I've read somewhere that JAXB "can't do interfaces." I'm not sure if that applies in this case, but if so I'd be fine with it mapping to a HashMap. Also, it doesn't necessarily have to be the complexType that maps to a Map, it could be an element if that's what's required. I control my JAXB generation using a .xjb file, so I'm looking for some <jaxb:bindings> to put in there. I've tried the following, but it does not work: <jaxb:bindings schemaLocation="myschema.xsd" node="/xs:schema"> <jaxb:globalBindings> <jaxb:serializable uid="1"/> </jaxb:globalBindings> <jaxb:schemaBindings> <jaxb:package name="com.myschema.client.types"/> </jaxb:schemaBindings> <jaxb:bindings node="//xs:complexType[@name='MapType']"> <jaxb:javaType name="java.util.HashMap" parseMethod="com.myschema.common.MapConverter.parseObjectToMap" printMethod="com.myschema.common.MapConverter.printMapToObject" /> </jaxb:bindings> </jaxb:bindings> Edit: I've added more detail on the above binding that I've already tried. It generates the following error during schema compile: [jaxb] [ERROR] compiler was unable to honor this javaType customization. It is attached to a wrong place, or its inconsistent with other bindings. <jaxb:javaType> will not work because it can only be used for mapping between XML Schema primitives and Java types . Since I
Tags (comma-separated)
Save Edits
Cancel