Java XML Node Remove removeUndesiredContent(Node node)

Here you can find the source of removeUndesiredContent(Node node)

Description

remove Undesired Content

License

Open Source License

Declaration

private static void removeUndesiredContent(Node node) 

Method Source Code

//package com.java2s;
/**//  w  w  w  . ja v a  2  s.  c o  m
 * TL Manager
 * Copyright (C) 2015 European Commission, provided under the CEF programme
 *
 * This file is part of the "TL Manager" project.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

import org.w3c.dom.Node;

public class Main {
    private static void removeUndesiredContent(Node node) {
        if (node.getLocalName() != null) {
            String localName = node.getLocalName();

            // According to jira issue DSS-58, the following is not done anymore
            //            if (localName.equals(QNames._CriteriaList)) {
            //                // check KeyUsageBits
            //                NodeList criteriaList = node.getChildNodes();
            //                for (int i = 0; i < criteriaList.getLength(); i++) {
            //                    Node criteria = criteriaList.item(i);
            //                    if (criteria.getLocalName() != null && criteria.getLocalName().equals(QNames._KeyUsage)) {
            //                        NodeList keyUsageBits = criteria.getChildNodes();
            //                        for (int j = 0; j < keyUsageBits.getLength(); j++) {
            //                            Node keyUsageBit = keyUsageBits.item(j);
            //                            if (keyUsageBit.getTextContent().equals("false")) {
            //                                keyUsageBit.setTextContent("");
            //                            }
            //                        }
            //                    }
            //                }
            //            }
        }
    }
}

Related

  1. removeNodesByName(Node node, String name)
  2. removePreviousWhiteSpace(Node node)
  3. removeQueryCallBody(Node queryElement)
  4. removeSelf(Node node)
  5. removeTextNodes(Node parent)
  6. removeUserData(Node node, String key)
  7. removeValue(NamedNodeMap values, String name)
  8. removeWhitespace(Node node, boolean deep)
  9. removeWhitespace(Node parent)