@Override
  public Document clone() {
    final Document doc = (Document)super.clone();

    // The clone has a reference to this object's content list, so
    // overwrite with an empty list
    doc.content = new ContentList(doc);

    // Add the cloned content to clone

    for (int i = 0; i < content.size(); i++) {
      Object obj = content.get(i);
      if (obj instanceof Element) {
        Element element = ((Element)obj).clone();
        doc.content.add(element);
      }
      else if (obj instanceof Comment) {
        Comment comment = ((Comment)obj).clone();
        doc.content.add(comment);
      }
      else if (obj instanceof ProcessingInstruction) {
        ProcessingInstruction pi = ((ProcessingInstruction)obj).clone();
        doc.content.add(pi);
      }
      else if (obj instanceof DocType) {
        DocType dt = ((DocType)obj).clone();
        doc.content.add(dt);
      }
    }

    return doc;
  }
@Override
  public Document clone()