Unresolved content of wildcards
Definition of the unresolved content
In case of unmarshalling, unresolved content is a content of an element of type any for which a schema to validate the content could not be found. Unresolved content can be handled differently, i.e. an exception can be thrown if the wildcard has processContent strinct, the content can be ignored, unmarshalled partially or completely if the default binding rules succeed (probably by accident) or unmarshalled using previously setup handlers for unresolved content.
In case of marshalling, unresolved content is a Java object that corresponds to a content of type any in the XML schema for which binding metadata could not be resolved. In other words, the corresponding schema component could not be found for the Java object. Depending on the configuration, an exception can be thrown that would terminate the marshalling process immediately, the Java object can be ignored or marshalled with the previously setup ObjectLocalMarshaller.
Configuration
WildcardBinding: unresolved marshaller, element and character handlers
WildcardBinding can have ParticleHandler, CharactersHandler and ObjectLocalMarshaller that will be used to handle unresolved content. They can be setup with
public ParticleHandler getUnresolvedElementHandler() public void setUnresolvedElementHandler(ParticleHandler unresolvedElementHandler) public CharactersHandler getUnresolvedCharactersHandler() public void setUnresolvedCharactersHandler(CharactersHandler unresolvedCharactersHandler) public ObjectLocalMarshaller getUnresolvedMarshaller() public void setUnresolvedMarshaller(ObjectLocalMarshaller marshaller)
Default DOM handlers and marshaller
There are utility classes that implement ParticleHandler and CharactersHandler to unmrshal XML content into a DOM element. And an implementation of the ObjectLocalMarshaller to marshal a DOM Element into an XML content. The classes are
org.jboss.xb.util.DomParticleHandler org.jboss.xb.util.DomCharactersHandler org.jboss.xb.util.DomLocalMarshaller
SchemaBinding::setUnresolvedContentBoundToDOM
SchemaBinding can be configured to bind unresolved content to DOM element by default. The SchemaBinding class has a method called setUnresolvedContentBoundToDOM which takes an argument of type boolean. Calling the method with true will bind unresolved content to DOM element by setting up the default DOM handlers and marshaller for the wildcards. Passing false to the method will set the unresolved content hendlers and marshaller of wildcards to null.
There is also a getUnresolvedContentBoundToDOM method that can be used to check whether unresolved content is bound to DOM or not.
XsdBinder::setUnresolvedContentBoundToDOM
XsdBinder has a boolean property unresolvedContentBoundToDOM. If it's true (it is by default), after parsing an XSD it will invoke setUnresolvedContentBoundToDOM(true) on the SchemaBinding.
Issues
Invoking SchemaBinding::setUnresolvedContentBoundToDOM(boolean value) will affect all the wildcards in the instance of the SchemaBinding (especially if the SchemaBinding was produced by the XsdBinder) since it binds the anyType which is one per schema. It would be better to be able to bind wildcards differently in different places in the schema.
Comments