/* (non-Javadoc)
   * @see org.jibx.binding.model.ElementBase#validate(org.jibx.binding.model.ValidationContext)
   */
  public void validate(ValidationContext vctx) {

    // call base class method first
    super.validate(vctx);

    // check for way to determine if named collection present on output
    if (vctx.isOutBinding()
        && hasName()
        && !hasProperty()
        && isOptional()
        && getTest() == null
        && !(vctx.getParentContainer() instanceof CollectionElement)) {
      vctx.addError("Need test method for optional collection output element");
    }

    // make sure only named element components are present
    ArrayList children = children();
    for (int i = 0; i < children.size(); i++) {
      IComponent child = (IComponent) children.get(i);
      if (child.hasAttribute()) {
        vctx.addFatal("Attributes not allowed as child components of collection", child);
      }
    }

    // check each child component
    if (m_itemTypeClass != null) {
      checkCollectionChildren(vctx, m_itemTypeClass, children);
    }

    // make sure child components can be distinguished
    if (children.size() > 1) {
      if (isOrdered()) {
        checkOrderedChildren(vctx, children);
      } else {
        checkUnorderedChildren(vctx, children);
      }
    }
  }