Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.5

Request #15467 CDATA sections and blank nodes
Submitted: 2008-12-31 03:35 UTC
From: mprowler Assigned: ashnazg
Status: Closed Package: XML_Util (version 1.2.1)
PHP Version: 5.2.8 OS: Linux 2.6.26
Roadmaps: (Not assigned)    
Subscription  


 [2008-12-31 03:35 UTC] mprowler (Joshua Ecklund)
Description: ------------ I am using the XML_Serializer package to output XML data to an Adobe Flex 3 application, and have CDATA sections turned on. However, when processing a blank string, XML_Util outputs a self-closing node (i.e. <node/>). I'm sure this is most likely the correct behavior, however Flex's XML handling will not utilize CDATA sections unless they are in the original XML. For this purpose, it would be great to have an option to always output CDATA sections regardless of the value being empty. To accomplish this for now, I have modified XML/Util.php, line 654, to read: if ($replaceEntities!=XML_UTIL_CDATA_SECTION && (!isset($tag['content']) || (string)$tag['content'] == '')) { Again, it would be great to have an option for this (which could then be added to XML_Serializer) in case it's needed by someone else in the future.

Comments

 [2017-02-01 19:43 UTC] ashnazg (Chuck Burgess)
-Status: Open +Status: Assigned -Assigned To: +Assigned To: ashnazg
 [2017-02-01 19:45 UTC] ashnazg (Chuck Burgess)
In the case of XML_Util::createTagFromArray( array('qname'=>'tag1','content'=>''), XML_UTIL_CDATA_SECTION ); Are you still wanting to see the CDATA marker? '<tag1><![CDATA[]]></tag1>'
 [2017-02-02 18:18 UTC] ashnazg (Chuck Burgess)
Or, are you wanting '<tag1></tag1>' ???
 [2017-02-02 19:06 UTC] ashnazg (Chuck Burgess)
-Status: Assigned +Status: Feedback
See Pull Request (https://github.com/pear/XML_Util/pull/5)... XML_Util::createTagFromArray( array('qname'=>'tag1','content'=>''), XML_UTIL_CDATA_SECTION ); should give you '<tag1><![CDATA[]]></tag1>' whereas XML_Util::createTagFromArray( array('qname'=>'tag1','content'=>''), XML_UTIL_REPLACE_ENTITIES, // default $replaceEntities false, // default $multiline '_auto', // default $indent "\n", // default $linebreak true, // default $sortAttributes XML_UTIL_COLLAPSE_NONE // *** new option *** ); should give you '<tag1></tag1>' ... Both calls *without* including the empty 'content' in the array should give you the same results.
 [2017-02-03 18:44 UTC] ashnazg (Chuck Burgess)
-Status: Feedback +Status: Closed
Included in v1.4.0.