Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    private static Element populateRootElement(Document doc, Element item) {

        // set attribute to root element
        Attr attr = doc.createAttribute("xmlns:xsi");
        attr.setValue("http://www.w3.org/2001/XMLSchema-instance");
        item.setAttributeNode(attr);

        attr = doc.createAttribute("xmlns");
        attr.setValue("http://www.example.com/airlines");
        item.setAttributeNode(attr);

        attr = doc.createAttribute("xsi:schemaLocation");
        attr.setValue("http://www.example.com/airlines airline.xsd");
        item.setAttributeNode(attr);

        /**
         * TODO Do the same for root element
         */
        return item;
    }
}