Esempio n. 1
0
  private void toXML(final Element parent) {
    final Document doc = parent.getOwnerDocument();
    final Element sessionElem = XMLTool.createElement(doc, parent, "session");

    for (final Map.Entry<String, Object> entry : entrySet()) {
      final Element attributeElem = XMLTool.createElement(doc, sessionElem, "attribute");
      attributeElem.setAttribute("name", entry.getKey());

      final Object value = entry.getValue();
      if (value instanceof Document) {
        final Document xmlDoc = (Document) value;
        final Element rootElem = xmlDoc.getDocumentElement();
        attributeElem.appendChild(doc.importNode(rootElem, true));
      } else if (value != null) {
        XMLTool.createTextNode(doc, attributeElem, value.toString());
      }
    }
  }