if (o instanceof AttributeHandler) {
AttributeHandler ah = (AttributeHandler) o;
attr.add(ah.compress(parent));
} else {
AttributeGroupHandler agh = (AttributeGroupHandler) o;
AttributeGroup ag = agh.compress(parent);
attr.addAll(Arrays.asList(ag.getAttributes()));
}
}
}
SimpleType st;
if ((ext.getBase() == null)
|| ext.getBase().equalsIgnoreCase("")) {
st = ((SimpleTypeHandler) ext.getChild()).compress(parent);
} else {
st = parent.lookUpSimpleType(ext.getBase());
}
dct.parent = st;
dct.simple = true;
} else {
// restriction
RestrictionHandler rest = (RestrictionHandler) sch.getChild();
// attributes
if (rest.getAttributeDeclarations() != null) {
Iterator it = rest.getAttributeDeclarations().iterator();
while (it.hasNext()) {
Object o = it.next();
if (o instanceof AttributeHandler) {
AttributeHandler ah = (AttributeHandler) o;
attr.add(ah.compress(parent));
} else {
AttributeGroupHandler agh = (AttributeGroupHandler) o;
AttributeGroup ag = agh.compress(parent);
attr.addAll(Arrays.asList(ag.getAttributes()));
}
}
}
SimpleType st = new SimpleTypeGT(id, name,
parent.getTargetNamespace(),
SimpleType.RESTRICTION,
SimpleTypeHandler.getSimpleTypes(rest, parent),
SimpleTypeHandler.getFacets(rest), finaL);
dct.parent = st;
dct.simple = true;
}
dct.mixed = true;
} else {
// ComplexContentHandler
// TODO deal with these as a special case to incure call backs in the heiarchy
ComplexContentHandler cch = (ComplexContentHandler) child;
if (cch.getChild() instanceof ExtensionHandler) {
ExtensionHandler ext = (ExtensionHandler) cch.getChild();
ComplexType ct = parent.lookUpComplexType(ext.getBase());
dct.parent = ct;
// attributes
if (ct!=null && ct.getAttributes() != null) {
Attribute[] it = ct.getAttributes();
for (int i = 0; i < it.length; i++) {
attr.add(it[i]);
}
}
if (ext.getAttributeDeclarations() != null) {
Iterator it = ext.getAttributeDeclarations().iterator();
while (it.hasNext()) {
Object o = it.next();
if (o instanceof AttributeHandler) {
AttributeHandler ah = (AttributeHandler) o;
attr.add(ah.compress(parent));
} else {
AttributeGroupHandler agh = (AttributeGroupHandler) o;
AttributeGroup ag = agh.compress(parent);
attr.addAll(Arrays.asList(ag.getAttributes()));
}
}
}
if (ct!=null && ext.getChild() != null) {
logger.finest("Looked up " + ext.getBase()
+ " and found "
+ ((ct == null) ? null
: (ct.getName() + ":::"
+ ct.getNamespace())) + " for " + name);
ElementGrouping extensionBaseType = ct.getChild();
ElementGrouping extensionChild = ((ElementGroupingHandler)ext.getChild()).compress(parent);
dct.child = loadNewEG(extensionBaseType,extensionChild, parent); // note should override element def only ... not spot
} else {
if (ct != null)
dct.child = ct.getChild();
}
} else {
//restriction
RestrictionHandler ext = (RestrictionHandler) cch.getChild();
// attributes
if (ext.getAttributeDeclarations() != null) {
Iterator it = ext.getAttributeDeclarations().iterator();
while (it.hasNext()) {
Object o = it.next();
if (o instanceof AttributeHandler) {
AttributeHandler ah = (AttributeHandler) o;
attr.add(ah.compress(parent));
} else {
AttributeGroupHandler agh = (AttributeGroupHandler) o;
AttributeGroup ag = agh.compress(parent);
attr.addAll(Arrays.asList(ag.getAttributes()));
}
}
}
if (ext.getChild() == null) {
dct.child = null; // empty child
} else {
dct.child = ((ElementGroupingHandler) ext.getChild())
.compress(parent);
}
dct.parent = parent.lookUpComplexType(ext.getBase());
}
if (dct.child == null) {
dct.child = new DefaultSequence();
}
dct.isDerived = true;
}
} else {
// one of Choice, Group, Sequence, All
// attributes
if (attrDecs != null) {
Iterator it = attrDecs.iterator();
while (it.hasNext()) {
Object o = it.next();
if (o instanceof AttributeHandler) {
AttributeHandler ah = (AttributeHandler) o;
attr.add(ah.compress(parent));
} else {
AttributeGroupHandler agh = (AttributeGroupHandler) o;
AttributeGroup ag = agh.compress(parent);
attr.addAll(Arrays.asList(ag.getAttributes()));
}
}
}
if (child != null) {