type.setLax(part.isLax());
for (int i = 0, nCount = part.getPartCount(); i < nCount; i++)
{
MessagePart child = part.getPart(i);
// Omit parts declared in base message
if (message != null && child.getDeclarator() != message)
{
continue;
}
boolean bChildEnvelopeHeaders = child.getRoot() == part &&
child == ((RootXMLMessagePartMapping)mapping).getHeaderPart();
XMLMessagePartMapping childMapping = (XMLMessagePartMapping)child.getMapping();
if (child instanceof PrimitiveMessagePart)
{
if (bChildEnvelopeHeaders)
{
continue;
}
if (childMapping.getNodeType() == XMLMessagePartMapping.VALUE)
{
type.setValueType(getAtomicType((PrimitiveMessagePart)child));
}
else
{
Markup markup = createMarkup((PrimitiveMessagePart)child);
if (!isEnvelopeMarkup(markup))
{
type.addChild(markup);
}
if (bEnvelopeHeaders)
{
addEnvelopeHeader(child, (Element)markup, false);
}
}
}
else if (child instanceof CompositeMessagePart)
{
CompositeType childType;
Element childElement;
if (child instanceof CompositeMessagePartRef)
{
CompositeMessagePart referentPart = ((CompositeMessagePartRef)child).getRefPart();
Message referentMessage = ((RootXMLMessagePartMapping)referentPart.getMapping()).getRootMessage();
childType = createCompositeType(referentPart, referentMessage);
childElement = new Element(childMapping.getNodeName());
childElement.setType(childType);
childElement.setDescription(child.getDescription());
if (bEnvelopeHeaders)
{
addEnvelopeHeader(child, childElement, true);
}
}
else
{
XMLNamespace childNamespace = childMapping.getNamespace();
String sURI = (childNamespace == null) ? null : childNamespace.getURI();
if (sURI != null && !sURI.equals(m_sNamespaceURI))
{
// Element reference (different namespace)
String sCurrentNamespace = m_sNamespaceURI;
Schema otherNSSchema = m_universe.getSchema(sURI, childNamespace.getName());
m_sNamespaceURI = sURI;
childType = createCompositeType((CompositeMessagePart)child, null);
Element otherNSElement = new Element(childMapping.getNodeName());
setElementProperties(otherNSElement, (CompositeMessagePart)child);
otherNSElement.setType(childType);
otherNSElement.setDescription(child.getDescription());
otherNSSchema.addItem(otherNSElement);
childElement = new ElementRef(otherNSElement);
m_sNamespaceURI = sCurrentNamespace;
if (bEnvelopeHeaders)
{
addEnvelopeHeader(child, childElement, false);
}
}
else
{
// Anonymous type (same namespace)
childType = createCompositeType((CompositeMessagePart)child, null);
childElement = new Element(childMapping.getNodeName());
childElement.setType(childType);
childElement.setDescription(child.getDescription());
if (bEnvelopeHeaders)
{
addEnvelopeHeader(child, childElement, true);
}