Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Document;

import org.w3c.dom.NamedNodeMap;

public class Main {
    /**
     * Compare necessary namespace declarations between original and proposed
     * document, if namespaces in the original are missing compared to the
     * proposed, we add them to the original.
     * 
     * @param original document as read from the file system
     * @param proposed document as determined by the JspViewManager
     * @return true if the document was adjusted, otherwise false
     */
    private static boolean checkNamespaces(final Document original, final Document proposed) {
        boolean originalDocumentChanged = false;
        final NamedNodeMap nsNodes = proposed.getDocumentElement().getAttributes();
        for (int i = 0; i < nsNodes.getLength(); i++) {
            if (0 == original.getDocumentElement().getAttribute(nsNodes.item(i).getNodeName()).length()) {
                original.getDocumentElement().setAttribute(nsNodes.item(i).getNodeName(),
                        nsNodes.item(i).getNodeValue());
                originalDocumentChanged = true;
            }
        }
        return originalDocumentChanged;
    }
}