Start a new topic
Answered

Path: How to check if an attribute is empty?

I want to filter a set of Items whether an attribute is empty or not. I Have tried using matches:


@ATTR.Matches('^$') that is supposed to identify empty strings(?). I want to do this both for an enumeration attribute and a string attribute.


How can I do this?


Best Answer
Does not this simple solution work?
[@ATTR='']

 


There is a rather elegant, but possibly a bit abstract, example in the Help manual, on the "[ ] Operator":


 

/IRRS[/ISSE=[]]

 

 

Returns all report sections without any subsection.

Hi Jakub,


You can use .Count which counts the number of object in a list.


Example: 


<If test="/SID1/SID2.Count=0">

........


</If>



Best regards,

Bashar

Hello, I have similar question here: is there any way I can check if <List> object is empty? 

Thanks Magnus!

 

It depends on the type of the attribute.

In your case Bashar you have a boolean attribute: AREP, while Fredrik possibly had a string attribute.

 


1 person likes this
I think this will not work  for example:
/part::ARPP[@AREP='']
ERROR: No '=' operator on (Boolean, String) could be found

But if you add ".ToString" it will work
/part::ARPP[@AREP.ToString='']

 

It does. I thought I tried that yesterday without success. Thanks!

Answer
Does not this simple solution work?
[@ATTR='']

 

Login to post a comment