public final void parseDoc(Document doc) {
        if (doc == null) {
            throw new IllegalArgumentException("Xml document cannot be null");
        }
        Element elem = (Element) doc.getElementsByTagName("KeyedFile").item(0);

        fileName = elem.getAttribute("path");
        if (fileName == null || "".equals(fileName)) {
            throw new RuntimeException("Keyed File name cannot be empty");
        }
        
        keyLength = Integer.parseInt(elem.getAttribute("keySize"));
        if (keyLength <= 0) {
            throw new RuntimeException("Key length must be a positive integer");
        }
        recordSize = Integer.parseInt(elem.getAttribute("recordSize"));
        if (recordSize <= 0) {
            throw new RuntimeException("Record size must be a positive integer");
        }

        Node parent = doc.getElementsByTagName("DefaultRecord").item(0);
        NodeList xFields = doc.getElementsByTagName("Field");
        int n = xFields.getLength();
        ArrayList al = new ArrayList(n);
        KFileField kff;
        for (int k = 0; k < n; k++) {
            elem = (Element) xFields.item(k);
            if (elem.getParentNode().equals(parent))
            {
                kff = new KFileField();
                kff.name = elem.getAttribute("name");
                kff.start = Integer.parseInt(elem.getAttribute("position"));
                kff.size = Integer.parseInt(elem.getAttribute("size"));
                kff.end = kff.start + kff.size;
                kff.type = elem.getAttribute("type");
                al.add(kff);
                kff = null;
            }
        }
        Collections.sort(al);
        fields = new KFileField[al.size()];
        al.toArray(fields);
    }