Serializing number formats requiring padding [message #535789] |
Tue, 25 May 2010 16:03 |
Eclipse User |
|
|
|
Originally posted by: Jo.Calder.m-ais.com
Hi,
I have a data type specified as follows:
<xsd:simpleType name="valAngleBrgBase">
<xsd:restriction base="xsd:decimal">
<xsd:minInclusive value="000"/>
<xsd:maxInclusive value="360"/>
<xsd:pattern value="\d{3}(\.\d{1,4}){0,1}"/>
</xsd:restriction>
</xsd:simpleType>
The use case is in representing compass bearings relative to north. For practical reasons, reflection as a numeric data
type (while not essential) is highly desirable.
When EMF serializes items of type valAngleBrgBase, the standard serialization of decimal number is used, and no leading
zeros are added for, say the value "31.5". As a consequence, EMF will serialize to schema-invalid documents. Is there
a method that can be overridden, or some eCore annotation available, to force serialization into the necessary format?
TIA, -- Jo Calder
|
|
|
Re: Serializing number formats requiring padding [message #535790 is a reply to message #535789] |
Tue, 25 May 2010 16:21 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Jo,
You'll need to specialize XyzFactoryImpl.convertValAngleBrgBaseToString.
Jo Calder wrote:
> Hi,
>
> I have a data type specified as follows:
>
> <xsd:simpleType name="valAngleBrgBase">
> <xsd:restriction base="xsd:decimal">
> <xsd:minInclusive value="000"/>
> <xsd:maxInclusive value="360"/>
> <xsd:pattern value="\d{3}(\.\d{1,4}){0,1}"/>
> </xsd:restriction>
> </xsd:simpleType>
>
> The use case is in representing compass bearings relative to north.
> For practical reasons, reflection as a numeric data type (while not
> essential) is highly desirable.
>
> When EMF serializes items of type valAngleBrgBase, the standard
> serialization of decimal number is used, and no leading zeros are
> added for, say the value "31.5". As a consequence, EMF will serialize
> to schema-invalid documents. Is there a method that can be
> overridden, or some eCore annotation available, to force serialization
> into the necessary format?
>
> TIA, -- Jo Calder
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02532 seconds