private static void addXOPInclude(TypeBinding binding, SchemaBinding schema)
{
binding.setHandler(DefaultHandlers.XOP_HANDLER);
if(binding.getParticle() != null)
{
throw new JBossXBRuntimeException(
"XOP optimizable type has a particle which is unexpected, please, open a JIRA issue!"
);
}
TypeBinding anyUriType = schema.getType(Constants.QNAME_ANYURI);
if(anyUriType == null)
{
log.warn("Type " + Constants.QNAME_ANYURI + " not bound.");
}
TypeBinding xopIncludeType = new TypeBinding(new QName(Constants.NS_XOP_INCLUDE, "Include"));
xopIncludeType.setSchemaBinding(schema);
xopIncludeType.addAttribute(new QName("href"), anyUriType, DefaultHandlers.ATTRIBUTE_HANDLER);
xopIncludeType.setHandler(new XOPIncludeHandler(binding));
ElementBinding xopInclude = new ElementBinding(schema, new QName(Constants.NS_XOP_INCLUDE, "Include"), xopIncludeType);
ParticleBinding particleBinding = new ParticleBinding(xopInclude);
particleBinding.setMinOccurs(0);
binding.addParticle(particleBinding);
}