XML/XHTML formatter – DOCTYPE v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 04 Jan 2014 23:39:38 +0100
branchv_0
changeset 136c0f9521900bf
parent 135 ef432015fdee
child 137 3a24be5d8dac
XML/XHTML formatter – DOCTYPE
java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractXmlFormatter.java
java/sql-dk/src/info/globalcode/sql/dk/formatting/XhtmlFormatter.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractXmlFormatter.java	Sat Jan 04 23:27:17 2014 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractXmlFormatter.java	Sat Jan 04 23:39:38 2014 +0100
     1.3 @@ -50,6 +50,7 @@
     1.4  	private static final TerminalColor ATTRIBUTE_NAME_COLOR = TerminalColor.Green;
     1.5  	private static final TerminalColor ATTRIBUTE_VALUE_COLOR = TerminalColor.Yellow;
     1.6  	private static final TerminalColor XML_DECLARATION_COLOR = TerminalColor.Red;
     1.7 +	private static final TerminalColor XML_DOCTYPE_COLOR = TerminalColor.Cyan;
     1.8  	private Stack<QName> treePosition = new Stack<>();
     1.9  	private final ColorfulPrintWriter out;
    1.10  	private final String indent;
    1.11 @@ -72,6 +73,10 @@
    1.12  		out.print(XML_DECLARATION_COLOR, "<?xml version=\"1.0\" encoding=\"" + Charset.defaultCharset().name() + "\"?>");
    1.13  	}
    1.14  
    1.15 +	protected void printDoctype(String doctype) {
    1.16 +		out.print(XML_DOCTYPE_COLOR, "\n<!DOCTYPE " + doctype + ">");
    1.17 +	}
    1.18 +
    1.19  	protected void printEndDocument() {
    1.20  		out.println();
    1.21  		out.flush();
     2.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/XhtmlFormatter.java	Sat Jan 04 23:27:17 2014 +0100
     2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/XhtmlFormatter.java	Sat Jan 04 23:39:38 2014 +0100
     2.3 @@ -39,6 +39,7 @@
     2.4  public class XhtmlFormatter extends AbstractXmlFormatter {
     2.5  
     2.6  	public static final String NAME = "xhtml"; // bash-completion:formatter
     2.7 +	private static final String DOCTYPE = "html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN\" \"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd\"";
     2.8  	private static final String CSS_FILE = "info/globalcode/sql/dk/formatter/XhtmlFormatter.css";
     2.9  	private int resultSetCounter = 0;
    2.10  	private int updatesResultCounter = 0;
    2.11 @@ -61,6 +62,7 @@
    2.12  	public void writeStartBatch() {
    2.13  		super.writeStartBatch();
    2.14  		printStartDocument();
    2.15 +		printDoctype(DOCTYPE);
    2.16  		Map<QName, String> attributes = new HashMap<>(1);
    2.17  		attributes.put(qname("xmlns"), Xmlns.XHTML);
    2.18  		printStartElement(qname("html"), attributes);