CSS recursive oxy_substring

Oxygen general issues.
dvezina
Posts: 23
Joined: Sat Mar 08, 2014 12:10 am

CSS recursive oxy_substring

Post by dvezina »

Hello,

XML input:

Code: Select all

<NEIGHBORHOOD name="North America|Canada|British Columbia|Vancouver|Downtown"/>
I need to output only "Downtown" from my CSS.

I've tried a combination of nested oxy_indexof and oxy_substring with no luck.

Will someone please send me the correct syntax for this?
I also need to account for the condition of no "|" present.
I'd rather not run an XSLT on this.
THANKS
alex_jitianu
Posts: 1016
Joined: Wed Nov 16, 2005 11:11 am

Re: CSS recursive oxy_substring

Post by alex_jitianu »

Hello,

I think you can get the desired behavior by using these two rules:

Code: Select all

NEIGHBORHOOD:before {
content: attr(name)
}

NEIGHBORHOOD[name*="|"]:before {
content: oxy_substring(attr(name), oxy_add(oxy_lastindexof(attr(name), '|'), 1, integer))
}
The first one will handle the case when the name attribute has only one term and the second rule will get the last term from a | separated enumeration.

Best regards,
Alex
dvezina
Posts: 23
Joined: Sat Mar 08, 2014 12:10 am

Re: CSS recursive oxy_substring

Post by dvezina »

THANK YOU. This is what I needed.
Post Reply