|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-02-08 08:34 UTC] oliver dot hofer at itp-solutions dot ch
Description: ------------ If the name of the super-type is alphabetically (sorted) AFTER the type name of the derived (extension, restriction) type in the schema, assigning a value to a property of that type fails. The schema defines a upl-object which has a creationType property. The creationType-property is of the type lovCreationTypeType which is a restriction of lovType which is a restriction of xs:int. In my (original) example, the type name is lovCreationTypeType which is alphabetically sorted BEFORE lovType where it is derived from. Example code and schemas are available here: http://ftxml-dev.itpnet.ch/test/test.zip http://ftxml-dev.itpnet.ch/test/sdo_test.php http://ftxml-dev.itpnet.ch/test/sdo_test.xsd http://ftxml-dev.itpnet.ch/test/sdo_working.xsd In PHP-Code, the property can not be set using $upl->creationType = 1234 after having created the upl-object. After renaming the type lovCreationTypeType to be lovZZCreationType, assigning a value works. Reproduction is possible on WinXP SP2, Apache 2.2.6, PHP 5.2.5 and Linux Fedora Core 6, Apache 2.2.6, PHP 5.2.5 Reproduce code: --------------- <?php $xmldas = SDO_DAS_XML::create(); $xmldas->addTypes('sdo_working.xsd'); $document = $xmldas->createDocument('http://example.com/model', 'upl'); $upl = $document->getRootDataObject(); $upl->creationType = 1234; header('Content-Type: text/xml'); echo $xmldas->saveString($document); unset($upl); $xmldas = SDO_DAS_XML::create(); $xmldas->addTypes('sdo_test.xsd'); $document = $xmldas->createDocument('http://example.com/model', 'upl'); $upl = $document->getRootDataObject(); $upl->creationType = 1234; unset($upl); ?> Expected result: ---------------- The code above can be used to reproduce the bug using 2 different schemas (sdo_working.xsd, sdo_test.xsd) The first test uses sdo_working.xsd which defines the type lovZZCreationTypeType (derived from lovType) to assign a value to $upl->creationType. The resulting XML is printed out. The second test uses sdo_test.xsd where the definition of the creationType element is of the type lovCreationTypeType. Teh result is a SDO_UnsupportedOperationException which is catched. The script may be run in a browser, the result (Source code) is shown below. Actual result: -------------- <?xml version="1.0" encoding="UTF-8"?> <tns:upl xmlns:tns="http://example.com/model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><tns:creationType>1234</tns:creationType></tns:upl> <br /> <b>Fatal error</b>: Uncaught exception 'SDO_UnsupportedOperationException' with message 'main(): cannot cast integer to SDO_DataObject for 'creationType'' in D:\workspaces\ftxml\test\sdo_test.php:21 Stack trace: #0 D:\workspaces\ftxml\test\sdo_test.php(21): unknown() #1 {main} thrown in <b>D:\workspaces\ftxml\test\sdo_test.php</b> on line <b>21</b><br /> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 09:00:02 2025 UTC |
Created a php-Test for it: --TEST-- SDO test for alphabetical type order bug --INI-- display_errors=off --SKIPIF-- <?php if (!extension_loaded("sdo")) echo "skip sdo not loaded"; ?> --FILE-- <?php $xsd = <<<EOF <?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="http://example.com/model" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.3" xmlns="http://example.com/model" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="lovType"> <xs:restriction base="xs:int"> <xs:totalDigits value="3"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="lovCreationTypeType"> <xs:restriction base="lovType"/> </xs:simpleType> <xs:simpleType name="lovZZCreationTypeType"> <xs:restriction base="lovType"/> </xs:simpleType> <xs:element name="creationType" type="lovCreationTypeType"> </xs:element> <xs:element name="creationTypeZZ" type="lovZZCreationTypeType"> </xs:element> <xs:complexType name="batchRequestType"> <xs:sequence> <xs:element ref="creationType"/> <xs:element ref="creationTypeZZ"/> </xs:sequence> </xs:complexType> <xs:element name="upl" type="batchRequestType"> </xs:element> </xs:schema> EOF; $schema_file = tempnam(NULL, 'xsd'); file_put_contents($schema_file, $xsd); $xmldas = SDO_DAS_XML::create($schema_file); unlink($schema_file); $document = $xmldas->createDocument('http://example.com/model', 'upl'); $upl = $document->getRootDataObject(); $upl->creationTypeZZ = 1234; $upl->creationType = 1234; echo ($upl->creationTypeZZ == 1234) ."\n"; echo ($upl->creationType == 1234); unset($upl); ?> --EXPECT-- 1 1