[IFCOpenShell] IDS file to analyze has a property with a value other than XXX

I'm trying to develop an IDS file and analyze it through a python program to check if there is a certain property and if it has a value different from a predefined value. The best way I found for this was to evaluate whether the property exists with a value in the regex pattern '(?!Nenhum).+', which would be any value other than 'Nenhum'
The property of my IDS file that analize that:
<ids:property dataType="IFCTEXT" cardinality="required"> <ids:propertySet> <ids:simpleValue>Circuito</ids:simpleValue> </ids:propertySet> <ids:baseName> <ids:simpleValue>Circuito_*</ids:simpleValue> </ids:baseName> <ids:value> <xs:restriction base="xs:string"> <xs:pattern value="(?!Nenhum).+" /> </xs:restriction> </ids:value> </ids:property>
When i use the function validate with this IDS it gives an error "RegexError: invalid '(?...)' extension notation at position 0: '(?!Nenhum).+' "
What are the best practices for this situation?

Tagged:

Comments

  • Yes, thanks, that explains a few things, my case would be a complex restrictions with pattern and because of limitations of the XML Regular expressions for IDS its not possible use negative lookahead. So apparently it is really not possible with IDS to check if a property is not a predefined value.

  • Maybe try this

    any number of characters (including zero characters) can occur before or after the text "Nenhum".

  • edited August 2024

    My solution that worked:
    Negative lookahead its realy not possible for regular expressions in IDS, the negative, that specify that should not have something with some text, should be in the applicability as a ' maxOccurs="0" ', the requirements go empty. That is working for me to verify if a IFC file have a property with a error value and this allows the system to notify the designer to review these elements

    The final IDS file specification look like this:
    `

    <ids:specification ifcVersion="IFC4" name="SEM CIRCUITO">
      <ids:applicability minOccurs="0" maxOccurs="0">
        <ids:property dataType="IFCTEXT">
          <ids:propertySet>
            <ids:simpleValue>Circuito</ids:simpleValue>
          </ids:propertySet>
          <ids:baseName>
            <xs:restriction base="xs:string">
              <xs:pattern value=".*Circuito.*" />
            </xs:restriction>
          </ids:baseName>
          <ids:value>
            <ids:simpleValue>Nenhum</ids:simpleValue>
          </ids:value>
        </ids:property>
      </ids:applicability>
      <ids:requirements />
    </ids:specification>
    

    `

  • Indeed this is known as a prohibited specification.

  • @Moult said:
    Indeed this is known as a prohibited specification.

    There's an allowed alternative to this case?

Sign In or Register to comment.