/** * <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; }
public String getPrefix(String uri) { return toNSContext().getPrefix(uri); }
throw new IllegalArgumentException("\"" + qname + "\" is a malformed QName."); } else if (pos == -1) { qn = new QName (getNamespaceUri(""),qname); } else { String uri = getNamespaceUri(qname.substring(0,pos)); if (uri == null) { throw new IllegalArgumentException("No URI is bound to " +