[NTG-context] lpath to select last item

Pablo Rodriguez oinos at gmx.es
Wed Jul 8 15:56:52 CEST 2020


On 7/8/20 11:59 AM, Hans Hagen wrote:
> On 7/7/2020 10:46 PM, Pablo Rodriguez wrote:
>> [...]
>> Which would be the right lpath to select the last item in each list?
> This should work but we're one off so i need to fix that.
>
> \startbuffer[demo]
> <document>
>    <ul>
>      <li>first</li>
>      <li>any</li>
>      <li>last</li>
>    </ul>
> </document>
> \stopbuffer
>
> \startxmlsetups xml:demo:base
>    \xmlsetsetup{#1}{document|ul|li}{xml:*}
>    \xmlsetsetup{#1}{ul/li[1]}{xml:item:first}
>    \xmlsetsetup{#1}{ul/li[-1]}{xml:item:last}
> \stopxmlsetups

Many thanks for your help, Hans.

This is like magic to me. But I’m afraid that my description was inaccurate.

I need to mark the last item from nested lists, but considering each
<h2> (such as in my sample), not the whole document.

Just in case it isn’t clear, this is the XML source with desired items
marked:

    <document>
    <h2 id="heading">Heading</h2>
      <ul>
        <li>list</li>                    ***this one***
      </ul>
    <h2 id="heading-1">Heading</h2>
      <ul>
        <li>list
        <ul>
           <li>list</li>                 ***this one***
        </ul></li>
      </ul>
    <h2 id="heading-2">Heading</h2>
      <ul>
        <li>list
        <ul>
          <li>list
          <ul>
            <li>list</li>               ***this one***
          </ul></li>
        </ul></li>
      </ul>
    </document>

I hope it is clear now that it is the last item in a nested list, but
for each <h2> element.

Many thanks for your help again,

Pablo
--
http://www.ousia.tk


More information about the ntg-context mailing list