[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[xml] xmlsave serialization patch for CDATA



Since it's possible using the tree API to create a CDATA section without
content the following patch fixes a serialzation but when cur->content == NULL

It appears according to the spec[1] that CDATA sections can be empty so this
outputs <![CDATA[]]>.  It could be argued that it should output nothing for the
CDATA node but I believe[2] this is the correct thing to do.

- Mark

[1] : http://www.w3.org/TR/2004/REC-xml-20040204/#sec-cdata-sect
[2] : I usually don't know what I'm talking about
Index: xmlsave.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/xmlsave.c,v
retrieving revision 1.23
diff -c -r1.23 xmlsave.c
*** xmlsave.c	1 Apr 2005 13:11:52 -0000	1.23
--- xmlsave.c	20 May 2005 17:48:06 -0000
***************
*** 715,720 ****
--- 715,723 ----
  	return;
      }
      if (cur->type == XML_CDATA_SECTION_NODE) {
+ 	if (cur->content == NULL) {
+ 		xmlOutputBufferWrite(buf, 12, "<![CDATA[]]>");
+ 	} else {
  	start = end = cur->content;
  	while (*end != '\0') {
  	    if ((*end == ']') && (*(end + 1) == ']') && (*(end + 2) == '>')) {
***************
*** 731,736 ****
--- 734,740 ----
  	    xmlOutputBufferWriteString(buf, (const char *)start);
  	    xmlOutputBufferWrite(buf, 3, "]]>");
  	}
+ 	}
  	return;
      }
      if (cur->type == XML_ATTRIBUTE_NODE) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]