Re: [xsl] How to retrieve the element with value DIR and not the element with value TURN_DIR?

Subject: Re: [xsl] How to retrieve the element with value DIR and not the element with value TURN_DIR?
From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 3 Jan 2025 02:32:19 -0000
> Or contains(concat(',', field, ','), 'DIR') but then you are sensitive
>   to values like
>      "DIR , OTHER"
> (a leading or trailing space should be removed by the XML parser,
> though)

Not a problem if spaces can occur only within the delimiters - just use:

contains(concat(',', translate(field, ' ', ''), ','), ',DIR,')



On Thu, Jan 2, 2025 at 5:16b/PM Liam R. E. Quin liam@xxxxxxxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> On Thu, 2025-01-02 at 23:04 +0000, Martin Honnen martin.honnen@xxxxxx
> wrote:
> >
> > contains-token tokenizes on pure whitespace, no? With that comma in
> > there I don't think it helps.
>
> oh, i didn't look closely enough, you're right. No, tokenize() it is.
>
> Or contains(concat(',', field, ','), 'DIR') but then you are sensitive
> to values like
>    "DIR , OTHER"
> (a leading or trailing space should be removed by the XML parser,
> though)
>
> liam
>
> --
> Liam Quin, https://www.delightfulcomputing.com/
> Available for XML/Document/Information Architecture/XSLT/
> XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
> Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org

Current Thread