On 07/12/06, Caroline Maynard (JIRA) <[email protected]> wrote:

DataObject assigned into open property goes missing
---------------------------------------------------

                Key: TUSCANY-980
                URL: http://issues.apache.org/jira/browse/TUSCANY-980
            Project: Tuscany
         Issue Type: Bug
         Components: C++ SDO
   Affects Versions: Cpp-current
           Reporter: Caroline Maynard


I have a schema like so:
<schema
xmlns="http://www.w3.org/2001/XMLSchema";>

<element name="jungle">
   <complexType>
     <sequence>
       <any minOccurs="0" maxOccurs="unbounded"/>
     </sequence>
   </complexType>
</element>

<element name="mixedJungle">
   <complexType mixed="true">
     <sequence>
       <any minOccurs="0" maxOccurs="unbounded"/>
     </sequence>
   </complexType>
</element>

</schema>

and another one like so:

<schema xmlns="http://www.w3.org/2001/XMLSchema";>

  <complexType name="snakeType">
    <sequence>
      <element name= "name" type="string"/>
      <element name= "length" type="positiveInteger" />
    </sequence>
  </complexType>

  <complexType name="bearType">
    <sequence>
      <element name= "name" type="string"/>
      <element name= "weight" type="positiveInteger" />
    </sequence>
  </complexType>

  <complexType name="pantherType">
    <sequence>
      <element name= "name" type="string"/>
      <element name= "colour" type="string" />
    </sequence>
  </complexType>

</schema>

Now suppose I load BOTH schemas into the same DataFactory, create a
document with root type jungle, create some animal types and then assign
them into the jungle. When I save the document, I see:

<?xml version="1.0" encoding="UTF-8"?>
<jungle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<bear xsi:type="bearType">
   <name>Baloo</name>
   <weight>700</weight>
</bear>
<panther xsi:type="pantherType">
   <name>Bagheera</name>
   <colour>inky black</colour>
</panther>
<snake xsi:type="snakeType">
   <name>Kaa</name>
   <length>25</length>
</snake>
</jungle>

This is good.

Now I change the example so that the two schemas are loaded into DIFFERENT
Data Factories, and run the same test. The saved document is now:
<?xml version="1.0" encoding="UTF-8"?>
<jungle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<bear xsi:type="bearType" name="Baloo" weight="700"/>
<panther xsi:type="pantherType" name="Bagheera" colour="inky black"/>
<snake xsi:type="snakeType" name="Kaa" length="25"/>
</jungle>

so the elements have turned into attributes.


I have checked in  a fix for this.


Finally, I change the test so that the document root is a mixedJungle
instead of a jungle, that is, it is sequenced. No errors are reported, but
my document comes out as:
<?xml version="1.0" encoding="UTF-8"?>
<mixedJungle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

Now the animals are completely missing. The outcome is the same regardless
of whether I use one or two data factories, btw.


Do you use the Sequence API to add the animals in this case? I suspect not
and this highlights a problem in our implementation where, for a Sequenced
DataObject, setting of Properties using the DataObject::setXXX methods
should delegate to the Sequence API but do not, so they do not appear in the
sequence.

If we make the change to delegate the setting of the property so that any
setXXX on a sequenced SDO will appear in the sequence there is another
question: Should properties that are defined from an XML Schema as
"attributes" be included in the Sequence? I think the answer is NO as that
is what wouild be intended by the schema.

Cheers,


--
Pete

Reply via email to