/**
  * Unconditionally clone an InDesign Object.
  *
  * @param sourceObj
  * @return The clone of the object.
  * @throws Exception
  */
 public InDesignComponent clone(InDesignObject sourceObj) throws Exception {
   logger.debug(
       "Cloning object "
           + sourceObj.getClass().getSimpleName()
           + " ["
           + sourceObj.getId()
           + "]...");
   InDesignObject clone = sourceObj.getClass().newInstance();
   assignIdAndRegister(clone);
   // Now remember that we've cloned this source object so we can not
   // clone it again if we don't want to:
   Map<String, InDesignObject> cloneMap = getCloneMapForDoc(sourceObj.getDocument());
   cloneMap.put(sourceObj.getId(), clone);
   clone.loadObject(sourceObj, clone.getId());
   return clone;
 }
  /**
   * @param class1
   * @param dataSource
   * @return
   * @throws Exception
   * @throws InstantiationException
   */
  private InDesignComponent newObject(Class<? extends InDesignObject> clazz, Element dataSource)
      throws Exception {
    logger.debug("newObject(): Creating new " + clazz.getSimpleName() + "...");
    InDesignObject obj = (InDesignObject) clazz.newInstance();
    obj.setDocument(this);
    if (dataSource != null) {
      logger.debug("newObject():   From element " + dataSource.getNodeName() + "...");
      obj.loadObject(dataSource);
      String selfValue = dataSource.getAttribute(PROP_SELF);
      if (selfValue != null && !"".equals(selfValue.trim())) {
        String id = InxHelper.decodeRawValueToSingleString(selfValue);
        obj.setId(id);
        this.registerObject(obj);
      } else {
        assignIdAndRegister(obj);
      }

    } else {
      assignIdAndRegister(obj);
    }
    logger.debug("newObject(): New object has ID [" + obj.getId() + "]");
    return obj;
  }