public final Elements convertElement(final StartElement start, final Note note) {

		Attribute type = start.getAttributeByName(new QName(TYPE));
		Attribute hash = start.getAttributeByName(new QName(HASH));

		Resource currentResource = null;
		for (Resource resource : note.getResources()) {
			if (Utils.bytesToHex(resource.getData().getBodyHash()).equals(hash.getValue())) {
				currentResource = resource;
			}
		}

		if (currentResource == null) {
			throw new MissingResourceException(note.getTitle());
		}

		if (type.getValue().contains(IMAGE)) {
			List<Attribute> newAttrs = new ArrayList<Attribute>();
			for (@SuppressWarnings("unchecked")
			Iterator<Attribute> iterator = start.getAttributes(); iterator.hasNext();) {
				Attribute attr = iterator.next();
				if (HASH.equals(attr.getName().getLocalPart())) {
					Attribute src = getEventFactory().createAttribute(
							SRC,
							DATA + type.getValue() + BASE64
									+ Utils.encodeFileToBase64Binary(currentResource.getData().getBody()));
					newAttrs.add(src);
				} else if (!TYPE.equals(attr.getName().getLocalPart())) {
					// type is not a supported attribute for img tag.
					newAttrs.add(attr);
				}
			}
			newAttrs.add(getEventFactory().createAttribute(
					ALT,
					currentResource.getAttributes().getFileName() != null ? currentResource.getAttributes()
							.getFileName() : ""));

			return new Elements(getEventFactory().createStartElement("", "", IMG, newAttrs.iterator(),
					start.getNamespaces()), getEventFactory().createEndElement("", "", IMG));
		} else {
			return new Elements(getEventFactory().createStartElement(
					"",
					"",
					A,
					Arrays.asList(
							getEventFactory().createAttribute(
									"download",
									currentResource.getAttributes().getFileName() != null ? currentResource
											.getAttributes().getFileName() : currentResource.getGuid()),
							getEventFactory().createAttribute(
									HREF,
									DATA + type.getValue() + BASE64
											+ Utils.encodeFileToBase64Binary(currentResource.getData().getBody())),
							type,
							getEventFactory().createAttribute(STYLE,
									"text-decoration: none;color: #6f6f6f;position: relative; display: block;"))
							.iterator(), start.getNamespaces()), getEventFactory().createEndElement("", "", A));
		}
	}