Class XMLChoiceCollectionMapping

All Implemented Interfaces:
Serializable, Cloneable, ChoiceCollectionMapping<AbstractSession,AttributeAccessor,ContainerPolicy,Converter,ClassDescriptor,DatabaseField,XMLMarshaller,Session,XMLUnmarshaller,XMLField,XMLMapping,XMLRecord>, Mapping<AbstractSession,AttributeAccessor,ContainerPolicy,ClassDescriptor,DatabaseField,XMLRecord>, XMLContainerMapping, XMLConverterMapping<XMLMarshaller,Session,XMLUnmarshaller>, XMLMapping

PUBLIC:

Purpose:Provide a mapping that can map a single attribute to a number of different elements in an XML Document. This will be used to map to Choices or Substitution Groups in an XML Schema

Responsibilities:

  • Allow the user to specify XPath -> Type mappings
  • Handle reading and writing of XML Documents containing a collection of choice or substitution group elements

The XMLChoiceCollectionMapping is the collection version of the XMLChoiceMapping. This mapping allows the user to specify a number of different xpaths, and types associated with those xpaths. When any of these elements are encountered in the XML Document, they are read in as the correct type and added to the collection.

Setting up XPath mappings:Unlike other OXM Mappings, instead of setting a single xpath, the addChoiceElement method is used to specify an xpath and the type associated with this xpath.
xmlChoiceCollectionMapping.addChoiceElement("mystring/text()", String.class);
xmlChoiceCollectionMapping.addChoiceElement("myaddress", Address.class);

See Also: