From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/97824 Path: news.gmane.org!.POSTED!not-for-mail From: Gerard Keiser Newsgroups: gmane.comp.tex.context Subject: \xmldoifelse false condition Date: Fri, 14 Apr 2017 13:17:57 -0500 Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1672872402356349716==" X-Trace: blaine.gmane.org 1492193976 21952 195.159.176.226 (14 Apr 2017 18:19:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 14 Apr 2017 18:19:36 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Fri Apr 14 20:19:31 2017 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cz5oe-0005Yi-RV for gctc-ntg-context-518@m.gmane.org; Fri, 14 Apr 2017 20:19:28 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 5A37584FBA; Fri, 14 Apr 2017 20:18:53 +0200 (CEST) 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 DnW2Z6eCSRvZ; Fri, 14 Apr 2017 20:18:52 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id 2326184FB7; Fri, 14 Apr 2017 20:18:52 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 71BB784FB7 for ; Fri, 14 Apr 2017 20:18:50 +0200 (CEST) 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 aB-qSdv71pQm for ; Fri, 14 Apr 2017 20:18:49 +0200 (CEST) Original-Received: from mail-vk0-f42.google.com (mail-vk0-f42.google.com [209.85.213.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 9C34E84FB6 for ; Fri, 14 Apr 2017 20:18:39 +0200 (CEST) Original-Received: by mail-vk0-f42.google.com with SMTP id r69so41881765vke.2 for ; Fri, 14 Apr 2017 11:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=PbUX8OJfnRqNNcQhxyC4TBusUf5fsdq37gqo3J3fCG0=; b=NYF3grR9yARC8XLXwv/ekn/NpfMsOAWAOlYeXU9V9mWE1fH3F8Leh2bbMs8nKWq7fe Q3KsGiIx+zsk7mOHHNxGJet88WUYwSrszxIjFQnl3WyXnGqqB3ryTjmGUteQ4WE99xeF 6hfuR8HS/q9LJdv1oz3lyYzXPQ/IHiY5Desh20Q34qqOzKfWAd9Gw25LEmP6cpuz9+Md M29iYYOUnCzbvwLL6/1o0kvakRhhwEkoisQUSOz7N2ft7XGx5AIsID1fHs+HXLn1nXJs 0CNJj+15RKp7ebr4rolJinpunyOiax5gv9+5G9RgRWvqzjE00Gl2SEjfT+W71lMD3WEa WtKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=PbUX8OJfnRqNNcQhxyC4TBusUf5fsdq37gqo3J3fCG0=; b=c+sYJeToS1SKQ6EigAWn3rCjVQo+6jxwyxOrmk6Q5v3wGe/ep+P21KPvisSDx/oxQY Hd+bGHUceNxz4LOvm16ViNiWYP3uS4PX9xQz0O1I62JpJLamW7dlqKaFeQJxXTVU11yJ 9LOHMSksqoleKSrs0YLM8RSr8MHpQ0cMTa/0I6yTZKtXzuutk+1iEVyVSLk4OGOmFWhV 8xgVqW/+4w0/iJxXuRTvYJ5K3tnkabxBRsKX6SaMqBxvXgD7sNy5S6ko7B+gzPhGrrUP MHbDUv6aCTCMinPfIYzYo5PQRX13PUzHM5Di7b1j0HqDRUIlr9/EZzvGMVzQ3IyQ2apT /9yQ== X-Gm-Message-State: AN3rC/4ghhOgHg/tuTnix+hTR+HeZWqONPf7FWtnC5N0cupCN+U27Riz Qy2/dSFIshZZrrdJWSIGmh5Cuy3bD9kEhlQ= X-Received: by 10.31.224.134 with SMTP id x128mr2442441vkg.173.1492193917796; Fri, 14 Apr 2017 11:18:37 -0700 (PDT) Original-Received: by 10.103.146.136 with HTTP; Fri, 14 Apr 2017 11:17:57 -0700 (PDT) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 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.org gmane.comp.tex.context:97824 Archived-At: --===============1672872402356349716== Content-Type: multipart/alternative; boundary=94eb2c07afe268081b054d247885 --94eb2c07afe268081b054d247885 Content-Type: text/plain; charset=UTF-8 I am trying to select specific elements from an XML document to make anthologies, and still retain the original numbering, by using \xmldoifelse; if the node matches, it is printed, and if it is not, the head number is incremented, to get something like this: 1 First Section (first match) 4 Fourth Section (second match, but fourth element in the XML file) But the fail condition is not being triggered properly. Here are the files: % % anthologize.xml % \def\incrementheadnumber[#1]{\setupheadnumber[#1] [\numexpr\namedheadnumber{#1}+1\relax]} \startxmlsetups xml:selectivity:* \xmlsetsetup{\xmldocument}{*}{-} \xmlsetsetup{\xmldocument}{stuff|div|head}{xml:selectivity:*} \stopxmlsetups \xmlregisterdocumentsetup{selectivity}{xml:selectivity:*} % Here is the difficulty. \startxmlsetups{xml:selectivity:stuff} \xmldoifelse{#1}{/div[match()==1 or match()==4]/all()} { \xmlflush{#1} } { \incrementheadnumber[section] } \stopxmlsetups \startxmlsetups{xml:selectivity:div} \xmlflush{#1} \stopxmlsetups \startxmlsetups{xml:selectivity:head} \startsection[title={\xmlflush{#1}}]\stopsection \stopxmlsetups \starttext \xmlprocessfile{selectivity}{bob.xml}{} \stoptext % % bob.xml %
First Section
Second Section
Third Section
Fourth Section
The result is that only the first and fourth heads are printed, as desired, but I end up with: 1 First Section 2 Fourth Section. I have used the \incrementheadnumber function elsewhere, and it works fine. If I replace \incrementheadnumber[section] with \xmlflush{#1}, it prints: 1 First Section 2 Fourth Section 3 First Section 4 Second Section 5 Third Section 6 Fourth Section So it seems to be properly triggering the true condition, but not the false condition, and I cannot figure out how to fix it. Using ConTeXt 2017.04.08 and LuaTeX 1.0.3. I do thank you for your help. Sincerely, Gerard Keiser --94eb2c07afe268081b054d247885 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I am trying to select specific elements from an XML document to make= anthologies, and still retain the original numbering, by using \xmldoifels= e; if the node matches, it is printed, and if it is not, the head number is= incremented, to get something like this:

=C2=A0 =C2=A0 1 First Sect= ion (first match)
=C2=A0 =C2=A0 4 Fourth Section (second match, but fourth e= lement in the XML file)

=C2=A0But the fail condition is not being trigge= red properly. Here are the files:

%
% anthologize.xml
%
\def\in= crementheadnumber[#1]{\setupheadnumber[#1]
=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [\numexpr\namedheadnumber{#1}+1\relax]= }

\startxmlsetups xml:selectivity:*
=C2=A0 \xmlsetsetup{\xmldocum= ent}{*}{-}
=C2=A0 \xmlsetsetup{\xmldocument}{stuff|div|head}{xml:selecti= vity:*}
\stopxmlsetups

\xmlregisterdocumentsetup{selectivity}{xml= :selectivity:*}

% Here is the difficulty.
\startxmlsetups{xml:selectivity= :stuff}
=C2=A0=C2=A0=C2=A0 \xmldoifelse{#1}{/div[match()=3D=3D1 or match= ()=3D=3D4]/all()}
=C2=A0=C2=A0=C2=A0 {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= \xmlflush{#1}
=C2=A0=C2=A0=C2=A0 } {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = \incrementheadnumber[section]
=C2=A0=C2=A0=C2=A0 }
\stopxmlsetups
=
\startxmlsetups{xml:selectivity:div}
=C2=A0 \xmlflush{#1}
\stopxm= lsetups

\startxmlsetups{xml:selectivity:head}
=C2=A0 \startsectio= n[title=3D{\xmlflush{#1}}]\stopsection
\stopxmlsetups

\starttext<= br>
=C2=A0 \xmlprocessfile{selectivity}{bob.xml}{}

\stoptext
<= br>
%=
% bob.xml
%
<stuff>
=C2=A0 <div>
=C2=A0=C2=A0= =C2=A0 <head>First Section</head>
=C2=A0 </div>
=C2= =A0 <div>
=C2=A0=C2=A0=C2=A0 <head>Second Section</head&g= t;
=C2=A0 </div>
=C2=A0 <div>
=C2=A0=C2=A0=C2=A0 <h= ead>Third Section</head>
=C2=A0 </div>
=C2=A0 <div&= gt;
=C2=A0=C2=A0=C2=A0 <head>Fourth Section</head>
=C2=A0= </div>
</stuff>

The result is that only the first and fo= urth heads are printed, as desired, but I end up with:

=C2=A0=C2=A0=C2= =A0 1 First Section
=C2=A0=C2=A0=C2=A0 2 Fourth Section.

I have used = the \incrementheadnumber function elsewhere, and it works fine. If I replac= e \incrementheadnumber[section] with \xmlflush{#1}, it prints:

=C2=A0=C2= =A0=C2=A0 1 First Section
=C2=A0=C2=A0=C2=A0 2 Fourth Section
=C2=A0=C2=A0=C2= =A0 3 First Section
=C2=A0=C2=A0=C2=A0 4 Second Section
=C2=A0=C2=A0=C2=A0 5= Third Section
=C2=A0=C2=A0=C2=A0 6 Fourth Section

So it seems to be pr= operly triggering the true condition, but not the false condition, and I ca= nnot figure out how to fix it. Using ConTeXt 2017.04.08 and LuaTeX 1.0.3. I= do thank you for your help.

Sincerely,
Gerard Keiser
--94eb2c07afe268081b054d247885-- --===============1672872402356349716== 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 X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f --===============1672872402356349716==--