docs: public static int setValue(Document document, String xPath, String value, String nodeToInsert) {
  
          int changes = 0;
          // be naive and try to find the node
          Iterator<Node> itNodes = CmsCollectionsGenericWrapper.<Node> list(document.selectNodes(xPath)).iterator();
  
          // if not found
          if (!itNodes.hasNext()) {
              if (value == null) {
                  // if no node found for deletion
                  return 0;
              }
              // find the node creating missing nodes in the way
              Iterator<String> it = CmsStringUtil.splitAsList(xPath, "/", false).iterator();
              Node currentNode = document;
              while (it.hasNext()) {
                  String nodeName = it.next();
                  // if a string condition contains '/'
                  while ((nodeName.indexOf("='") > 0) && (nodeName.indexOf("']") < 0)) {
                      nodeName += "/" + it.next();
                  }
                  Node node = currentNode.selectSingleNode(nodeName);
                  if (node != null) {
                      // node found
                      currentNode = node;
                      if (!it.hasNext()) {
                          currentNode.setText(value);
                      }
                  } else if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
                      Element elem = (Element)currentNode;
                      if (!nodeName.startsWith("@")) {
                          elem = handleNode(elem, nodeName);
                          if (!it.hasNext() && CmsStringUtil.isNotEmptyOrWhitespaceOnly(value)) {
                              elem.setText(value);
                          }
                      } else {
                          // if node is attribute create it with given value
                          elem.addAttribute(nodeName.substring(1), value);
                      }
                      currentNode = elem;
                  } else {
                      // should never happen
                      if (LOG.isDebugEnabled()) {
                          LOG.debug(Messages.get().getBundle().key(Messages.ERR_XML_SET_VALUE_2, xPath, value));
                      }
                      break;
                  }
              }
              if (nodeToInsert == null) {
                  // if not inserting we are done
                  return 1;
              }
              // if inserting, we just created the insertion point, so continue
              itNodes = CmsCollectionsGenericWrapper.<Node> list(document.selectNodes(xPath)).iterator();
          }
  
          // if found
          while (itNodes.hasNext()) {
              Node node = itNodes.next();
              if (nodeToInsert == null) {
                  // if not inserting
                  if (value != null) {
                      // if found, change the value
                      node.setText(value);
                  } else {
                      // if node for deletion is found
                      node.getParent().remove(node);
                  }
              } else {
                  // first create the node to insert
                  Element parent = node.getParent();
                  Element elem = handleNode(parent, nodeToInsert);
                  if (value != null) {
                      elem.setText(value);
                  }
                  // get the parent element list
                  List<Node> list = CmsCollectionsGenericWrapper.<Node> list(parent.content());
                  // remove the just created element
                  list.remove(list.size() - 1);
                  // insert it back to the right position
                  int pos = list.indexOf(node);
                  list.add(pos + 1, elem); // insert after
              }
              changes++;
          }
          return changes;
      }