diff --git a/j2ee.archive/src/org/netbeans/modules/j2ee/archive/project/UpdateHelper.java b/j2ee.archive/src/org/netbeans/modules/j2ee/archive/project/UpdateHelper.java --- a/j2ee.archive/src/org/netbeans/modules/j2ee/archive/project/UpdateHelper.java +++ b/j2ee.archive/src/org/netbeans/modules/j2ee/archive/project/UpdateHelper.java @@ -44,13 +44,9 @@ import java.io.IOException; import javax.swing.JButton; import org.netbeans.spi.project.support.ant.GeneratedFilesHelper; -import org.w3c.dom.Comment; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.w3c.dom.Text; import org.openide.DialogDisplayer; import org.openide.ErrorManager; import org.openide.NotifyDescriptor; @@ -61,6 +57,7 @@ import org.netbeans.spi.project.AuxiliaryConfiguration; import org.netbeans.spi.project.support.ant.AntProjectHelper; import org.netbeans.spi.project.support.ant.EditableProperties; +import org.openide.xml.XMLUtil; /** @@ -277,7 +274,7 @@ if (oldRoot != null) { Document doc = oldRoot.getOwnerDocument(); Element newRoot = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,DATA); //NOI18N - copyDocument (doc, oldRoot, newRoot); + XMLUtil.copyDocument (doc, oldRoot, newRoot, ArchiveProjectType.PROJECT_CONFIGURATION_NS); Element sourceRoots = doc.createElementNS(ArchiveProjectType.PROJECT_CONFIGURATION_NS,"source-roots"); //NOI18N Element root = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,"root"); //NOI18N root.setAttribute ("id","src.dir"); //NOI18N @@ -294,7 +291,7 @@ if (oldRoot != null) { Document doc = oldRoot.getOwnerDocument(); Element newRoot = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,DATA); //NOI18N - copyDocument (doc, oldRoot, newRoot); + XMLUtil.copyDocument (doc, oldRoot, newRoot, ArchiveProjectType.PROJECT_CONFIGURATION_NS); cachedElement = updateMinAntVersion (newRoot, doc); } } @@ -317,38 +314,6 @@ return cachedProperties; } - private static void copyDocument (Document doc, Element from, Element to) { - NodeList nl = from.getChildNodes(); - int length = nl.getLength(); - for (int i=0; i< length; i++) { - Node node = nl.item (i); - Node newNode = null; - switch (node.getNodeType()) { - case Node.ELEMENT_NODE: - Element oldElement = (Element) node; - newNode = doc.createElementNS(ArchiveProjectType.PROJECT_CONFIGURATION_NS,oldElement.getTagName()); - NamedNodeMap m = oldElement.getAttributes(); - Element newElement = (Element) newNode; - for (int index = 0; index < m.getLength(); index++) { - Node attr = m.item(index); - newElement.setAttribute(attr.getNodeName(), attr.getNodeValue()); - } - copyDocument(doc,oldElement,newElement); - break; - case Node.TEXT_NODE: - Text oldText = (Text) node; - newNode = doc.createTextNode(oldText.getData()); - break; - case Node.COMMENT_NODE: - Comment oldComment = (Comment) node; - newNode = doc.createComment(oldComment.getData()); - break; - } - if (newNode != null) { - to.appendChild (newNode); - } - } - } public static final String MINIMUM_ANT_VERSION = "1.6.5"; // NOI18N private static Element updateMinAntVersion (final Element root, final Document doc) {