public static void writeCustomAttributes(Collection<List<ExtensionAttribute>> attributes,XMLStreamWriter xtw,Map<String,String> namespaceMap,List<ExtensionAttribute>... blackLists) throws XMLStreamException {
  for (  List<ExtensionAttribute> attributeList : attributes) {
    if (attributeList != null && !attributeList.isEmpty()) {
      for (      ExtensionAttribute attribute : attributeList) {
        if (!isBlacklisted(attribute,blackLists)) {
          if (attribute.getNamespacePrefix() == null) {
            if (attribute.getNamespace() == null)             xtw.writeAttribute(attribute.getName(),attribute.getValue());
 else {
              xtw.writeAttribute(attribute.getNamespace(),attribute.getName(),attribute.getValue());
            }
          }
 else {
            if (!namespaceMap.containsKey(attribute.getNamespacePrefix())) {
              namespaceMap.put(attribute.getNamespacePrefix(),attribute.getNamespace());
              xtw.writeNamespace(attribute.getNamespacePrefix(),attribute.getNamespace());
            }
            xtw.writeAttribute(attribute.getNamespacePrefix(),attribute.getNamespace(),attribute.getName(),attribute.getValue());
          }
        }
      }
    }
  }
}

public static void writeCustomAttributes ( Collection < List < ExtensionAttribute > > attributes , XMLStreamWriter xtw , Map < String , String > namespaceMap , List < ExtensionAttribute > ... blackLists ) throws XMLStreamException { for ( List < ExtensionAttribute > attributeList : attributes ) { if ( attributeList != null && ! attributeList . isEmpty ( ) ) { for ( ExtensionAttribute attribute : attributeList ) { if ( ! isBlacklisted ( attribute , blackLists ) ) { if ( attribute . getNamespacePrefix ( ) == null ) { if ( attribute . getNamespace ( ) == null ) xtw . writeAttribute ( attribute . getName ( ) , attribute . getValue ( ) ) ; else { xtw . writeAttribute ( attribute . getNamespace ( ) , attribute . getName ( ) , attribute . getValue ( ) ) ; } } else { if ( ! namespaceMap . containsKey ( attribute . getNamespacePrefix ( ) ) ) { namespaceMap . put ( attribute . getNamespacePrefix ( ) , attribute . getNamespace ( ) ) ; xtw . writeNamespace ( attribute . getNamespacePrefix ( ) , attribute . getNamespace ( ) ) ; } xtw . writeAttribute ( attribute . getNamespacePrefix ( ) , attribute . getNamespace ( ) , attribute . getName ( ) , attribute . getValue ( ) ) ; } } } } } }
write attributes to xtw ( except blacklisted )
