From denis.maier.lists@mailbox.org Mon Sep 21 18:31:40 2020 From: Denis Maier To: ntg-context@ntg.nl Subject: [NTG-context] How to get the last item from an XML node Date: Mon, 21 Sep 2020 18:31:33 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7417460121414803707==" --===============7417460121414803707== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Hi struggling again: Shouldn't the code below give me the last element under ? Right now \xmlfilter{#1}{/tr/last()/command(xml:table:tbody:tr)} gives me nothing... (Use case is that I want to have a frame above the table and one bar below. So I think I should wrap the last line in the \startxtablefoot ...\stopxtablefoot, i.e., I need one command for the last element, and one for the rest (Or is there a better way?). What would be the everything but the last? What am I missing? Thanks again, Denis ================== \setupxtable[frame=off,split=yes] \setupxtable[head][topframe=on,bottomframe=on] \setupxtable[body][] \setupxtable[foot][bottomframe=on] \startbuffer[test]
                                                                        
5A
7B
2C
\stopbuffer \startxmlsetups xml:test     \xmlsetsetup{#1}{*}{-}     \xmlsetsetup{#1}{article}{xml:*}     \xmlsetsetup{#1}{table}{xml:table}     \stopxmlsetups \xmlregistersetup{xml:test} \startxmlsetups xml:article \starttext     \xmlflush{#1} \stoptext \stopxmlsetups \startxmlsetups xml:table   \startembeddedxtable         \xmlfilter{#1}{/tbody/command(xml:table:tbody)}   \stopembeddedxtable \stopxmlsetups \startxmlsetups xml:table:tbody     \xmlfilter{#1}{/tr/last()/command(xml:table:tbody:tr)} \stopxmlsetups \startxmlsetups xml:table:tbody:tr     \startxrow     \xmlfilter{#1}{/td/command(xml:table:tbody:tr:td)}     \stopxrow \stopxmlsetups \startxmlsetups xml:table:tbody:tr:td     \startxcell         \xmlflush{#1}     \stopxcell \stopxmlsetups \xmlprocessbuffer{test}{test}{} ================== --===============7417460121414803707==-- From taco@elvenkind.com Tue Sep 22 09:18:55 2020 From: Taco Hoekwater To: ntg-context@ntg.nl Subject: Re: [NTG-context] How to get the last item from an XML node Date: Tue, 22 Sep 2020 09:18:21 +0200 Message-ID: <87FBC62F-57F8-4E9F-9B39-E5D1EAD13314@elvenkind.com> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7916578918831007356==" --===============7916578918831007356== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable > On 21 Sep 2020, at 18:31, Denis Maier wro= te: >=20 > Hi >=20 > struggling again: Shouldn't the code below give me the last element under <= tbody>? Right now \xmlfilter{#1}{/tr/last()/command(xml:table:tbody:tr)} give= s me nothing... >=20 > (Use case is that I want to have a frame above the table and one bar below.= So I think I should wrap the last line in the \startxtablefoot ...\stopxtabl= efoot, i.e., I need one command for the last element, and one for the rest (O= r is there a better way?). What would be the everything but the last? >=20 > What am I missing? You need to read some more on the "Expressions and filters=E2=80=9D chapter o= f the xml manual, as it does not work quite the way you think. Here is a quic= k fix: >=20 >=20 > \startxmlsetups xml:table:tbody > \xmlfilter{#1}{/tr/last()/command(xml:table:tbody:tr)} \xmlfilter{#1}{/tr[position()=3D=3Dlast()]/command(xml:table:tbody:tr)} Best wishes, Taco --===============7916578918831007356==-- From denis.maier.lists@mailbox.org Tue Sep 22 10:23:56 2020 From: Denis Maier To: ntg-context@ntg.nl Subject: Re: [NTG-context] How to get the last item from an XML node Date: Tue, 22 Sep 2020 10:23:50 +0200 Message-ID: <5ed32ae3-6895-f250-c43d-d0b3f1e98210@mailbox.org> In-Reply-To: <87FBC62F-57F8-4E9F-9B39-E5D1EAD13314@elvenkind.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0040919048849577759==" --===============0040919048849577759== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Am 22.09.2020 um 09:18 schrieb Taco Hoekwater: >=20 >=20 >> On 21 Sep 2020, at 18:31, Denis Maier wr= ote: >> >> Hi >> >> struggling again: Shouldn't the code below give me the last element under = ? Right now \xmlfilter{#1}{/tr/last()/command(xml:table:tbody:tr)} giv= es me nothing... >> >> (Use case is that I want to have a frame above the table and one bar below= . So I think I should wrap the last line in the \startxtablefoot ...\stopxtab= lefoot, i.e., I need one command for the last element, and one for the rest (= Or is there a better way?). What would be the everything but the last? >> >> What am I missing? >=20 > You need to read some more on the "Expressions and filters=E2=80=9D chapter= of the xml manual, as it does not work quite the way you think. Here is a qu= ick fix: >=20 >> >> >> \startxmlsetups xml:table:tbody >> \xmlfilter{#1}{/tr/last()/command(xml:table:tbody:tr)} >=20 > \xmlfilter{#1}{/tr[position()=3D=3Dlast()]/command(xml:table:tbody:tr)} >=20 > Best wishes, > Taco Thanks! That works. I have to admit, it's not entirely clear to me. I adapted my pattern from the one given on page 78: /whocares/last() Obviously, it's not that easy. Best, Denis --===============0040919048849577759==--