class AxiomUtils {

	public static OMNamespace toNamespace(QName qName, OMElement resolveElement) throws OMException {
		String prefix = qName.getPrefix();
		if (StringUtils.hasLength(qName.getNamespaceURI()) && StringUtils.hasLength(prefix)) {
			return resolveElement.declareNamespace(qName.getNamespaceURI(), prefix);
		} else if (StringUtils.hasLength(qName.getNamespaceURI())) {
			// check for existing namespace, and declare if necessary
			return resolveElement.declareNamespace(qName.getNamespaceURI(), "");
		} else {
			throw new IllegalArgumentException("qName [" + qName + "] does not contain a namespace");
		}
	}

}