/** * <p> * Allocate and declare a new namespace prefix for the current context that uses * the supplied "hint" as a start. The algorithm used will defer to an * existing binding, then try the hint, then use a variant of the hint until it * finds an available prefix. * </p> * @param hint a hint as to the desired prefix or <code>null</code> if any prefix * will do. * @param uri the URI to bind to the prefix. * @return the suggested prefix. */ public String allocatePrefix(String hint, String uri) { String pfx = getPrefix(uri); if (pfx == null) { hint = hint==null?"ns":hint; String u = getNamespaceUri(hint); if (u == null) { declarePrefix(hint,uri); pfx = hint; } else if (u.equals(uri)) { pfx = hint; } else { // ?? } } return pfx; }