Hi folks,
I am facing a problem I simply can't solve.
Consider this schema snippet:
---------------------------------------
<xs:complexType name="positionedLabel">
<xs:complexContent>
<xs:extension base="positionedElement">
<xs:sequence>
<xs:element name="text" type="text" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<jaxb:property name="texts" />
<annox:annotate target="field">
<annox:annotate
annox:class="javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter"
value="model.adapters.LabelTextAdapter">
</annox:annotate>
</annox:annotate>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="width" type="xs:positiveInteger" />
<xs:attribute name="height" type="xs:positiveInteger" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
---------------------------------------
As you can see, I have this text elements list. I want it to be a map with the lang as key and the text element as value.
Well, I searched forums and net to solve the problems myself and found Kohsuke's blog post [1]. Seems to be it but he does not mention how to do this with a schema. After some digging I found the annonate plugin which injects the @XmlAdaper for me [2]. It did its job perfectly on the field.
Now the problem, how do I change from List/ArrayList to Map/HashMap? There does not seem to be a solution. Moreover, I found this thread [3]. I tried the example myself I was able to reproduce the incorrect behavior. The collection is empty, always when unmarshalling.
Should I continue this path, or completely abandon it and accept that this is not possible with JAXB and schema binding?
I am on: JDK 1.6.0_17 and built-in JAXB 2.1.10
Thanks,
Mike
[1]
http://weblogs.java.net/blog/kohsuke/archive/2005/04/xmladapter_in_j.html
[2]
http://confluence.highsource.org/display/J2B/Annotate+Plugin
[3]
https://jaxb.dev.java.net/servlets/ReadMsg?listName=users&msgNo=8560
--
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail