/*
 * MIT License
 *
 * Copyright (c) 2014-16, Miguel Gamboa (gamboa.pt)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package htmlflow;

import htmlflow.elements.ElementType;
import htmlflow.elements.HtmlBody;
import htmlflow.elements.HtmlHead;

import java.io.PrintStream;

/**
 * The root container for HTML elements, representing the main structure of
 * an  HTML document.
 *
 * @author Miguel Gamboa
 *         created on 29-03-2012
 */
public class HtmlView<T> extends HtmlWriterComposite<T, HtmlView<T>>{

    public HtmlHead<T> head(){return addChild(new HtmlHead<T>());}
    public HtmlBody<T> body(){return addChild(new HtmlBody<T>());}

    @Override
    public void doWriteBefore(PrintStream out, int depth) {
        out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
        out.print("<html xmlns=\"http://www.w3.org/1999/xhtml\" >");
    }

    @Override
    public String getElementName() {
        return ElementType.HTML.toString();
    }
}

@@ -1293,258 +1293,1204 @@
 .io.
-PrintStream;%0A%0A/**%0A * The root container for HTML elements, representing the main structure of%0A * an  HTML document.%0A *%0A * @author Miguel Gamboa%0A *         created on 29-03-2012%0A */%0Apublic class HtmlView%3CT%3E extends HtmlWriterComposite%3CT, HtmlView%3CT%3E%3E%7B
+BufferedReader;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.io.PrintStream;%0Aimport java.io.UncheckedIOException;%0Aimport java.net.URL;%0Aimport java.util.stream.Collectors;%0A%0A/**%0A * The root container for HTML elements, representing the main structure of%0A * an  HTML document.%0A *%0A * @author Miguel Gamboa%0A *         created on 29-03-2012%0A */%0Apublic class HtmlView%3CT%3E extends HtmlWriterComposite%3CT, HtmlView%3CT%3E%3E%7B%0A%0A    private static final String header;%0A    private static final String NEWLINE = System.getProperty(%22line.separator%22);%0A%0A    static %7B%0A        try %7B%0A            URL headerUrl = ClassLoader.getSystemResource(%22templates/HtmlView-Header.txt%22);%0A            if(headerUrl == null) throw new FileNotFoundException(%22templates/HtmlView-Header.txt%22);%0A            InputStream headerStream = headerUrl.openStream();%0A            try (BufferedReader reader = new BufferedReader(new InputStreamReader(headerStream))) %7B%0A                header = reader.lines().collect(Collectors.joining(NEWLINE));%0A            %7D%0A        %7D catch (IOException e) %7B%0A            throw new UncheckedIOException(e);%0A        %7D%0A    %7D
 %0A%0A  
@@ -2720,204 +2720,55 @@
 tln(
-%22%3C!DOCTYPE html PUBLIC %5C%22-//W3C//DTD XHTML 1.0 Transitional//EN%5C%22 %5C%22http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%5C%22%3E%22);%0A        out.print(%22%3Chtml xmlns=%5C%22http://www.w3.org/1999/xhtml%5C%22 %3E%22
+header);%0A        super.doWriteBefore(out, depth
 );%0A 

Read HTML header from template located in templates/ folder