public void complainAboutUnknownAttributes(String elementXpath,String... knownAttributes){
  SortedMap<String,SortedSet<String>> problems=new TreeMap<>();
  NodeList nodeList=getNodeList(elementXpath,false);
  for (int i=0; i < nodeList.getLength(); ++i) {
    Element element=(Element)nodeList.item(i);
    Set<String> unknownAttributes=getUnknownAttributes(element,knownAttributes);
    if (null != unknownAttributes) {
      String elementName=element.getNodeName();
      SortedSet<String> allUnknownAttributes=problems.get(elementName);
      if (null == allUnknownAttributes) {
        allUnknownAttributes=new TreeSet<>();
        problems.put(elementName,allUnknownAttributes);
      }
      allUnknownAttributes.addAll(unknownAttributes);
    }
  }
  if (problems.size() > 0) {
    StringBuilder message=new StringBuilder();
    for (    Map.Entry<String,SortedSet<String>> entry : problems.entrySet()) {
      if (message.length() > 0) {
        message.append(", ");
      }
      message.append('<');
      message.append(entry.getKey());
      for (      String attributeName : entry.getValue()) {
        message.append(' ');
        message.append(attributeName);
        message.append("=\"...\"");
      }
      message.append('>');
    }
    message.insert(0,"Unknown attribute(s) on element(s): ");
    String msg=message.toString();
    SolrException.log(log,msg);
    throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,msg);
  }
}

public void complainAboutUnknownAttributes ( String elementXpath , String ... knownAttributes ) { SortedMap < String , SortedSet < String > > problems = new TreeMap < > ( ) ; NodeList nodeList = getNodeList ( elementXpath , false ) ; for ( int i = 0 ; i < nodeList . getLength ( ) ; ++ i ) { Element element = ( Element ) nodeList . item ( i ) ; Set < String > unknownAttributes = getUnknownAttributes ( element , knownAttributes ) ; if ( null != unknownAttributes ) { String elementName = element . getNodeName ( ) ; SortedSet < String > allUnknownAttributes = problems . get ( elementName ) ; if ( null == allUnknownAttributes ) { allUnknownAttributes = new TreeSet < > ( ) ; problems . put ( elementName , allUnknownAttributes ) ; } allUnknownAttributes . addAll ( unknownAttributes ) ; } } if ( problems . size ( ) > 0 ) { StringBuilder message = new StringBuilder ( ) ; for ( Map . Entry < String , SortedSet < String > > entry : problems . entrySet ( ) ) { if ( message . length ( ) > 0 ) { message . append ( ", " ) ; } message . append ( '<' ) ; message . append ( entry . getKey ( ) ) ; for ( String attributeName : entry . getValue ( ) ) { message . append ( ' ' ) ; message . append ( attributeName ) ; message . append ( "=\"...\"" ) ; } message . append ( '>' ) ; } message . insert ( 0 , "Unknown attribute(s) on element(s): " ) ; String msg = message . toString ( ) ; SolrException . log ( log , msg ) ; throw new SolrException ( SolrException . ErrorCode . SERVER_ERROR , msg ) ; } }
logs an error and throws an exception if any of the element ( s ) at the given elementxpath contains an attribute name that is not among knownattributes .
