Consider a map type of element that has a set of well known subelements along with support for custom elements. Can something like this work?
<xs:element name="descriptors"> <xs:annotation> <xs:documentation> The descriptors element contains all the descriptors for a containing element, as subelements. The descriptors suggested in the jmx spec have predefined elements, whereas custom descriptors have a generic element. </xs:documentation> <xs:appinfo> <jbxb:class impl="javax.management.modelmbean.DescriptorSupport"/> </xs:appinfo> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" ref="xmbean:interceptors"> <xs:annotation> <xs:appinfo> <putMethod name="setField" keyType="java.lang.String" valueType="java.lang.Object" /> <mapEntry /> <mapEntryKey key="interceptors" /> <mapEntryValue /> </xs:appinfo> </xs:annotation> </xs:element> <xs:element minOccurs="0" ref="xmbean:persistence"> <xs:annotation> <xs:appinfo> <putMethod name="setField" keyType="java.lang.String" valueType="java.lang.Object" /> <mapEntry /> <mapEntryKey key="persistence" /> <mapEntryValue /> </xs:appinfo> </xs:annotation> </xs:element> ...
Specifying the defaults for keys and values maybe useful.
What you could use currently as a workaround is attribute 'impl' of mapEntry annotation to specify the implementation of the mapEntry class which would return the key you need.