Issue Details (XML | Word | Printable)

Key: TUSCANY-1564
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Matthew Peters
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Tuscany

xsi:type not always set for complexTypes

Created: 21/Aug/07 10:48 AM   Updated: 22/Aug/07 01:15 PM
Return to search
Component/s: C++ SDO
Affects Version/s: Cpp-Next
Fix Version/s: Cpp-Next

Time Tracking:
Not Specified

Environment: Win XP and Gentoo Linux

Resolution Date: 22/Aug/07 01:15 PM


 Description  « Hide
This has been reported by a user of the PHP SDO code. I have verified that he is right - the problem does exist. I will cut and paste in the PHP example from the defect http://pecl.php.net/bugs/bug.php?id=11774 but the php-ness of the example is irrelevant: under the covers we are just manipulating a C++ SDO and then calling XMLHelper->save()

In the defect text below he puts in both expected and actual output. He is right to raise the problem in the sense that I have tried reading in the actual and expected xml under XERCES with schema validation turned on, and the actual will *not* validate whereas the expected will.

Incidentally there is some history w.r.t. xsi:types - in a different case they were coming out when we did not want them and they were suppressed for us. See for example JIRA 1297. I do not know the rules which should determine whether it should be present or not.

Here follows the original PHP defect.

Description:
------------
xsi:type is not always set for complexTypes. Notice the absence of xsi:type="collectionInfo" in the actual output.

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"/>
              </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('Blah');
$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 kind="collectionInfo" xsi:type="collectionInfo">
        <collection>Blah</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 kind="collectionInfo">
        <collection>Blah</collection>
    </request>
</request-list>

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #568296 Tue Aug 21 21:37:46 UTC 2007 robbinspg TUSCANY-1564 Always write xsi:type for a property that is an abstract Type
Files Changed
MODIFY /incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp

Repository Revision Date User Message
ASF #568299 Tue Aug 21 21:59:26 UTC 2007 robbinspg TUSCANY-1564 Add testcase
Files Changed
MODIFY /incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest.h
ADD /incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/xsiTypeAbstract_expected.xml
MODIFY /incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/sdotest2.cpp
MODIFY /incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/main.cpp
ADD /incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/test/xsiTypeAbstract.xsd

Repository Revision Date User Message
ASF #568508 Wed Aug 22 08:37:05 UTC 2007 robbinspg TUSCANY-1564 More accurate fix. This caters for when a type is defined as abstract programmatically
Files Changed
MODIFY /incubator/tuscany/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp

Repository Revision Date User Message
ASF #568759 Wed Aug 22 22:14:07 UTC 2007 robbinspg TUSCANY-1564 Always write xsi:type for a property that is an abstract Type
Files Changed
MODIFY /incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
ADD /incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract.xsd
MODIFY /incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
ADD /incubator/tuscany/cpp/sdo/runtime/core/test/xsiTypeAbstract_expected.xml
MODIFY /incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
MODIFY /incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp