Page MenuHomeClusterLabs Projects

pcmk__output_t XML object should display declaration
Open, WishlistPublic

Assigned To
Authored By
Jan 29 2024, 7:58 PM
  • Restricted Project
  • Restricted Project
Referenced Files


The declaration is the element with <?xml version="..."?>.

It's required for XML 1.1. However, we'll always be using XML 1.0 because that's all libxml2 supports.

See also

If we do this, perhaps advertise UTF-8 encoding as well, something like

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

Event Timeline

nrwahl2 created this task.
nrwahl2 created this object with edit policy "Restricted Project (Project)".

The problem is that pcmk__xml2fd takes an xmlNode *, not an xmlDoc *. Printing an XML_DOCUMENT_NODE is what causes the version to be printed out. So we'd either need to change that function or make a new one, and then have xml_finish pass the document pointer instead of the root node.

This gets the right result (well, with an extra newline) but I don't like it:

diff --git a/lib/common/xml.c b/lib/common/xml.c
index 1e1b830a5..9fec40261 100644
--- a/lib/common/xml.c
+++ b/lib/common/xml.c
@@ -1678,7 +1678,7 @@ pcmk__xml2fd(int fd, xmlNode *cur)
     xmlOutputBuffer *fd_out = xmlOutputBufferCreateFd(fd, NULL);
     CRM_ASSERT(fd_out != NULL);
-    xmlNodeDumpOutput(fd_out, cur->doc, cur, 0, pcmk__xml_fmt_pretty, NULL);
+    xmlNodeDumpOutput(fd_out, cur->doc, (xmlNodePtr) cur->doc, 0, pcmk__xml_fmt_pretty, NULL);
     success = xmlOutputBufferWrite(fd_out, sizeof("\n") - 1, "\n") != -1;
nrwahl2 renamed this task from pcmk__output_t XML object should display header element to pcmk__output_t XML object should display declaration.Feb 4 2024, 3:21 PM
nrwahl2 lowered the priority of this task from Low to Wishlist.
nrwahl2 updated the task description. (Show Details)
nrwahl2 updated the task description. (Show Details)