Java Utililty Methods XML Attribute Remove

List of utility methods to do XML Attribute Remove

Description

The list of methods to do XML Attribute Remove are organized into topic(s).

Method

StringremovePrefixes(final String xml, final boolean ignoreAttrValues)
Removes prefixes from an XML String
final int len = xml.length();
int start = -2, stop = -1, stop2;
final StringBuilder sb = new StringBuilder(len);
final char[] c = xml.toCharArray();
while (start != -1) {
    start = xml.indexOf('<', start + 1);
    sb.append(c, stop + 1, (start < 0 ? len : start) - stop - 1);
    if (start >= 0) {
...
voidremoveUnspecifiedIfmapAttributes(Node meta)
Method to remove attributes from Metadata elements, which start with "ifmap-", but are not allowed to be sent by IFMAP-Client.
String[] specifiedIfmapAttributes = { "ifmap-cardinality" };
if (meta == null) {
    return;
NamedNodeMap nnm = meta.getAttributes();
for (int i = 0; nnm != null && i < nnm.getLength(); i++) {
    Node attrNode = nnm.item(i);
    if (attrNode.getNodeType() != Node.ATTRIBUTE_NODE) {
...
voidremoveXmlBaseAttributes(Node node)
Remove xml:base attributes from the given node and all of its descendants.
if (node.getNodeType() == Node.ELEMENT_NODE) {
    Element element = (Element) node;
    element.removeAttribute("xml:base");
Node child = node.getFirstChild();
while (child != null) {
    removeXmlBaseAttributes(child);
    child = child.getNextSibling();
...
voidremoveXmlNsAttribute(final Node node)
remove stray "xmlns" default namespace element that seems to get left over even after removing namespacing from nodes
final NamedNodeMap attr = node.getAttributes();
for (int i = 0; i < attr.getLength(); i++) {
    final Node item = attr.item(i);
    if (ATTR_XMLNS.equals(item.getNodeName())) {
        attr.removeNamedItem(ATTR_XMLNS);
        return;