![](https://secure.gravatar.com/avatar/46562c7d27388490d62e8d7a5bc960dd.jpg?s=120&d=mm&r=g)
On 8/24/2023 4:11 PM, denis.maier@unibe.ch wrote:
Hi,
I'm trying to check whether an attribute contains (or, actually starts with) a given string. I've tried a whole bunch of different combinations, but I've had no luck so far. Minimal example below. Anyone has a hint?
Best, Denis
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \startxmlsetups xml:test \xmlsetsetup{#1}{*}{-} \xmlsetsetup{#1}{doc|element}{xml:*} \stopxmlsetups
\xmlregisterdocumentsetup{test}{xml:test}
\startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:element \xmlfilter{#1}{./find(attribute('class'), 'abc')/command(xml:whatever)}
\xmldoifelse{#1}{./attribute('class')/contains('abc')} {Yes}{No} \stopxmlsetups
\startxmlsetups xml:whatever Yes \stopxmlsetups
\startbuffer[test] <?xml version="1.0" encoding="UTF-8"?> <doc> <element class="abcdefg">Yes</element> <element>No</element> </doc> \stopbuffer
\starttext
\xmlprocessbuffer{test}{test}{}
\stoptext \xmldoifelse{#1}{.[@class and contains(@class,'abc')]}{Yes}{No} \xmldoifelse{#1}{.[@class and find(@class,"abc")]}{Yes}{No}
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------