ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] xmldoif: checking for contents of attribute
@ 2023-08-24 14:11 denis.maier
  2023-08-24 14:34 ` [NTG-context] " Thomas A. Schmitz
  2023-08-24 14:54 ` Hans Hagen
  0 siblings, 2 replies; 8+ messages in thread
From: denis.maier @ 2023-08-24 14:11 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 989 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 4960 bytes --]

[-- Attachment #2: Type: text/plain, Size: 495 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-08-25 12:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-24 14:11 [NTG-context] xmldoif: checking for contents of attribute denis.maier
2023-08-24 14:34 ` [NTG-context] " Thomas A. Schmitz
2023-08-25  6:25   ` denis.maier
2023-08-24 14:54 ` Hans Hagen
2023-08-25  6:22   ` denis.maier
2023-08-25  7:05     ` Hans Hagen
2023-08-25 11:45       ` denis.maier
2023-08-25 12:48         ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).