--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateProjectImpl.java +++ a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateProjectImpl.java @@ -53,6 +53,7 @@ import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.util.NbBundle; +import org.openide.xml.XMLUtil; import org.w3c.dom.Comment; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -147,7 +148,7 @@ if (oldRoot != null) { Document doc = oldRoot.getOwnerDocument(); Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N - copyDocument (doc, oldRoot, newRoot); + XMLUtil.copyDocument (doc, oldRoot, newRoot, AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE); Element sourceRoots = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N Element root = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N root.setAttribute ("id","src.dir"); //NOI18N @@ -164,7 +165,7 @@ if (oldRoot != null) { Document doc = oldRoot.getOwnerDocument(); Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N - copyDocument (doc, oldRoot, newRoot); + XMLUtil.copyDocument (doc, oldRoot, newRoot, AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE); cachedElement = updateMinAntVersion (newRoot, doc); } } @@ -187,39 +188,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(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,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); - } - } - } - private static Element updateMinAntVersion (final Element root, final Document doc) { NodeList list = root.getElementsByTagNameNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT); if (list.getLength() == 1) { --- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathSupportCallbackImpl.java +++ a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathSupportCallbackImpl.java @@ -51,6 +51,7 @@ import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item; import org.netbeans.modules.java.api.common.util.CommonProjectUtils; import org.netbeans.spi.project.support.ant.AntProjectHelper; +import org.openide.xml.XMLUtil; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -91,7 +92,7 @@ for ( int i = 0; i < libs.getLength(); i++ ) { Element item = (Element)libs.item( i ); // appclient is different from other j2ee projects - it stores reference without ${ and } - String ref = "${"+findText( item )+"}"; + String ref = "${"+XMLUtil.findText( item )+"}"; libraries.add(ref); // NOI18N String dirs = item.getAttribute(ATTR_DIRS); if (Util.DESTINATION_DIRECTORY_ROOT.equals(dirs) || @@ -140,23 +141,6 @@ return libraryElement; } - /** - * Extracts the first nested text from an element. - * Currently does not handle coalescing text nodes, CDATA sections, etc. - * @param parent a parent element - * @return the nested text, or null if none was found - */ - private static String findText( Element parent ) { - NodeList l = parent.getChildNodes(); - for ( int i = 0; i < l.getLength(); i++ ) { - if ( l.item(i).getNodeType() == Node.TEXT_NODE ) { - Text text = (Text)l.item( i ); - return text.getNodeValue(); - } - } - return null; - } - public void readAdditionalProperties(List items, String projectXMLElement) { Map destination = new HashMap(); List l = getIncludedLibraries(antProjectHelper, projectXMLElement, destination);