public void setXPathNamespaceContext(String prefix, String uri)
throws XMLSecurityException {
String ns;
if ((prefix == null) || (prefix.length() == 0)) {
throw new XMLSecurityException("defaultNamespaceCannotBeSetHere");
} else if (prefix.equals("xmlns")) {
throw new XMLSecurityException("defaultNamespaceCannotBeSetHere");
} else if (prefix.startsWith("xmlns:")) {
ns = prefix;//"xmlns:" + prefix.substring("xmlns:".length());
} else {
ns = "xmlns:" + prefix;
}
Attr a = this.constructionElement.getAttributeNodeNS(Constants.NamespaceSpecNS, ns);
if (a != null) {
if (!a.getNodeValue().equals(uri)) {
Object exArgs[] = { ns, this.constructionElement.getAttributeNS(null, ns) };
throw new XMLSecurityException("namespacePrefixAlreadyUsedByOtherURI", exArgs);
}
return;
}
this.constructionElement.setAttributeNS(Constants.NamespaceSpecNS, ns, uri);