Skip to content

numeric simpleValue #342

@atomczak

Description

@atomczak

Let's say I want the value of a length property to be exactly 2.0. I would use <simpleValue>, but it technically only accepts strings.

ids.xsd#L41:
<xs:element name="simpleValue" type="xs:string" minOccurs="1" maxOccurs="1"/>

When I try to convert python data to IDS using xml.etree Python package, it says:

File "...\site-packages\xmlschema\validators\xsdbase.py", line 249, in validation_error raise error
xmlschema.validators.exceptions.XMLSchemaEncodeError: failed validating 2.0 with XsdAtomicBuiltin(name='xs:string'):
Reason: 2.0 is not an instance of <class 'str'>

So the implementers have to remember to cast all alphanumeric values to strings. I think we could improve the schema by replacing the abovementioned line with union type also allowing numbers:

<xs:element name="simpleValue" minOccurs="1" maxOccurs="1">
  <xs:simpleType>
    <xs:union memberTypes="xs:string xs:decimal xs:int"/>
  </xs:simpleType>
</xs:element>

Metadata

Metadata

Assignees

No one assigned

    Labels

    please contributeA PR is welcome for this issue. Please target the `development` branch.schemaIssues that impact the schema file

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions