创建新话题
已回答

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?


最佳答案
Does not this simple solution work?
[@ATTR='']

 


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

 

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

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 depends on the type of the attribute.

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

 

Liquid error: translation data {:other=>"%{count} 人 "} can not be used with :count => 1. key 'one' is missing.
Thanks Magnus!

 

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

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

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.

登录 发表评论