@Override
public void init( final Element modelElement )
{
super.init( modelElement );
final ElementType modelElementType = modelElement.type();
final CustomXmlRootBinding customXmlRootBindingAnnotation = modelElementType.getAnnotation( CustomXmlRootBinding.class );
if( customXmlRootBindingAnnotation != null )
{
try
{
this.rootElementController = customXmlRootBindingAnnotation.value().newInstance();
}
catch( Exception e )
{
Sapphire.service( LoggingService.class ).log( e );
}
}
if( this.rootElementController == null )
{
final XmlBinding xmlBindingAnnotation = modelElementType.getAnnotation( XmlBinding.class );
if( xmlBindingAnnotation != null && xmlBindingAnnotation.path().length() != 0 )
{
final XmlPath path = new XmlPath( xmlBindingAnnotation.path(), getXmlNamespaceResolver() );
final QName qualifiedName = path.getSegment( 0 ).getQualifiedName();
final String localName = qualifiedName.getLocalPart();
final String prefix = qualifiedName.getPrefix();
final String namespace = qualifiedName.getNamespaceURI();
final XmlDocumentType xmlDocumentTypeAnnotation = modelElementType.getAnnotation( XmlDocumentType.class );
if( xmlDocumentTypeAnnotation != null && xmlDocumentTypeAnnotation.systemId().length() != 0 )
{
this.rootElementController = new DocumentTypeRootElementController( localName );
}
else
{
final Map<String,String> schemas = new HashMap<String,String>();
final XmlSchemas xmlSchemasAnnotation = modelElementType.getAnnotation( XmlSchemas.class );
if( xmlSchemasAnnotation != null )
{
for( XmlSchema xmlSchemaAnnotation : xmlSchemasAnnotation.value() )
{
final String xmlSchemaNamespace = xmlSchemaAnnotation.namespace().trim();
final String xmlSchemaLocation = xmlSchemaAnnotation.location().trim();
if( xmlSchemaNamespace.length() != 0 && xmlSchemaLocation.length() != 0 )
{
schemas.put( xmlSchemaNamespace, xmlSchemaLocation );
}
}
}
final XmlSchema xmlSchemaAnnotation = modelElementType.getAnnotation( XmlSchema.class );
if( xmlSchemaAnnotation != null )
{
final String xmlSchemaNamespace = xmlSchemaAnnotation.namespace().trim();
final String xmlSchemaLocation = xmlSchemaAnnotation.location().trim();