Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numeric simpleValue #342

Open
atomczak opened this issue Sep 12, 2024 · 1 comment
Open

numeric simpleValue #342

atomczak opened this issue Sep 12, 2024 · 1 comment
Labels
decide To vote on during next meeting schema Issues that impact the schema file
Milestone

Comments

@atomczak
Copy link
Contributor

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>
@atomczak atomczak added decide To vote on during next meeting schema Issues that impact the schema file labels Sep 12, 2024
@atomczak atomczak added this to the 1.1 milestone Sep 12, 2024
atomczak added a commit to atomczak/IfcOpenShell that referenced this issue Sep 12, 2024
The input value can be a string or number, but 1.0 schema only accepts strings. The processing of int and float was missing. The casting to string might no longer be needed in IDS 1.1. buildingSMART/IDS#342
@janbrouwer
Copy link
Contributor

and xs:boolean ?

Moult pushed a commit to IfcOpenShell/IfcOpenShell that referenced this issue Sep 18, 2024
The input value can be a string or number, but 1.0 schema only accepts strings. The processing of int and float was missing. The casting to string might no longer be needed in IDS 1.1. buildingSMART/IDS#342
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
decide To vote on during next meeting schema Issues that impact the schema file
Projects
None yet
Development

No branches or pull requests

2 participants