XMLComplexElement cmplxEl = (XMLComplexElement) el;
Iterator it = ((XMLComplexElement) tmplEl).toElementMap().entrySet().iterator();
while (it.hasNext()) {
Map.Entry me = (Map.Entry) it.next();
String subElName = (String) me.getKey();
XMLElement subEl = (XMLElement) me.getValue();
if (!subEl.isEmpty()) {
if (!compareToTemplate(topEl, cmplxEl.get(subElName), subEl)) {
ret = false;
break;
}
}
}
}
} else if (el instanceof XMLCollection) {
if (!tmplEl.toValue().equals("") && !tmplEl.toValue().equals(el.toValue())) {
ret = false;
} else {
XMLCollection col = (XMLCollection) el;
List cels = ((XMLCollection) tmplEl).toElements();
for (int i = 0; i < cels.size(); i++) {
XMLElement tcel = (XMLElement) cels.get(i);
if (tcel instanceof ActualParameter || tcel instanceof FormalParameter) {
if (!compareToTemplate(topEl, col.get(i), tcel)) {
ret = false;
break;
}
} else {
boolean btt = false;
for (int j = 0; j < col.size(); j++) {
XMLElement e = (XMLElement) col.get(j);
if (compareToTemplate(topEl, e, tcel)) {
btt = true;
break;
}
}
if (!btt) {
ret = btt;
}
}
}
}
} else if (el instanceof XMLComplexChoice) {
XMLElement tmplChsn = ((XMLComplexChoice) tmplEl).getChoosen();
XMLElement elChsn = ((XMLComplexChoice) el).getChoosen();
ret = compareToTemplate(topEl, elChsn, tmplChsn);
}
} else {
ret = false;
}