Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    /**
     * 
     */
    public static Document createVmlDocument() {
        Document document = createDocument();

        Element root = document.createElement("html");
        root.setAttribute("xmlns:v", "urn:schemas-microsoft-com:vml");
        root.setAttribute("xmlns:o", "urn:schemas-microsoft-com:office:office");

        document.appendChild(root);

        Element head = document.createElement("head");

        Element style = document.createElement("style");
        style.setAttribute("type", "text/css");
        style.appendChild(document.createTextNode("<!-- v\\:* {behavior: url(#default#VML);} -->"));

        head.appendChild(style);
        root.appendChild(head);

        Element body = document.createElement("body");
        root.appendChild(body);

        return document;
    }

    /**
     * Returns a new, empty DOM document.
     * 
     * @return Returns a new DOM document.
     */
    public static Document createDocument() {
        Document result = null;

        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder parser = factory.newDocumentBuilder();

            result = parser.newDocument();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

        return result;
    }
}