public static CaseComponent deserializeCaseComponent(Node node) {
    try {
      NamedNodeMap nodemap = node.getAttributes();
      String className = nodemap.getNamedItem("Class").getTextContent();
      CaseComponent cc = (CaseComponent) Class.forName(className).newInstance();

      NodeList nl = node.getChildNodes();
      for (int i = 0; i < nl.getLength(); i++) {
        Node child = nl.item(i);
        String nodeName = child.getNodeName();

        if (nodeName.equals("CaseComponent")) {
          Attribute at =
              new Attribute(
                  child.getAttributes().getNamedItem("Name").getTextContent(),
                  Class.forName(child.getAttributes().getNamedItem("Class").getTextContent()));
          AttributeUtils.setValue(at, cc, deserializeCaseComponent(child));
        } else {
          Attribute at = new Attribute(nodeName, cc.getClass());
          if (child.getFirstChild() != null) {
            String value = child.getFirstChild().getTextContent();
            Object oValue = PlainTextTypeConverter.convert(value, at.getType());
            AttributeUtils.setValue(at, cc, oValue);
          }
        }
      }
      return cc;
    } catch (Exception e) {
      org.apache.commons.logging.LogFactory.getLog(CaseComponentSerializer.class).error(e);
    }
    return null;
  }
  public static Element serializeCaseComponent(
      CaseComponent casecomponent, String name, Document doc) {
    try {
      Element root = doc.createElement("CaseComponent");
      root.setAttribute("Name", name);
      root.setAttribute("Class", casecomponent.getClass().getCanonicalName());
      root.setAttribute("IdAttribute", casecomponent.getIdAttribute().getName());

      for (Attribute at : AttributeUtils.getAttributes(casecomponent)) {
        if (CaseComponent.class.isAssignableFrom(at.getType()))
          root.appendChild(
              serializeCaseComponent(
                  (CaseComponent) at.getValue(casecomponent), at.getName(), doc));
        else {
          Element child = doc.createElement(at.getName());
          Object value = at.getValue(casecomponent);
          if (value != null) child.appendChild(doc.createTextNode(value.toString()));
          root.appendChild(child);
        }
      }

      return root;
    } catch (Exception e) {
      org.apache.commons.logging.LogFactory.getLog(CaseComponentSerializer.class).error(e);
    }
    return null;
  }