M2Doc requirement VP custom attribute data

Hi All,

Before returning the data of a custom attribute of a requirement, I’m trying to check that the attribute actually has some data to return. Using the M2Doc Interpreter and entering the following command where “selection” is a requirement, it returns the number of characters in the attribute, as expected.

selection.ownedAttributes->filter(Requirements::StringValueAttribute)->select(a | a.definition.ReqIFLongName = ‘reqtRationale’).value.size()

However, if I try to compare that value to a number e.g. “<> 0”, it doesn’t matter what the size is (0 or non-0), the condition always returns “true”.

I also notice the comparison on the size() function is not giving me many options which makes me think I’m not returning an appropriate value to do a comparison with

  1. Could someone explain why this is happening?
  2. Assuming there is an easy fix to this problem, is this a sensible approach to checking if the attribute is empty or not?

The return type of the select is a collection then calling value on it returns a collection of String. Here we have a specificity of AQL, using:

  • . will call the service/feature on each element of the collection like an implicit collect
  • -> will call the service on the collection itself

in your test you check is a collection is different from 0 which is always true.

So you can check if the collection ->isEmpty()

We can’t see the difference between a collection and a scalar in the M2Doc interperter because it render the result as text (HTML).