php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mattsch at gmail dot com
New email:
PHP Version: OS:

 

 [2007-08-28 16:45 UTC] mattsch at gmail dot com
Description:
------------
I can insert letters in elements with the type of decimal.

http://www.w3.org/TR/xmlschema-2/#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="http://www.w3.org/2001/XMLSchema">

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

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

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

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

</xsd:schema>

<?php

try {
	$xmldas = SDO_DAS_XML::create("request.xsd");
	try {
		$doc = $xmldas->createDocument('', 'request-list');
		$rdo = $doc->getRootDataObject();
		$request = $xmldas->createDataObject('', 'collectionInfo');
		$request->collection->insert('foo');
		$request->kind = 'collectionInfo';
		$rdo->request->insert($request);
		print($xmldas->saveString($doc));
	} catch (SDO_Exception $e) {
		print($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="http://www.w3.org/2001/XMLSchema-instance"><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="http://www.w3.org/2001/XMLSchema-instance"><request xsi:type="collectionInfo" kind="collectionInfo"><collection>0.0</collection></request></request-list>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-28 16:45 UTC] mattsch at gmail dot com
Changing php version.
 [2007-08-29 05:16 UTC] gcc@php.net
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 http://osoa.org/display/Main/Service+Data+Objects+Specifications) 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] gcc@php.net
Tuscany SDO C++ has a Jira to investigate this, but it's been open for 18 months: http://issues.apache.org/jira/browse/TUSCANY-99

I've raised a Jira improvement request: https://issues.apache.org/jira/browse/TUSCANY-1631
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jan 24 14:03:33 2022 UTC