private final void buildAttribute(final String prefix,
			final String namespaceURI, final String localName,
			final String value, final boolean withpfx) throws XMLStreamException {
		if (!(parent instanceof Element)) {
			throw new IllegalStateException(
					"Cannot write attribute unless inside an Element.");
		}
		if (localName == null) {
			throw new XMLStreamException("localName is not allowed to be null");
		}
		if (value == null) {
			throw new XMLStreamException("value is not allowed to be null");
		}
		if (activeelement == null) { 
			throw new IllegalStateException("Cannot add Attributes to an Element after other content was added.");
		}
		
		Namespace ns = resolveAttributeNamespace(prefix, namespaceURI, withpfx);
		
		factory.setAttribute(activeelement, factory.attribute(localName, value, ns));
	}