It's all about the answers!

Ask a question

How to count the number of attributes in a WItype ?

long TRUONG (3654107141) | asked Nov 19 '14, 9:11 p.m.
 Is there an easy way to count the number of attributes, better yet of custom attributes, in a WItype ?

Maybe it wouldn't be so bad, manually, if we had followed advises to keep the number of custom attributes under 100 in a WItype. But we have 624 in one of the 7 similar WItypes. 

sam detweiler commented Nov 19 '14, 9:46 p.m.

We'll you could write a little utility to count them.  

long TRUONG commented Nov 19 '14, 10:41 p.m.

Thx Sam 

Accepted answer

permanent link
Donald Nong (14.5k314) | answered Nov 19 '14, 10:25 p.m.
The easiest way I can think of is to count the attribute entries in the process configuration source. RTC Eclipse client may not have this feature, but any advanced text editors, such as Notepad++, have the feature to count the occurrence of patterns. Custom attributes look like this in the source.
<customAttributes category="" >
  <customAttribute id="Browser" name="Browser" type="enumerationList$browser" />
</customAttributes >
Search "</customAttributes >" should give you the exact number.
long TRUONG selected this answer as the correct answer

long TRUONG commented Nov 19 '14, 11:01 p.m.
Thx Don, 

My comment is too long: will use the answer for it.

long TRUONG commented Nov 19 '14, 11:08 p.m. | edited Nov 20 '14, 12:08 a.m.

 Thx Don,

For the quick and right answer. Didn't get the full understanding of what to look for before pulling the notepad++ (what could we hve done before there is notepad++) search literally for a copy of your string "</customattributes>" but here are the details for slow poke like me:

  • The search gave me:
 new  4 (44 hits)
Line 391:      </customAttributes>
Line 419:      </customAttributes>
Line 1045:      </customAttributes>
Line 1051:      </customAttributes>
Line 1080:      </customAttributes>
  • Clicking on one of the line will lead me to the ID of the WItype right on the next line: in my case clicking on 419 gave me line 420 <customAttributes category="">, the WItype I had manually counted the # of custom attributes
  • There are 626 lines between 419 and 1045, the latter of which is the line of the next found string.
  • Hence besides line 420 there are 625 lines of "<customAttribute id" which are the number of custom attributes in that bug WItype. I had counted only 624 ... (Not going to loose my sleep over that missing one ... nor will I recount to match)
  • All that can be verified by searching for "<customAttribute id" then verify that the search returned all the 625 consecutive lines from 421 to 1044 inclusively.
  • ... Ah! I did count right, 624 lines from 421 to 1044, was just making a mental mistake and included 1045 in the group.

Not sure what was that noise after my first edit. It may return after I save this one

sam detweiler commented Nov 19 '14, 11:37 p.m.

Don, that is amazing!!.. never had an editor that would return counts.. nice

Donald Nong commented Nov 20 '14, 12:15 a.m.

I converted your "answer" to a comment, which it should be. And by some magic, the format became correct and I could read your comment properly.
Yes you are right, "<customAttribute id" gives you the right number, and "</customAttributes>" does not. I overlooked the "s" in the "customAttributes", which means that there can be multiple entries within this entity, and I made the wrong choice.

long TRUONG commented Nov 20 '14, 3:52 p.m.

Nothing a night rest won't help discover if you sleep on it: Have not realized before that you can choose to search by regExp on notepad++

use search string "</customattributes>|<customAttributes category=" and voila, neatly arranged without having to manipulate in .xls or sort:
  new  1 (88 hits)
Line 420:    <customAttributes category="">
Line 1045:    </customAttributes>
hence for WItype bug there are (1045-420+1)-2 (for lines 420 and 1045)= 624

long TRUONG commented Dec 03 '14, 1:27 p.m.

Out of neceessity, some regExp did not work as thought, found the simplest search strings:

 "</customAttributes" for WItypes & their count of custom attributes
"</customAttributes*" for WItypes & their custom attributes

showing 5 of 6 show 1 more comments

Your answer

Register or to post your answer.