Skip to main content



      Home
Home » Modeling » EMF » Force generation of xsi:type
Force generation of xsi:type [message #400141] Tue, 11 April 2006 13:55 Go to next message
Eclipse UserFriend
Hi,

in a standard EMF model serialization, an xsi:type attribute is only
generated for those model elements, whose type is a subtype of their
containment reference type.
My question: is there a chance to force the generation of the xsi:type
attribute for every element? I didn't find a way in the generator model.

Regards,
Marco
Re: Force generation of xsi:type [message #400143 is a reply to message #400141] Tue, 11 April 2006 14:09 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------060901050009040401020205
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Marco,

You can use this option during save:

/**
* Use XMLTypeInfo to determine whether type information
(xsi:type/xmi:type) is
* to be serialized for references.
*/
String OPTION_SAVE_TYPE_INFORMATION = "SAVE_TYPE_INFORMATION";


Marco Mosconi wrote:
> Hi,
>
> in a standard EMF model serialization, an xsi:type attribute is only
> generated for those model elements, whose type is a subtype of their
> containment reference type.
> My question: is there a chance to force the generation of the xsi:type
> attribute for every element? I didn't find a way in the generator model.
>
> Regards,
> Marco


--------------060901050009040401020205
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Marco,<br>
<br>
You can use
Re: Force generation of xsi:type [message #400159 is a reply to message #400143] Wed, 12 April 2006 09:29 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the hint. Unfortunately it doesn't work as I suspected,
because even if XMLResource.OPTION_SAVE_TYPE_INFORMATION is set to true,
the method XMLSaveImpl.XMLTypeInfoImpl.shouldSaveType decides that the
type attribute is only generated, if the expected type is not the actual
type of the element.

In fact, it doesn't make any difference whether the option is set to
true or false, as you can see in the following code snippet from
XMLSaveImpl:

....
if (saveTypeInfo ? xmlTypeInfo.shouldSaveType(eClass, eType, f) : eClass
!= eType && eClass != anyType)
....

if saveTypeInfo is true, the same condition is checked:

public boolean shouldSaveType(EClass objectType, EClassifier
featureType, EStructuralFeature feature)
{
return objectType != featureType && objectType != anyType;
}

Is this intended, a bug or just redundant?

Regards,
Marco

Ed Merks wrote:
> Marco,
>
> You can use this option during save:
>
> /**
> * Use XMLTypeInfo to determine whether type information
> (xsi:type/xmi:type) is
> * to be serialized for references.
> */
> String OPTION_SAVE_TYPE_INFORMATION = "SAVE_TYPE_INFORMATION";
>
>
> Marco Mosconi wrote:
>> Hi,
>>
>> in a standard EMF model serialization, an xsi:type attribute is only
>> generated for those model elements, whose type is a subtype of their
>> containment reference type.
>> My question: is there a chance to force the generation of the xsi:type
>> attribute for every element? I didn't find a way in the generator model.
>>
>> Regards,
>> Marco
>
>
Re: Force generation of xsi:type [message #400161 is a reply to message #400159] Wed, 12 April 2006 10:10 Go to previous messageGo to next message
Eclipse UserFriend
Marco,

You can create your own derived XMLSaveImpl.XMLTypeInfoImpl with your
own algorithm for deciding. It does seem to me that passing in TRUE
should do this by default. Please open a bugzilla so I can fix this.


Marco Mosconi wrote:

> Thanks for the hint. Unfortunately it doesn't work as I suspected,
> because even if XMLResource.OPTION_SAVE_TYPE_INFORMATION is set to
> true, the method XMLSaveImpl.XMLTypeInfoImpl.shouldSaveType decides
> that the type attribute is only generated, if the expected type is not
> the actual type of the element.
>
> In fact, it doesn't make any difference whether the option is set to
> true or false, as you can see in the following code snippet from
> XMLSaveImpl:
>
> ...
> if (saveTypeInfo ? xmlTypeInfo.shouldSaveType(eClass, eType, f) :
> eClass != eType && eClass != anyType)
> ...
>
> if saveTypeInfo is true, the same condition is checked:
>
> public boolean shouldSaveType(EClass objectType, EClassifier
> featureType, EStructuralFeature feature)
> {
> return objectType != featureType && objectType != anyType;
> }
>
> Is this intended, a bug or just redundant?
>
> Regards,
> Marco
>
> Ed Merks wrote:
>
>> Marco,
>>
>> You can use this option during save:
>>
>> /**
>> * Use XMLTypeInfo to determine whether type information
>> (xsi:type/xmi:type) is
>> * to be serialized for references.
>> */
>> String OPTION_SAVE_TYPE_INFORMATION = "SAVE_TYPE_INFORMATION";
>>
>>
>> Marco Mosconi wrote:
>>
>>> Hi,
>>>
>>> in a standard EMF model serialization, an xsi:type attribute is only
>>> generated for those model elements, whose type is a subtype of their
>>> containment reference type.
>>> My question: is there a chance to force the generation of the
>>> xsi:type attribute for every element? I didn't find a way in the
>>> generator model.
>>>
>>> Regards,
>>> Marco
>>
>>
>>
Re: Force generation of xsi:type [message #400162 is a reply to message #400161] Wed, 12 April 2006 10:50 Go to previous message
Eclipse UserFriend
https://bugs.eclipse.org/bugs/show_bug.cgi?id=136347

Ed Merks schrieb:
> Marco,
>
> You can create your own derived XMLSaveImpl.XMLTypeInfoImpl with your
> own algorithm for deciding. It does seem to me that passing in TRUE
> should do this by default. Please open a bugzilla so I can fix this.
>
>
> Marco Mosconi wrote:
>
>> Thanks for the hint. Unfortunately it doesn't work as I suspected,
>> because even if XMLResource.OPTION_SAVE_TYPE_INFORMATION is set to
>> true, the method XMLSaveImpl.XMLTypeInfoImpl.shouldSaveType decides
>> that the type attribute is only generated, if the expected type is not
>> the actual type of the element.
>>
>> In fact, it doesn't make any difference whether the option is set to
>> true or false, as you can see in the following code snippet from
>> XMLSaveImpl:
>>
>> ...
>> if (saveTypeInfo ? xmlTypeInfo.shouldSaveType(eClass, eType, f) :
>> eClass != eType && eClass != anyType)
>> ...
>>
>> if saveTypeInfo is true, the same condition is checked:
>>
>> public boolean shouldSaveType(EClass objectType, EClassifier
>> featureType, EStructuralFeature feature)
>> {
>> return objectType != featureType && objectType != anyType;
>> }
>>
>> Is this intended, a bug or just redundant?
>>
>> Regards,
>> Marco
>>
>> Ed Merks wrote:
>>
>>> Marco,
>>>
>>> You can use this option during save:
>>>
>>> /**
>>> * Use XMLTypeInfo to determine whether type information
>>> (xsi:type/xmi:type) is
>>> * to be serialized for references.
>>> */
>>> String OPTION_SAVE_TYPE_INFORMATION = "SAVE_TYPE_INFORMATION";
>>>
>>>
>>> Marco Mosconi wrote:
>>>
>>>> Hi,
>>>>
>>>> in a standard EMF model serialization, an xsi:type attribute is only
>>>> generated for those model elements, whose type is a subtype of their
>>>> containment reference type.
>>>> My question: is there a chance to force the generation of the
>>>> xsi:type attribute for every element? I didn't find a way in the
>>>> generator model.
>>>>
>>>> Regards,
>>>> Marco
>>>
>>>
>>>
Previous Topic:Generating XML and Relationships
Next Topic:Adding eattributes to existing static eclass
Goto Forum:
  


Current Time: Wed Sep 24 18:16:44 EDT 2025

Powered by FUDForum. Page generated in 0.04276 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top