Methods Summary |
---|
public static java.lang.String | getLocalName(org.w3c.dom.Element element)Returns the "localname" part of a QName, which is the whole
name if it has no prefix.
String name = element.getTagName();
if (name.indexOf(':") > 0) {
name = name.substring(name.indexOf(':")+1);
}
return name;
|
public static java.lang.String | getNamespaceURI(org.w3c.dom.Node node, java.lang.String prefix)Returns the namespace URI for the specified prefix at the
specified context node.
if (node == null || node.getNodeType() != Node.ELEMENT_NODE) {
return null;
}
if (prefix.equals("")) {
if (((Element) node).hasAttribute("xmlns")) {
return ((Element) node).getAttribute("xmlns");
}
} else {
String nsattr = "xmlns:" + prefix;
if (((Element) node).hasAttribute(nsattr)) {
return ((Element) node).getAttribute(nsattr);
}
}
return getNamespaceURI(node.getParentNode(), prefix);
|
public static java.lang.String | getNamespaceURI(org.w3c.dom.Element element)Returns the namespace URI for the namespace to which the
element belongs.
String prefix = getPrefix(element);
return getNamespaceURI(element, prefix);
|
public static java.lang.String | getPrefix(org.w3c.dom.Element element)Returns the "prefix" part of a QName or the empty string (not
null) if the name has no prefix.
String name = element.getTagName();
String prefix = "";
if (name.indexOf(':") > 0) {
prefix = name.substring(0, name.indexOf(':"));
}
return prefix;
|