long childGID = firstChildID(); if (childGID < 0) childGID = 1; child.setGID(childGID + children); if (child.getGID() == StoredNode.NODE_IMPL_UNKNOWN_GID) { final DocumentImpl owner = (DocumentImpl)getOwnerDocument(); final int level = owner.getTreeLevel(getGID()); final int order = owner.getTreeLevelOrder(level); throw new DOMException(DOMException.INVALID_STATE_ERR, "internal error: node " + getGID() + "; first-child: " + firstChildID() + "; level: " + level + "; maxDepth: " + owner.getMaxDepth() + "; order(level+1): " + order + "; start0: " + owner.getLevelStartPoint(level) + "; start1: " + owner.getLevelStartPoint(level + 1)); } } else  child.setGID(0);
    public void appendChildInternal(StoredNode prevNode, StoredNode child) throws DOMException {        //TOUNDERSTAND : what are the semantics of this 0 ? -pb        if (getGID() > 0) {            NodeId childId;            if (prevNode == null)                childId = getNodeId().newChild();            else {                childId = prevNode.getNodeId().nextSibling();            }            child.setNodeId(childId);            long childGID = firstChildID();            if (childGID < 0)                childGID = 1;            child.setGID(childGID + children);            if (child.getGID() == StoredNode.NODE_IMPL_UNKNOWN_GID) {                final DocumentImpl owner = (DocumentImpl)getOwnerDocument();                final int level = owner.getTreeLevel(getGID());                final int order = owner.getTreeLevelOrder(level);                throw new DOMException(DOMException.INVALID_STATE_ERR,                        "internal error: node "                        + getGID()                        + "; first-child: "                        + firstChildID()                        + "; level: "                        + level                        + "; maxDepth: "                        + owner.getMaxDepth()                        + "; order(level+1): "                        + order                        + "; start0: "                        + owner.getLevelStartPoint(level)                        + "; start1: "                        + owner.getLevelStartPoint(level + 1));            }        }        else            //TOUNDERSTAND : what are the semantics of this 0 ? -pb            child.setGID(0);        ++children;    }