ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Pablo Rodriguez <oinos@gmx.es>
To: ntg-context@ntg.nl
Subject: Re: lpath to select last item
Date: Wed, 8 Jul 2020 15:56:52 +0200	[thread overview]
Message-ID: <1dc18f22-1cd1-58d7-907e-e2aba63b904d@gmx.es> (raw)
In-Reply-To: <9a6fd9de-3cba-5f61-1732-146032db6da3@xs4all.nl>

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
___________________________________________________________________________________
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
___________________________________________________________________________________

      reply	other threads:[~2020-07-08 13:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 20:46 Pablo Rodriguez
2020-07-08  9:59 ` Hans Hagen
2020-07-08 13:56   ` Pablo Rodriguez [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1dc18f22-1cd1-58d7-907e-e2aba63b904d@gmx.es \
    --to=oinos@gmx.es \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).