class XModifier {

    private void create(Node parent, XModifyNode node) throws XPathExpressionException {
        Node newNode;
        if (node.isAttributeModifier()) {
            //attribute
            createAttributeByXPath(parent, node.getCurNode().substring(1), node.getValue());
        } else {
            //element
            if (node.isRootNode()) {
                //root node
                newNode = parent;
                boolean canMoveToNext = node.moveNext();
                if (!canMoveToNext) {
                    //last node
                    newNode.setTextContent(node.getValue());
                } else {
                    //next node
                    create(newNode, node);
                }
            } else if (node.getCurNode().equals("text()")) {
                parent.setTextContent(node.getValue());
            } else {
                //element
                findOrCreateElement(parent, node);
            }
        }

    }

    public  XModifier(Document document);

}