/** Removes all the unused attributes after a conversion */
  private void removeUndefinedAttrs(MultiTextEdit rootEdit, Element element) {
    ViewElementDescriptor descriptor = getElementDescriptor(mTypeFqcn);
    if (descriptor == null) {
      return;
    }

    Set<String> defined = new HashSet<String>();
    AttributeDescriptor[] layoutAttributes = descriptor.getAttributes();
    for (AttributeDescriptor attribute : layoutAttributes) {
      defined.add(attribute.getXmlLocalName());
    }

    List<Attr> attributes = findAttributes(element);
    for (Attr attribute : attributes) {
      String name = attribute.getLocalName();
      if (!defined.contains(name)) {
        // Remove it
        removeAttribute(rootEdit, element, attribute.getNamespaceURI(), name);
      }
    }

    // Set text attribute if it's defined
    if (defined.contains(ATTR_TEXT) && !element.hasAttributeNS(ANDROID_URI, ATTR_TEXT)) {
      setAttribute(
          rootEdit,
          element,
          ANDROID_URI,
          getAndroidNamespacePrefix(),
          ATTR_TEXT,
          descriptor.getUiName());
    }
  }
 // ---- Implements Comparable ----
 @Override
 public int compareTo(UiAttributeNode o) {
   return compareAttributes(mDescriptor.getXmlLocalName(), o.mDescriptor.getXmlLocalName());
 }