protected void updateFromMirror() {
        setTag(mirroredElement.getTag());

        int numOfAtts = getNumberOfAttributes();
        int numMirroredAtts = mirroredElement.getNumberOfAttributes();
        if (numOfAtts < numMirroredAtts) {
            for (int i = 0; i < numOfAtts; i++) {
                String attName = mirroredElement.getAttributeName(i);
                String attVal = mirroredElement.getAttribute(attName);
                setAttribute(i, attName, attVal);
            }

            for (int i = numOfAtts; i < numMirroredAtts; i++) {
                String attName = mirroredElement.getAttributeName(i);
                String attVal = mirroredElement.getAttribute(attName);
                setAttribute(attName, attVal);
            }
        } else if (numOfAtts == numMirroredAtts) {
            for (int i = numOfAtts; i < numMirroredAtts; i++) {
                String attName = mirroredElement.getAttributeName(i);
                String attVal = mirroredElement.getAttribute(attName);
                setAttribute(attName, attVal);
            }
        } else {
            for (int i = 0; i < numMirroredAtts; i++) {
                String attName = mirroredElement.getAttributeName(i);
                String attVal = mirroredElement.getAttribute(attName);
                setAttribute(i, attName, attVal);
            }
            for (int i = numMirroredAtts; i < numOfAtts; i++) {
                attributes.remove(i);
            }
        }

        text = mirroredElement.getText();

        int numOfChildren = getNumberOfChildren();
        int numOfMirroredChildren = mirroredElement.getNumberOfChildren();
        if (numOfChildren < numOfMirroredChildren) {
            Element newestChild = mirroredElement.getYoungestChild();
            Element child = new Element();
            child.mirrorElement(newestChild);
            addChild(child);
        } else if (numOfChildren > numOfMirroredChildren) {
            int childIndex = numOfChildren - 1;
            children.remove(childIndex);
        }
    }