msg337463 - (view) |
Author: Johann Krauter (Photoniker) |
Date: 2019-03-08 10:08 |
I have the problem, that a xml file is save with the following xml declaration: instead of I would propose to change the line number 769 in the ElementTree.py to: write("\n" % ( declared_encoding,)) |
|
|
msg337489 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2019-03-08 15:15 |
Both quotes are valid. See https://www.w3.org/TR/2008/REC-xml-20081126/#sec-prolog-dtd. |
|
|
msg337520 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2019-03-08 18:01 |
+0 I support making this change, if only to keep the quoting convention consistent with how we quote attributes. Also, use of double quotes seems to be the norm. I made a brief informal survey of XML samples from multiple sources including DocBook, MS Excel, RSS feeds, the W3Schools examples, and various XML tutorials -- the only exception to double quotes was a NOAA weather feed. The XML spec itself shows a preference for double quotes in its examples. |
|
|
msg337528 - (view) |
Author: Stefan Behnel (scoder) *  |
Date: 2019-03-08 20:15 |
While I do understand the interest in a bit more visual consistency (and, lacking further input, I assume that this is the OP's "problem"), it really is at best a purely visual improvement with the potential to break code and/or tests out there. I'd rather not make that change. FWIW, lxml also uses single quotes in the XML declaration (originally following ElementTree), but double quotes by default for the rest, except for attributes that contain double quotes (but no single quotes). Any XML parser in the world is able to deal with that (since otherwise, it's not an XML parser). Nothing is broken here. |
|
|
msg337654 - (view) |
Author: Johann Krauter (Photoniker) |
Date: 2019-03-11 10:10 |
The xml parser of OpenCV (3.4.5) in C++ is not able to load such xml file. |
|
|
msg337671 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2019-03-11 14:43 |
Then report a bug to OpenCV. I do not think that changing quotation marks in the xml declaration will help much, since likely that parser has other flaws (for example what about using single quotes for attributes?). Changing quotation marks for sure will break many tests, in particularly our own tests. Needed a stronger reason to overcome this. |
|
|
msg338596 - (view) |
Author: Stefan Behnel (scoder) *  |
Date: 2019-03-22 09:32 |
I concur with Serhiy that the bug is in OpenCV (or its parser project), and that it is best solved there. Otherwise, we would create a dependency on a future/recent Python version for exporting XML to it. |
|
|
msg338597 - (view) |
Author: Stefan Behnel (scoder) *  |
Date: 2019-03-22 09:36 |
As a work-around, you can provide your own XML declaration (or not) and pass "xml_declaration=False" into ElementTree.write() to prevent it from adding one. UTF-8 encoded XML is ok without such a declaration. |
|
|