Home » Modeling » EMF » Force generation of xsi:type
Force generation of xsi:type [message #400141] |
Tue, 11 April 2006 13:55  |
Eclipse User |
|
|
|
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 #400159 is a reply to message #400143] |
Wed, 12 April 2006 09:29   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
>>>
>>>
>>>
|
|
|
Goto Forum:
Current Time: Wed Sep 24 18:16:44 EDT 2025
Powered by FUDForum. Page generated in 0.04276 seconds
|