I traced this through to SDOXMLWriter::writeDO, line 1105 in my version
          if (dataObjectType.isSequencedType())
           {
               SequencePtr sequence  = dataObject->getSequence();
               if (sequence)
               {
                   for (i=0; i<sequence->size(); i++)
                   {

                       if (sequence->isText(i))
                       {
                           // do unstructured text stuff, and
                           continue;
                       } // end TextType

                       const Property& seqProp = sequence->getProperty(i);
                       SDOXMLString seqPropName = seqProp.getName();
                       const Type& seqPropType = seqProp.getType();

                       if (seqPropType.isDataObjectType())
                       {
                          // do DataObject stuff
                       } // end DataObject


                       else
                       {
                           // Sequence member is a primitive
                           writeXMLElement(writer,
                                   seqPropName,
                                   sequence->getCStringValue(i));

                       } // end DataType
                   } // end - iterate over sequence

               }

           } // end sequence handling

so it seems that if the data object is sequenced, it will write primitive
properties as elements unconditionally. The code to handle non-sequenced
objects, which follows this snippet, has some much more complicated
conditions.Looks like it has been updated while the sequenced clause has
been allowed to go a bit stale.


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

    [
http://issues.apache.org/jira/browse/TUSCANY-963?page=comments#action_12454956]

Caroline Maynard commented on TUSCANY-963:
------------------------------------------

It's not necessary for the element to be open for this to occur, it's
sufficient for it to be sequenced.

> Spurious elements generated
> ---------------------------
>
>                 Key: TUSCANY-963
>                 URL: http://issues.apache.org/jira/browse/TUSCANY-963
>             Project: Tuscany
>          Issue Type: Bug
>          Components: C++ SDO
>    Affects Versions: Cpp-current
>            Reporter: Caroline Maynard
>            Priority: Critical
>
> I have a schema like so:
> <?xml version="1.0" encoding="utf-8" ?>
> <xs:schema targetNamespace="http://www.w3.org/2005/Atom";
> xmlns="http://www.w3.org/2005/Atom"; xmlns:xs="
http://www.w3.org/2001/XMLSchema";>
> <xs:import namespace="http://www.w3.org/XML/1998/namespace";
schemaLocation="xml.xsd" />
> <xs:import namespace="http://www.w3.org/1999/xhtml"; schemaLocation="
xhtml1-strict.xsd" />
> <xs:element name="content" type="contentType" minOccurs="0" />
> <xs:complexType name="contentType" mixed="true" >
> <xs:sequence>
> <xs:any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded" />
> </xs:sequence>
> <xs:attribute name="type" type="xs:string" default="text" />
> <xs:attribute name="src" type="xs:string" /> <!-- uriType -->
> <xs:attributeGroup ref="commonAttributes"/>
> </xs:complexType>
> <xs:attributeGroup name="commonAttributes">
> <xs:attribute ref="xml:base" />
> <xs:attribute ref="xml:lang" />
> <xs:anyAttribute/>
> </xs:attributeGroup>
> </xs:schema>
> and a document like so:
> <?xml version="1.0" encoding="UTF-8"?>
> <content xmlns="http://www.w3.org/2005/Atom"; xmlns:tns="
http://www.w3.org/2005/Atom";
> xml:base="blah" xml:lang="blah2" />
> I load the schema with XSDHelper::defineFile(), and then load the
document with XMLHelper::loadFile().
> Then I do a save() of the document. The output is:
> <?xml version="1.0" encoding="UTF-8"?>
> <content xmlns="http://www.w3.org/2005/Atom";
>                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>                  xmlns:tns="http://www.w3.org/2005/Atom";
>                  base="blah" lang="blah2">
>   <base>blah</base>
>   <lang>blah2</lang>
> </content>
> So not only do I have the lang and base attributes on <content>, I get
some elements thrown in for free, too.
> You'll notice that id is both sequenced and open. I'll find out if both
these conditions are necessary.

Reply via email to