PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Structures » Structures_DataGrid_Renderer_XML » Bug #8427

Add functionality to define the XML encoding

Details

Request #8427Add functionality to define the XML encoding
Submitted2006-08-14 08:56 UTC
Fromacoghlan at itsm dot net
Assignedolivierg
StatusClosed
PackageStructures_DataGrid_Renderer_XML
PHP Version5.0.4
OSLinux
Roadmaps(Not assigned)

Comments

[2006-08-14 08:56 UTC] acoghlan at itsm dot net

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.

[2006-08-14 10:03 UTC] olivierg at php dot net

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