public static String detectIdentifier(String eadfile)
			throws FileNotFoundException, XMLStreamException,
			FactoryConfigurationError {

		FileInputStream fileInputStreamEAD = new FileInputStream(eadfile);
		XMLEventReader xmlEventReaderEAD = XMLInputFactory.newInstance()
				.createXMLEventReader(fileInputStreamEAD);

		while (xmlEventReaderEAD.hasNext()) {
			XMLEvent event = xmlEventReaderEAD.nextEvent();
			if (event.isStartElement()) {
				if (event.asStartElement().getName().getLocalPart()
						.equals("did")) {
					
					@SuppressWarnings("unchecked")
					Iterator<Attribute> attributes = event.asStartElement()
							.getAttributes();
					while (attributes.hasNext()) {
						if (attributes.next().getName().toString().equals("id")) {
							identifier = App.DID;
                                                        return identifier;
						}
					}
						
				} else {

					if (event.asStartElement().getName().getLocalPart()
							.equals("unitid")) {
                                            identifier = App.UNITID;
//						@SuppressWarnings("unchecked")
//						Iterator<Attribute> attributes = event.asStartElement()
//								.getAttributes();
//						if (!attributes.hasNext()) {
//							identifier = "UNITID";
//						}
//						if (attributes.hasNext()){
//							while (attributes.hasNext()) {
//								if (attributes.next().getName().toString().equals("Bestandssignatur")) {
//									identifier = "UNITID";
//								}
//							}
//
//						}
					}

				}

			}
		}
		xmlEventReaderEAD.close();
		return identifier;
	}