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

Request #8427 Add functionality to define the XML encoding
Submitted: 2006-08-14 08:56 UTC
From: acoghlan at itsm dot net Assigned: olivierg
Status: Closed Package: Structures_DataGrid_Renderer_XML (version 0.1.0)
PHP Version: 5.0.4 OS: Linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 42 + 48 = ?

 
 [2006-08-14 08:56 UTC] acoghlan at itsm dot net (Andrew Coghlan)
Description: ------------ The issue came about because I had UTF-8 characters that I needed to include in my XML doc - which I UTF-8 Encoded. However it occured to me that it would be good to include the XML Encoding header in the XML doc, which you currently cant do. I modified the renderer XML.php at line 111 as follows:- if ($this->_options['useXMLDecl']) { // This is the new code // Create the declaration string $decEncoding = ($this->_options['XMLDeclEncoding'] == "" ? null : $this->_options['XMLDeclEncoding']); $decVersion = ($this->_options['XMLDeclVersion'] == "" ? "1.0" : $this->_options['XMLDeclVersion']); $decStandAlone = ($this->_options['XMLDeclStandAlone'] == "" ? false : $this->_options['XMLDeclStandAlone']); // End of new code // The following line was modified to include the above variables $this->_xml .= XML_Util::getXMLDeclaration($decVersion, $decEncoding, $decStandAlone) . "\n"; Essentially adding in 3 variables which can be set as options when you specifiy the renderer, and modifying the call to XML_Util::getXMLDeclaration to include the variables it is already expecting. Test script: --------------- if ($this->_options['useXMLDecl']) { // This is the new code // Create the declaration string $decEncoding = ($this->_options['XMLDeclEncoding'] == "" ? null : $this->_options['XMLDeclEncoding']); $decVersion = ($this->_options['XMLDeclVersion'] == "" ? "1.0" : $this->_options['XMLDeclVersion']); $decStandAlone = ($this->_options['XMLDeclStandAlone'] == "" ? false : $this->_options['XMLDeclStandAlone']); // End of new code // The following line was modified to include the above variables $this->_xml .= XML_Util::getXMLDeclaration($decVersion, $decEncoding, $decStandAlone) . "\n"; Expected result: ---------------- It includes the encoding and standalone headers in the first line of the XML doc. Actual result: -------------- it works.

Comments

 [2006-08-14 10:03 UTC] olivierg at php dot net (Olivier Guilyardi)
Hi Andrew, There is an "encoding" option, common to all renderers. See Renderer.php. There is no need for "XMLDeclEncoding" IMO. Concerning advanced customization (version, etc...) of the XML declaration, I recommend to set the "useXMLDecl" option to false and make your own declaration string. There's no need to add new options, new code, overhead, etc... for such an easy task IMO. This is fixed in CVS. Please see the comments added to the "useXMLDecl" option documentation. Thanks for your report.
 [2006-08-17 14:31 UTC] acoghlan at itsm dot net
Thanks - implemented and working - that is a much better way. Cheers