XSElementDeclaration elemDecl, final XSComplexTypeDefinition complexDef, String sNodeName, String sNamespace,
boolean bNillable, Message msgArray[])
{
assert isComposite(complexDef, parent == null);
CompositeMessagePartInstance newInstance;
Message newMsg = null;
String sMsgName = sNodeName;
XSComplexTypeDefinition base = findBase(complexDef);
if (parent == null)
{
sMsgName = generateMessageName(sMsgName);
registerMessageName(sMsgName);
newMsg = new Message(sMsgName);
m_msgList.add(newMsg);
if (msgArray != null)
{
msgArray[0] = newMsg;
}
if (m_metadata != null)
{
newMsg.setMetadata(m_metadata);
newMsg.setFormat(m_metadata.getFormat("XML"));
}
if (isRegistered(complexDef))
{
String sName = generateDefaultMessageName(sNodeName, null);
CompositeMessagePartRef ref = new CompositeMessagePartRef(sName);
ref.setDescription(sElemDesc);
newMsg.setRoot(ref);
setMapping(ref, newMsg, sNodeName, sNamespace, bNillable, complexDef);
addFixup(new MessageRefFixup(ref, sNodeName, sNamespace, bNillable, complexDef));
return ref;
}
registerMessage(complexDef, newMsg);
newInstance = new CompositeMessagePartInstance(sMsgName);
newMsg.setRoot(newInstance);
if (base != null)
{
addFixup(new MessageBaseFixup(base, newMsg));
}
}
else
{
sMsgName = generateDefaultMessageName(sNodeName,
new INameConflictChecker()
{
public boolean conflicts(String name)
{
return parent.hasPart(name);
}
});
assert base == null || elemDecl != null;
if (base != null && elemDecl != null)
{
StringBuilder builder = new StringBuilder(sMsgName);
for (CompositeMessagePartInstance ancestor = parent; ancestor != null; ancestor = ancestor.getParent())
{
builder.insert(0, ancestor.getName() + "_");
}
create(complexDef, builder.toString());
return createRef(parent, elemDecl, sMsgName);
}
base = null;
newInstance = new CompositeMessagePartInstance(sMsgName);
newInstance.setParent(parent);
}
XSObjectList annotationList = complexDef.getAnnotations();
if (annotationList != null && annotationList.getLength() > 0)
{
StringBuilder buffer = new StringBuilder();
if (sElemDesc != null)
{
buffer.append(sElemDesc);
}
for (int i = 0; i < annotationList.getLength(); ++i)
{
XSAnnotation annotation = (XSAnnotation)annotationList.item(i);
String sDescription = parseDescription(annotation);
if (sDescription != null)
{
if (buffer.length() > 0)
{
buffer.append("\r");
}
buffer.append(sDescription);
}
}
if (buffer.length() > 0)
{
newInstance.setDescription(buffer.toString());
}
}
else
{
newInstance.setDescription(sElemDesc);
}
setMapping(newInstance, newMsg, sNodeName, sNamespace, bNillable, complexDef);
addAttributeParts(newInstance, complexDef, base);
addChildParts(newInstance, EMPTY_PARTICLE_ARRAY, complexDef, base, null);