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

Wrong serialization DataObject in XML if DataObject is defined by means of dynamic type

    XMLWordPrintableJSON

Details

    • Patch Available

    Description

      SDO 2.1.0 Specification define rules for XML generation of DataObject`s property defined by dynamic types (without XSD) that (part "10 Generation of XSD from SDO Type and Property" page 107):
      ===
      An element is generated if property.many,
      property.containment, or property.nullable is true, or if property.get(xmlElement) is
      present and set to true, where xmlElement is an open content property in
      commonj.sdo/xml. If the property is bidirectional and the opposite property has
      containment=true, nothing is generated. Otherwise, an attribute is generated.
      ===

      But Tuscany generates element by default. Attributes generated only for properties with corresponding xmlElement - the "many" and "nullable" properties dont checked.
      XML documents generated for such DataObjects is not corresponds to XSD generated for their Types (XSDHelper.generate()). So, it is not possible to deserialize XML back to DataObject.

      I have changed /org/apache/tuscany/sdo/helper/TypeHelperImpl.java method "void initializeProperty()" as follow:
      ====
      — tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-07-10 16:53:42.000000000 +0400
      +++ /patch/apache-tuscany-sdo-1.1.1/tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-12-05 06:54:56.000000000 +0300
      @@ -271,6 +271,12 @@
      }
      }
      }
      +
      + // Check for many and nullable
      + if (!newProperty.isMany() && !newProperty.isNullable())

      { + isXmlElement = Boolean.FALSE; + }

      +
      if (!isXmlElement.booleanValue())

      { SDOUtil.setPropertyXMLKind(newProperty, false); }

      ====

      May be it is not very correct, but works for me ^)

      Attachments

        1. TUSCANY-2719-3.patch
          2 kB
          Andrey Utkin
        2. TUSCANY-2719-2.patch
          2 kB
          Andrey Utkin

        Activity

          People

            Unassigned Unassigned
            ciand7 Andrey Utkin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: