.NET XmlSerializer and JAXB attribute/annotation mappings

This is a technical post.

I’ve recently been looking at how XML serialization is performed in JAXB 2.0 and immediately realised that I’d find it useful to have a cross-reference of .NET XmlSerializer attributes and JAXB annotations.  I hope you find it useful too.

The following table shows attributes and annotations that refer to the binding of the XML schema and not the behaviour (except where it relates directly to the binding) of either of the serialization and deserialization engines, such as recognition of types and custom serialization extensions.

Xml .NET XmlSerializer JAXB Serialization
Root element XmlRootAttribute XmlRootElement
Anonymous complex type XmlTypeAttribute XmlType
XmlValue
Named complex type XmlTypeAttribute XmlType
XmlValue
Anonymous simple type XmlElementAttribute
XmlAttributeAttribute
XmlValue
Named simple type   XmlValue
Contained element XmlElement XmlElement
XmlElementRef
XmlElements
XmlElementRefs
XmlElementWrapper
XmlInlineBinaryData
XmlList
XmlMixed
XmlAttachmentRef
Element attribute XmlAttribute XmlAttribute
XmlID
XmlIDREF
XmlInlineBinaryData
XmlAttachmentRef
text() node XmlTextAttribute  
enumerations XmlTypeAttribute XmlEnum
enumeration values XmlEnumAttribute XmlEnumValue
nested element sequence XmlArrayAttribute XmlElementWrapper
nested element sequence member XmlElement
XmlArrayItemAttribute
(sequence generation is implicit by contained element types and annotations)
choice disambiguation XmlChoiceIdentifierAttribute  
Any element XmlAnyElementAttribute XmlAnyElement
Any attribute XmlAnyAttributeAttribute XmlAnyAttribute
Exclusion from binding XmlIgnoreAttribute XmlAccessorType
XmlTransient
Order of binding Implied by class structure XmlAccessorOrder

Reference material is here:

Hope its useful.  Please add comments if you find mistakes or significant omissions.  Thanks.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s