From 413f8b517669288d815da38fc6b7073edda37ecc Mon Sep 17 00:00:00 2001 From: dmiller Date: Thu, 30 Oct 2014 13:14:00 +0000 Subject: [PATCH] Remove standalone="yes" from xml output This is complicated: a validating parser needs to know how to handle whitespace (as ignorable markup or as a whitespace node). The default is to treat it as a whitespace node, and the standalone="yes" tells it that the document can be handled as such, since there is no internal doctype definition that says otherwise. But then, when we try to validate against our DTD, the parser sees that some elements are defined with element-only content, which conflicts with the standalone default. References: http://www.w3.org/TR/REC-xml/#sec-rmd http://bytes.com/topic/net/answers/553902-standalone-yes --- xml.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/xml.cc b/xml.cc index 84c51cfbb..838799d1f 100644 --- a/xml.cc +++ b/xml.cc @@ -124,13 +124,13 @@ This is a simple library for writing XML. It handles two main things: keeping track of the element stack, and escaping text where necessary. If you wanted to write this XML: - + these are the functions you would call. Each one is followed by the text it prints enclosed in ||. -xml_start_document("elem") |\n| +xml_start_document("elem") |\n| xml_newline(); |\n| xml_open_start_tag("elem"); |\n. +xml_start_document Writes \n. xml_depth Returns the size of the element stack. The library makes it harder but not impossible to make non-well-formed @@ -309,7 +309,7 @@ int xml_write_escaped_v(const char *fmt, va_list va) { return 0; } -/* Write the XML declaration: +/* Write the XML declaration: * and the DOCTYPE declaration: */ int xml_start_document(const char *rootnode) { @@ -321,11 +321,6 @@ int xml_start_document(const char *rootnode) { * for future expansion */ if (xml_attribute("encoding", "UTF-8") < 0) return -1; - /* This indicates that parsers don't have to go elsewhere for entity - * declarations and so forth. We had trouble with this when we defined a - * PUBLIC doctype. */ - if (xml_attribute("standalone", "yes") < 0) - return -1; if (xml_close_pi() < 0) return -1; if (xml_newline() < 0)