/**
   * Select the default service.
   *
   * @param candidates the list of candiate services
   * @return the selected candidate or null
   */
  private AttributeConsumingService selectDefault(List<AttributeConsumingService> candidates) {
    log.debug("Selecting default AttributeConsumingService");
    AttributeConsumingService firstNoDefault = null;
    for (AttributeConsumingService attribCS : candidates) {
      if (attribCS.isDefault()) {
        log.debug("Selected AttributeConsumingService with explicit isDefault of true");
        return attribCS;
      }

      // This records the first element whose isDefault is not explicitly false
      if (firstNoDefault == null && attribCS.isDefaultXSBoolean() == null) {
        firstNoDefault = attribCS;
      }
    }

    if (firstNoDefault != null) {
      log.debug("Selected first AttributeConsumingService with no explicit isDefault");
      return firstNoDefault;
    } else {
      log.debug("Selected first AttributeConsumingService with explicit isDefault of false");
      return candidates.get(0);
    }
  }