XPath Expression problem

E

Elmer Miller

I have an edit form that contains 5 checkboxes. They are actually setup as
default values in a repeating table. I also have a print view for the edit
view in which I would like to display the text of all the selected items in
an expression box delimited by ", " but I can't figure out how to write the
xpath expression for this.
The best I can do so far is something like this:

concat(my:Options/my:Option[1][my:Selected =1]/my:Text, ", ",
my:Options/my:Option[2][my:Selected = 1]/my:Text, ", ",
my:Options/my:Option[3][my:Selected = 1]/my:Text, ", ",
my:Options/my:Option[4][my:Selected = 1]/my:Text, ", ",
my:Options/my:Option[5][my:Selected = 1]/my:Text)

But this results in extra commas in cases where an item is not selected.
There must by a way to not concat the ", " in cases where the item is not
selected, but there doesn't seem to be any iff function.

Another idea I thought of was to use a combination of the replace function
and normalize-space. I would use spaces as the delimiter then
normalize-space to merge consecutive spaces, then use replace to change
space to comma. The problem with this idea is that I want to have my
delimiter be comma space not just comma. The replace function only works
with single characters. right?

Any ideas would be appreciated. Thanks.
 
Top