binding = schemaBinding.getElement(startName);
}
}
else
{
throw new JBossXBRuntimeException("Neither schema binding nor schema binding resolver is not available!");
}
}
else
{
parentBinding = (ElementBinding)elementStack.peek();
if(parentBinding != null)
{
binding = parentBinding.getType().getElement(startName, atts);
schemaBinding = parentBinding.getSchema();
}
}
elementStack.push(binding);
if(binding != null)
{
TypeBinding typeBinding = binding.getType();
Object o = objectStack.isEmpty() ? null : objectStack.peek();
List elementHandlers = binding.getInterceptors();
for(int i = 0; i < elementHandlers.size(); ++i)
{
ElementInterceptor interceptor = (ElementInterceptor)elementHandlers.get(i);
o = interceptor.startElement(o, startName, typeBinding);
objectStack.push(o);
interceptor.attributes(o, startName, typeBinding, atts, nsRegistry);
}
// todo xsi:nil handling
String nil = atts.getValue("xsi:nil");
if(nil == null || !("1".equals(nil) || "true".equals(nil)))
{
o = typeBinding.startElement(o, startName, binding);
}
else
{
o = NIL;
}
objectStack.push(o);
if(o != null && o != NIL)
{
// Expand the attributes list with any missing attrs with defaults
atts = typeBinding.expandWithDefaultAttributes(atts);
typeBinding.attributes(o, startName, binding, atts, nsRegistry);
}
}
else if(schemaBinding != null && schemaBinding.isStrictSchema())
{
throw new JBossXBRuntimeException("Element " +
startName +
" is not bound " +
(parentBinding == null ? "as a global element." : "in type " + parentBinding.getType().getQName())
);
}