public void startElement(String uri, String localName, String qName,
			Attributes attributes) throws SAXException {

		// if the element name is valid and in the elementMap
		if (elementMap.containsKey(qName.toUpperCase())) {
			Element name = elementMap.get(qName.toUpperCase());
			// if the parent of the element is on the stack
			if (stack.peek() == parentMap.get(name))
				// push the element onto the stack
				stack.push(name);
			else {
				throw new SAXException("Element type " + qName
						+ " has incorrect nesting");
			}
		} else {
			throw new SAXException("Unknown Start Element Type: " + qName + ".");
		}

		String fileName;
		File csvFile;
		// switch mainly used to process attribute values of elements
		switch (stack.peek()) {
			case SIMDOMAIN:
				numLayer = Integer.parseInt(attributes.getValue("layers"));
				break;
			case SIMTIMESTEPS:
				Director.setTimeStep(Integer.parseInt(attributes
						.getValue("simsteptime")));
				break;
			case LAYER:
				if (!gridStart) {
					grid.setLimits(new Point(numRow, numCol), numLayer);
					grid.initializeAll();
					gridStart = true;
				}
				curLayer = Integer.parseInt(attributes.getValue("lay")) - 1;
				break;
			case TOP:
				fileName = attributes.getValue("src");
				csvFile = new File(xmlFile.getParentFile().getAbsolutePath(),fileName);
				grid.importCSV(csvFile, curLayer, Grid.LAYER);
				break;
			case OIL:
				fileName = attributes.getValue("src");
				csvFile = new File(xmlFile.getParentFile().getAbsolutePath(),fileName);
				grid.importCSV(csvFile, curLayer, Grid.OIL);
				break;
			case GAS:
				fileName = attributes.getValue("src");
				csvFile = new File(xmlFile.getParentFile().getAbsolutePath(),fileName);
				grid.importCSV(csvFile, curLayer, Grid.GAS);
				break;
		}
	}