} //end for
}
private void appendComplexTypeDefinition(StringBuilder buf, XSComplexTypeDefinition jxstype)
{
XSParticle xsp = jxstype.getParticle();
XSTerm xsterm = xsp.getTerm();
short deriveMethod = jxstype.getDerivationMethod();
if (xsterm instanceof XSElementDeclaration)
{
// FIXME This is horribly wrong, but too much depends on this broken behavior
buf.append("<sequence>");
XSElementDeclaration xsel = (XSElementDeclaration)xsterm;
buf.append(this.write(xsel, xsp));
buf.append("</sequence>");
}
else if (xsterm instanceof XSModelGroup)
{
XSModelGroup jmg = (XSModelGroup)xsterm;
XSObjectList objlist = jmg.getParticles();
String end = null;
switch (jmg.getCompositor())
{
case XSModelGroup.COMPOSITOR_ALL:
buf.append("<all>");
end = "</all>";
break;
case XSModelGroup.COMPOSITOR_CHOICE:
buf.append("<choice>");
end = "</choice>";
break;
default:
case XSModelGroup.COMPOSITOR_SEQUENCE:
buf.append("<sequence>");
end = "</sequence>";
break;
}
int lenobj = objlist != null ? objlist.getLength() : 0;
for (int i = 0; i < lenobj; i++)
{
XSParticle jxsp = (XSParticle)objlist.item(i);
XSTerm xterm = jxsp.getTerm();
if (xterm instanceof XSElementDeclaration)
{
XSElementDeclaration xsel = (XSElementDeclaration)jxsp.getTerm();
buf.append(this.write(xsel, jxsp));
}
else if (xterm instanceof XSModelGroup)
{
if (deriveMethod == XSConstants.DERIVATION_EXTENSION && i != lenobj - 1)
continue;
if (i == 0)
continue;//Ignore as it provides the baseclass sequence of elements
XSObjectList olist = ((XSModelGroup)xterm).getParticles();
int lobj = olist != null ? olist.getLength() : 0;
for (int k = 0; k < lobj; k++)
{
XSParticle jxp = (XSParticle)olist.item(k);
XSTerm jxpterm = jxp.getTerm();
short termType = jxpterm.getType();
if (termType == XSConstants.ELEMENT_DECLARATION)
buf.append(write((XSElementDeclaration)jxpterm, jxsp));
else if (termType == XSConstants.MODEL_GROUP)
buf.append(write((XSModelGroup)jxpterm));