Question

How can I remove specific elements from a list(=multi-valued-attribute) using a map? For example, let's say I want to filter out all b's in a given list:

<["a", "b", "c", "b"]: {<table.(it)>}; separator=",">
table ::= ["b":, default: key]

The desired outcome would be "a,c" but the actual result is "a,,c,"
The thing is that the map successfully turn b's into nulls, but then they're wrapped in an anonymous template {} and become non-null values. So they won't go away with strip() function, either.

So the question is, would it be possible to filter a list using a map by slightly modifying the code above?

update

I've found a workaround:

filter(it) ::= "<if(it)><it><endif>"
<["a", "b", "c", "b"]: {<table.(it)>}: filter(); separator=",">

This gives the result I wanted: a,c

Was it helpful?

Solution

Might not want to filter in your template, but nonetheless, could be a bug.

Ok, i checked it out. That gives empty not null so it thinks it's an item. ST treats false conditionals same way: empty not null. I think you need to filter in model.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top