OpenMath / py-openmath

An OpenMath 2.0 implementation in Python
MIT License
15 stars 4 forks source link

when converting big floats to OpenMath, remove the + of the exponent #31

Open MarcoCostantini opened 4 years ago

MarcoCostantini commented 4 years ago

the XML standard requires that the floats are without the + in the exponent, see https://docstore.mik.ua/orelly/xml/schema/ch04_04.htm Hence 10.0**20 should be converted as <OMF dec="1e20"/>, not as <OMF dec="1e+20"/>

>>> encoder.encode_bytes(converter.to_openmath([10.0**20]))
b'<OMA xmlns="http://www.openmath.org/OpenMath"><OMS cdbase="http://www.openmath.org/cd" name="list" cd="list1"/><OMF dec="1e+20"/></OMA>'
>>> 

This output in fact doesn't validate, even if the OMOBJ tag is added, see https://www.openmath.org/validation/omvalidate.html

To validate OpenMath, it can be used also the online validator https://www.liquid-technologies.com/online-relaxng-validator with the grammar copied from https://www.openmath.org/standard/om20-2019-07-01/omstd20.html#app_openmath.rng