Tuesday, 3 January 2012

JAXB Notes

  • marshall/unmarshall event callbacks (alternative to listener):
    • beforeUnmarshal
    • afterUnmarshal
    • beforeMarshal
    • afterMarshal
  • javax.xml.bind.Binder: partial binding to a Java representation (updateXML/updateJAXB methods)
  • JAXBElement offers support for:
    • type substitution (xsi:type)
    • element substitution groups (xsd:substitutionGroup)
    • wildcards (xsd:any, xsd:anyAttribute)
    • Whereas an instance of a Java value class or content interface only represents the value of an element, an instance of JAXBElement represents all element declaration features (qualified name, value, type, nil and scope)
    • JAX-WS strips the JAXBElement wrapper off the type of a method parameter
    • The original schema is more precise for validation purposes than the one generated from the schema-derived classes
    • The default binding rule only generates an "element property" when a property represents an element that is substitutable
    • The default bindings for mixed content and wildcard result in a hybrid mixture of strongly typed Java instances with DOM nodes or java.lang.String, representing text info