[NTG-context] How to get the last item from an XML node

Denis Maier denis.maier.lists at mailbox.org
Tue Sep 22 10:23:50 CEST 2020


Am 22.09.2020 um 09:18 schrieb Taco Hoekwater:
> 
> 
>> On 21 Sep 2020, at 18:31, Denis Maier <denis.maier.lists at mailbox.org> wrote:
>>
>> Hi
>>
>> 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)} 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?
> 
> You need to read some more on the "Expressions and filters” chapter of the xml manual, as it does not work quite the way you think. Here is a quick fix:
> 
>>
>>
>> \startxmlsetups xml:table:tbody
>>      \xmlfilter{#1}{/tr/last()/command(xml:table:tbody:tr)}
> 
> \xmlfilter{#1}{/tr[position()==last()]/command(xml:table:tbody:tr)}
> 
> 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



More information about the ntg-context mailing list