Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., and individual contributors as indicated
 * by the @authors tag.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the JBPM BPEL PUBLIC LICENSE AGREEMENT as
 * published by JBoss Inc.; either version 1.0 of the License, or
 * (at your option) any later version.
 *
 * This software 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.
 */

import org.w3c.dom.Attr;

import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;

public class Main {
    public static void removeAttributes(Element elem) {
        if (elem.hasAttributes()) {
            NamedNodeMap attributeMap = elem.getAttributes();
            // since node maps are live, hold attributes in a separate collection
            int n = attributeMap.getLength();
            Attr[] attributes = new Attr[n];
            for (int i = 0; i < n; i++)
                attributes[i] = (Attr) attributeMap.item(i);
            // now remove each attribute from the element
            for (int i = 0; i < n; i++)
                elem.removeAttributeNode(attributes[i]);
        }
    }
}