buildingSMART / IDS

Computer interpretable (XML) standard to define Information Delivery Specifications for BIM (mainly used for IFC)
Other
167 stars 52 forks source link

Missing tests for property name enumeration restriction #246

Closed sanzoghenzo closed 3 months ago

sanzoghenzo commented 3 months ago

Test cases for the property facet show how to use a regex restriction to match more than one property at a time;

The case of having an enumeration as the name restriction is not considered, though. Just to be sure: is this case allowed? and has the enumeration be interpreted as a "all of"?

A colleague of mine wanted to do something like the case below, and expected the check to be performed on all the properties enlisted. I didn't consider this case in my code, and reading through the ifctester source code it seems that it doesn't, either. It just checks if the property name is in the enumeration, and then exits as soon as a check is not met. Is this the intended behavior by the IDS specification, or should it be treated as a bug?

<requirements>
  <property>
    <propertySet>
      <simpleValue>MyPset</simpleValue>
    </propertySet>
    <name>
      <xs:restriction>
        <xs:enumeration value="Component"/>
        <xs:enumeration value="ComponentDescription"/>
        <xs:enumeration value="DesignPack"/>
        <xs:enumeration value="Discipline"/>
        <xs:enumeration value="Phase"/>
        <xs:enumeration value="GUID"/>
        <xs:enumeration value="ID"/>
      </xs:restriction>
    </name>
    <value>
      <xs:restriction base="xs:string">
        <xs:minLength value="1"/>
        <xs:pattern value="[^ ]+"/>
      </xs:restriction>
    </value>
  </property>
</requirements>
andyward commented 3 months ago

I believe it's the intended behaviour. Enumeration expectations are documented here.

An Enumeration restriction means that the value must be one of a list of allowed values. For example, you might want to specify that a material may be either "concrete" or "steel".

It's a 'oneOf' not 'allOf'. OR not AND.

If you wanted to a requirement that all properties were populated, you'd have to duplicate the property facet for each Name

sanzoghenzo commented 3 months ago

Thanks @andyward for the clarification, that's what I suspected. Not what I wanted, and maybe not what one would expect, but it is in line with the xsd meaning.

Still, my code (and I suppose ifcTester too, I'm checking it now) has to check every matching properties and not only the first one found.