Uploaded image for project: 'Tuscany'
  1. Tuscany
  2. TUSCANY-1564

xsi:type not always set for complexTypes



    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • C++-SCA-Next
    • None
    • C++ SDO
    • None
    • Win XP and Gentoo Linux


      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.

      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:extension base="requestType">
      <xsd:sequence minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="collection"/>
      <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");

      { $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">

      Actual result:
      <?xml version="1.0" encoding="UTF-8"?>
      <request-list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <request kind="collectionInfo">




            Unassigned Unassigned
            matthew.f.peters Matthew Peters
            1 Vote for this issue
            2 Start watching this issue