From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/113686 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joey McCollum via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: xml processing: if elseif else / switch case Date: Thu, 9 Dec 2021 09:08:43 -0500 Message-ID: References: <5a99613cd1254cf296a97aa479ee740b@unibe.ch> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8267971701185224070==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32724"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Joey McCollum To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Dec 09 15:11:35 2021 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mvK91-0008Mj-0c for gctc-ntg-context-518@m.gmane-mx.org; Thu, 09 Dec 2021 15:11:35 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 028602A1EBE; Thu, 9 Dec 2021 15:11:11 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id plZdcAqQ_gwG; Thu, 9 Dec 2021 15:11:09 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 816D42A1EBF; Thu, 9 Dec 2021 15:11:09 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id A68982A1EBE for ; Thu, 9 Dec 2021 15:11:08 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rNdv3bvd-4le for ; Thu, 9 Dec 2021 15:11:07 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.166.169; helo=mail-il1-f169.google.com; envelope-from=jmccollum20140511@gmail.com; receiver= Original-Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 432802A18BC for ; Thu, 9 Dec 2021 15:11:07 +0100 (CET) Original-Received: by mail-il1-f169.google.com with SMTP id l5so5404004ilv.7 for ; Thu, 09 Dec 2021 06:11:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PZ+eiEmxB0KBAUng5aYwYsDCiiaP6FuBbOCijiGOcRs=; b=IqCYoS2ZYnRnCVPN+lORlsmpZBUSjLU/cbz4lFDdv4o0NoJiTqN5BUKoupid1sjffy kUCBUN/ucNth2OLJMSNgfGQ9xVodC7vRMIwalCl6SOlmVF2PXRUSiTm/01PCftREiOIL O7loDP4z3P0oFpdaNGEApBRU/zRGmPy52SREJWQJDxCHWMMEa+eiC1ND8i0vEaObhogT ZlndcV6Q+UXWzKYb3Ztlqa/epAXbkv00gh2MipWEOEiAovH6Z1JelSA+wGqSHJ+8Nblq Km/GLwMnaKA/rj1UsJz/35LDCzFYoV8P7OwC2f2F88+4DV72PV4tKayJj33c+vSZUavG TCcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PZ+eiEmxB0KBAUng5aYwYsDCiiaP6FuBbOCijiGOcRs=; b=3kFQqD+TjxGnrEfMC/4ACRf1wtn1iiS17WJHaVbzGtdIdHKA0dg+ZgLbQWnAhQ7Fby 76rLcDFFqiX/LB94NgXGZKl7iVqJhukM/OzJZhBv2s63fv3vX4WSUQs2tFNpaT5f2qTX NOAFSKAFyojz/fu46F4geOhFS93g4D1HVxyEN42c4MPReERSR6xBfPiSze+eUeb3zcM7 A//4dx9nDkke9ES9zy89cZoEqE5eceMSywm/7aK4houcs86iK/7gk0RDCHyVW6PdqMuJ +G3/Lcq5LArDI/pWGolP3jAv2Q2c17/e75Ut7zTEm7psas1rDakQLoaJHq13PYaqorWX KgLQ== X-Gm-Message-State: AOAM532ZfgnCK3HEnjM6N4XBPFafYXZ+jjVXwGynC63QChK2KQc6L66i oZNMaaM1ubUdG0NDwoQ3fwz3O7MfMz4gikdkj9g/w0IJqbA= X-Google-Smtp-Source: ABdhPJzMGEIW4u4YzCjtImeHDRCiJ1W1a7wopdqqxL8PJuc1Bkg5Zmx3KfUjWX3BhEq7BBg1UMESdHOVufUqwPIS6h4= X-Received: by 2002:a92:ca46:: with SMTP id q6mr12704926ilo.54.1639059065853; Thu, 09 Dec 2021 06:11:05 -0800 (PST) In-Reply-To: <5a99613cd1254cf296a97aa479ee740b@unibe.ch> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:113686 Archived-At: --===============8267971701185224070== Content-Type: multipart/alternative; boundary="00000000000062d9a305d2b72dfd" --00000000000062d9a305d2b72dfd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I believe \orelse might be what you want. It works with most \if... macros, and it avoids nesting of \doifelse constructs. Here's an example, which I use in conditionally removing preceding punctuation if any other keys are defined before a specific one in an assignment: ``` % If any of the preceding keys was specified, then replace any preceding punctuation with a space % and typeset the number with its CSL abbreviation, followed by a comma \ifdefined\btxsbllocvol \removeunwantedspaces\removepunctuation\btxspace \orelse\ifdefined\btxsbllocno \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocpt \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocp \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocn \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocfig \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocop \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocbk \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocep \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocchap \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocv \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocfol \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocfrag \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocpl \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsblloccol \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocl \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocsv \removeunwantedspaces\removepunctuation\btxspace \fi \orelse\ifdefined\btxsbllocsec \removeunwantedspaces\removepunctuation\btxspace \fi \fi ``` Joey On Thu, Dec 9, 2021, 3:19 AM Denis Maier via ntg-context wrote: > Hi, > > > > I was wondering whether we have tests similar to =C2=ABif-else if-else=C2= =BB or > =C2=ABswitch case=C2=BB in context=E2=80=99s xml processing. (And even in= context more > general...) I have found these doifelse tests, but elseif doesn=E2=80=99t= seem to > exist. Is that correct? If yes, could that be added? Of course, you can > always just nest doifelse-constructs, but that will become ugly quickly. > Being able to specify multiple branches would be handy. > > > > Best, > > Denis > > _________________________________________________________________________= __________ > If your question is of interest to others as well, please add an entry to > the Wiki! > > maillist : ntg-context@ntg.nl / > http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > > _________________________________________________________________________= __________ > --00000000000062d9a305d2b72dfd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I believe \orelse might be what you want. It works with mo= st \if... macros, and it avoids nesting of \doifelse constructs. Here's= an example, which I use in conditionally removing preceding punctuation if= any other keys are defined before a specific one in an assignment:
```
=C2=A0 =C2=A0 =C2=A0 % If any of the preceding keys was = specified, then replace any preceding punctuation with a space
=C2=A0 = =C2=A0 =C2=A0 % and typeset the number with its CSL abbreviation, followed = by a comma
=C2=A0 =C2=A0 =C2=A0 \ifdefined\btxsbllocvol
=C2=A0 =C2=A0= =C2=A0 =C2=A0 \removeunwantedspaces\removepunctuation\btxspace
=C2=A0 = =C2=A0 =C2=A0 \orelse\ifdefined\btxsbllocno
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = \removeunwantedspaces\removepunctuation\btxspace
=C2=A0 =C2=A0 =C2=A0 \f= i
=C2=A0 =C2=A0 =C2=A0 \orelse\ifdefined\btxsbllocpt
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 \removeunwantedspaces\removepunctuation\btxspace
=C2=A0 = =C2=A0 =C2=A0 \fi
=C2=A0 =C2=A0 =C2=A0 \orelse\ifdefined\btxsbllocp
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 \removeunwantedspaces\removepunctuation\btxspac= e
=C2=A0 =C2=A0 =C2=A0 \fi
=C2=A0 =C2=A0 =C2=A0 \orelse\ifdefined\btx= sbllocn
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \removeunwantedspaces\removepunctuat= ion\btxspace
=C2=A0 =C2=A0 =C2=A0 \fi
=C2=A0 =C2=A0 =C2=A0 \orelse\if= defined\btxsbllocfig
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \removeunwantedspaces\r= emovepunctuation\btxspace
=C2=A0 =C2=A0 =C2=A0 \fi
=C2=A0 =C2=A0 =C2= =A0 \orelse\ifdefined\btxsbllocop
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \removeunw= antedspaces\removepunctuation\btxspace
=C2=A0 =C2=A0 =C2=A0 \fi
=C2= =A0 =C2=A0 =C2=A0 \orelse\ifdefined\btxsbllocbk
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 \removeunwantedspaces\removepunctuation\btxspace
=C2=A0 =C2=A0 =C2= =A0 \fi
=C2=A0 =C2=A0 =C2=A0 \orelse\ifdefined\btxsbllocep
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 \removeunwantedspaces\removepunctuation\btxspace
=C2= =A0 =C2=A0 =C2=A0 \fi
=C2=A0 =C2=A0 =C2=A0 \orelse\ifdefined\btxsbllocch= ap
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \removeunwantedspaces\removepunctuation\b= txspace
=C2=A0 =C2=A0 =C2=A0 \fi
=C2=A0 =C2=A0 =C2=A0 \orelse\ifdefin= ed\btxsbllocv
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \removeunwantedspaces\removepu= nctuation\btxspace
=C2=A0 =C2=A0 =C2=A0 \fi
=C2=A0 =C2=A0 =C2=A0 \ore= lse\ifdefined\btxsbllocfol
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \removeunwantedsp= aces\removepunctuation\btxspace
=C2=A0 =C2=A0 =C2=A0 \fi
=C2=A0 =C2= =A0 =C2=A0 \orelse\ifdefined\btxsbllocfrag
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \= removeunwantedspaces\removepunctuation\btxspace
=C2=A0 =C2=A0 =C2=A0 \fi=
=C2=A0 =C2=A0 =C2=A0 \orelse\ifdefined\btxsbllocpl
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 \removeunwantedspaces\removepunctuation\btxspace
=C2=A0 =C2= =A0 =C2=A0 \fi
=C2=A0 =C2=A0 =C2=A0 \orelse\ifdefined\btxsblloccol
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 \removeunwantedspaces\removepunctuation\btxspac= e
=C2=A0 =C2=A0 =C2=A0 \fi
=C2=A0 =C2=A0 =C2=A0 \orelse\ifdefined\btx= sbllocl
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \removeunwantedspaces\removepunctuat= ion\btxspace
=C2=A0 =C2=A0 =C2=A0 \fi
=C2=A0 =C2=A0 =C2=A0 \orelse\if= defined\btxsbllocsv
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \removeunwantedspaces\re= movepunctuation\btxspace
=C2=A0 =C2=A0 =C2=A0 \fi
=C2=A0 =C2=A0 =C2= =A0 \orelse\ifdefined\btxsbllocsec
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \removeun= wantedspaces\removepunctuation\btxspace
=C2=A0 =C2=A0 =C2=A0 \fi
=C2= =A0 =C2=A0 =C2=A0 \fi
```

Joey

On Thu, Dec 9, 2021, 3:19 AM Denis Maier via ntg-context <<= a href=3D"mailto:ntg-context@ntg.nl" target=3D"_blank">ntg-context@ntg.nl> wrote:

Hi,

=C2=A0

I was wondering whether we have tests similar to =C2= =ABif-else if-else=C2=BB or =C2=ABswitch case=C2=BB in context=E2=80=99s xm= l processing. (And even in context more general...) I have found these doif= else tests, but elseif doesn=E2=80=99t seem to exist. Is that correct? If yes, could that be added? Of cours= e, you can always just nest doifelse-constructs, but that will become ugly = quickly. Being able to specify multiple branches would be handy.<= /u>

=C2=A0

Best,

Denis

___________________________________________________________________________= ________
If your question is of interest to others as well, please add an entry to t= he Wiki!

maillist : ntg-context@ntg.nl / http:/= /www.ntg.nl/mailman/listinfo/ntg-context
webpage=C2=A0 : http://www.pragma-ade.nl / http://= context.aanhet.net
archive=C2=A0 : https://bitbucket.org/ph= g/context-mirror/commits/
wiki=C2=A0 =C2=A0 =C2=A0: http://contextgarden.net
___________________________________________________________________________= ________
--00000000000062d9a305d2b72dfd-- --===============8267971701185224070== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============8267971701185224070==--