|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57803 SDO DAS XML does not enforce decimal data type
Submitted: 2007-08-28 16:45 UTC Modified: 2007-08-29 06:26 UTC
From: mattsch at gmail dot com Assigned:
Status: Closed Package: SCA_SDO (PECL)
PHP Version: 5.2.3 OS: Gentoo Linux
Private report: No CVE-ID: None
 [2007-08-28 16:45 UTC] mattsch at gmail dot com
I can insert letters in elements with the type of decimal.

3.2.3 decimal

[Definition:]  decimal represents a subset of the real numbers, which can be represented by decimal numerals. The ?value space? of decimal is the set of numbers that can be obtained by multiplying an integer by a non-positive power of ten, i.e., expressible as i ? 10^-n where i and n are integers and n >= 0. Precision is not reflected in this value space; the number 2.0 is not distinct from the number 2.00. The ?order-relation? on decimal is the order relation on real numbers, restricted to this subset. 

Note:  All ?minimally conforming? processors ?must? support decimal numbers with a minimum of 18 decimal digits (i.e., with a ?totalDigits? of 18). However, ?minimally conforming? processors ?may? set an application-defined limit on the maximum number of decimal digits they are prepared to support, in which case that application-defined maximum number ?must? be clearly documented.

Reproduce code:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="">

<xsd:element name="request" type="requestType"/>

<xsd:complexType name="requestType" abstract="true"/>

<xsd:complexType name="collectionInfo">
    <xsd:extension base="requestType">
      <xsd:sequence minOccurs="0" maxOccurs="unbounded">
        <xsd:element name="collection" type="xsd:decimal"/>
      <xsd:attribute name="kind" type="xsd:string" fixed="collectionInfo"/>

<xsd:element name="request-list">
        <xsd:element ref="request" minOccurs="0" maxOccurs="unbounded"/>



try {
	$xmldas = SDO_DAS_XML::create("request.xsd");
	try {
		$doc = $xmldas->createDocument('', 'request-list');
		$rdo = $doc->getRootDataObject();
		$request = $xmldas->createDataObject('', 'collectionInfo');
		$request->kind = 'collectionInfo';
	} catch (SDO_Exception $e) {
} catch (SDO_Exception $e) {
	print("Problem creating an XML document: " . $e->getMessage());


Expected result:
<?xml version="1.0" encoding="UTF-8"?>
<request-list xmlns:xsi=""><request xsi:type="collectionInfo" kind="collectionInfo"><collection>foo</collection></request></request-list>

Actual result:
<?xml version="1.0" encoding="UTF-8"?>
<request-list xmlns:xsi=""><request xsi:type="collectionInfo" kind="collectionInfo"><collection>0.0</collection></request></request-list>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-28 16:45 UTC] mattsch at gmail dot com
Changing php version.
 [2007-08-29 05:16 UTC]
Thank you for taking the time to write to us, but this is not
a bug.

This is the current expected behaviour.  Unfortunately, the SDO C++ specification (see on which our internals are based, does not address Decimal and leaves it up to the implementation.  There is no natural mapping for Decimal which preserves precision.  I believe there were a few alternatives here:
1. Provide a decimal type implementation (large piece of work)
2. Map to something like double (lose precision).
3. Use string to preserve precision (require correct data to be provided).

I believe option 3 was chosen for pragmatic reasons.

Not an entirely satisfactory outcome, I'm afraid :-(
 [2007-08-29 06:26 UTC]
Tuscany SDO C++ has a Jira to investigate this, but it's been open for 18 months:

I've raised a Jira improvement request:
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jan 24 15:03:34 2022 UTC