String tmpl = null;
StateMachineRootNode sm = stateMachineMap.get(parentType);
boolean isChildOfUnreferencedTopLevelElement = false;
XSElementDeclaration parentElement = null;
ElementUsage elementUsage = completeElementUsage.get(element.getName());
List<XSElementDeclaration> parents = elementUsage.collectParents();
for (XSElementDeclaration parent : parents) {
if (parent.getTypeDefinition() == parentType) {
parentElement = parent;
break;
}
}
if (parentElement != null && !parentElement.getName().equals(config.getRootElementName())) {
if (parentElement.getSubstitutionGroupAffiliation() == null) {
ElementUsage parentUsage = completeElementUsage.get(parentElement.getName());
if (parentUsage.collectParents().isEmpty()) {
isChildOfUnreferencedTopLevelElement = true;
}
}
}
if (isChildOfUnreferencedTopLevelElement) {
tmpl = "#ind##ind#// no validation because is child of unreferenced top level element#nl#";
if (parentElement != null && parentElement.getName() != null) {
tmpl += "#ind##ind#// parent element: " + parentElement.getName() + "#nl#";
}
} else {
if (sm == null) {
tmpl = config.getTemplateComplexValidationChildValidateBegin();
} else {