private void validatAllGroupContent(List elementContent, ElementContentComparator comparator, CMGroup allGroup, Result result)
{
boolean isValid = true;
boolean isPartiallyValid = true;
HashMap map = new HashMap();
CMNodeList list = allGroup.getChildNodes();
for (int j = list.getLength() - 1; j >= 0; j--)
{
CMNode node = list.item(j);
if (map.get(node) == null)
{
map.put(node, new ItemCount());
}
}
int validitionCount = 0;
for (Iterator i = elementContent.iterator(); i.hasNext(); validitionCount++)
{
Object o = i.next();
if (comparator.isElement(o))
{
// test to see if the element is listed in the all group
//
CMNode matchingCMNode = null;
for (int j = list.getLength() - 1; j >= 0; j--)
{
CMNode node = list.item(j);
if (comparator.matches(o, node))
{
matchingCMNode = node;
break;
}
}
if (matchingCMNode == null)
{
isPartiallyValid = false;
isValid = false;
break;
}
else
{
// test to see that the element occurs only once
//
ItemCount itemCount = (ItemCount)map.get(matchingCMNode);
if (itemCount != null)
{
if (itemCount.count > 0)
{
// we don't want to allow too many elements!
// we consider 'not enough' to be partially valid... but not 'too many'
isPartiallyValid = false;
break;
}
else
{
itemCount.count++;
}
}
}
}
}
if (isValid)
{
for (int j = list.getLength() - 1; j >= 0; j--)
{
CMNode node = list.item(j);
if (node.getNodeType() == CMNode.ELEMENT_DECLARATION)
{
CMContent content = (CMContent)node;
ItemCount itemCount = (ItemCount)map.get(node);
// System.out.print("content " + content.getNodeName() + " " + content.getMinOccur());