[ 
https://issues.apache.org/jira/browse/TUSCANY-2719?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12653848#action_12653848
 ] 

Frank Budinsky commented on TUSCANY-2719:
-----------------------------------------

Thanks Andrey. The only problem I see with your fix is that it can wipe out the 
users choice (set by the xmlElement property/annotation).

A better fix would be to change the initialization of the isXmlElement variable 
to this:

            Boolean isXmlElement = newProperty.isMany() || 
newProperty.isNullable();




> Wrong serialization DataObject in XML if DataObject is defined by means of 
> dynamic type
> ---------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-2719
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-2719
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>            Reporter: Andrey Utkin
>
> 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 ^)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to