1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

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
This commit is contained in:
dmiller
2014-10-30 13:14:00 +00:00
parent 183566948f
commit 413f8b5176

13
xml.cc
View File

@@ -124,13 +124,13 @@
This is a simple library for writing XML. It handles two main things: This is a simple library for writing XML. It handles two main things:
keeping track of the element stack, and escaping text where necessary. keeping track of the element stack, and escaping text where necessary.
If you wanted to write this XML: If you wanted to write this XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE elem> <!DOCTYPE elem>
<elem name="&amp;10.5"></elem> <elem name="&amp;10.5"></elem>
these are the functions you would call. Each one is followed by the text these are the functions you would call. Each one is followed by the text
it prints enclosed in ||. it prints enclosed in ||.
xml_start_document("elem") |<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<!DOCTYPE elem>| xml_start_document("elem") |<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE elem>|
xml_newline(); |\n| xml_newline(); |\n|
xml_open_start_tag("elem"); |<elem| xml_open_start_tag("elem"); |<elem|
xml_attribute("name", "&%.1f", 10.5); | name="&amp;10.5"| xml_attribute("name", "&%.1f", 10.5); | name="&amp;10.5"|
@@ -167,7 +167,7 @@ Additional functions are
xml_write_raw Raw unescaped output. xml_write_raw Raw unescaped output.
xml_write_escaped XML-escaped output. xml_write_escaped XML-escaped output.
xml_write_escaped_v XML-escaped output, with a va_list. xml_write_escaped_v XML-escaped output, with a va_list.
xml_start_document Writes <?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<!DOCTYPE elem>. xml_start_document Writes <?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE elem>.
xml_depth Returns the size of the element stack. xml_depth Returns the size of the element stack.
The library makes it harder but not impossible to make non-well-formed 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; return 0;
} }
/* Write the XML declaration: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> /* Write the XML declaration: <?xml version="1.0" encoding="UTF-8"?>
* and the DOCTYPE declaration: <!DOCTYPE rootnode> * and the DOCTYPE declaration: <!DOCTYPE rootnode>
*/ */
int xml_start_document(const char *rootnode) { int xml_start_document(const char *rootnode) {
@@ -321,11 +321,6 @@ int xml_start_document(const char *rootnode) {
* for future expansion */ * for future expansion */
if (xml_attribute("encoding", "UTF-8") < 0) if (xml_attribute("encoding", "UTF-8") < 0)
return -1; 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) if (xml_close_pi() < 0)
return -1; return -1;
if (xml_newline() < 0) if (xml_newline() < 0)