ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Pablo Rodriguez <oinos@gmx.es>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: lpath to select last item
Date: Tue, 7 Jul 2020 22:46:56 +0200	[thread overview]
Message-ID: <84cb7217-44fb-63ed-d27b-8061257a0f4d@gmx.es> (raw)

Dear list,

I have the following sample:

  \startbuffer[demo]
    <document>
    <h2 id="heading">Heading</h2>
      <ul>
        <li>list</li>
      </ul>
    <h2 id="heading-1">Heading</h2>
      <ul>
        <li>list
        <ul>
           <li>list</li>
        </ul></li>
      </ul>
    <h2 id="heading-2">Heading</h2>
      <ul>
        <li>list
        <ul>
          <li>list
          <ul>
            <li>list</li>
          </ul></li>
        </ul></li>
      </ul>
    </document>
  \stopbuffer

  \startxmlsetups xml:demo:base
      \xmlsetsetup{#1}{document|h2|ul|li}{xml:*}
      %~ \xmlsetsetup{#1}{ul/li/!ul}{xml:last:item} % nothing changes
      %~ \xmlsetsetup{#1}{ul/li/!li}{xml:last:item} % blank item inserted
      %~ \xmlsetsetup{#1}{h2/**/ul/li}{xml:last:item} % nothing changes
      \xmlsetsetup{#1}{h2/***/ul/li/!ul}{xml:last:item} % shouldn’t be
this one?
  \stopxmlsetups

  \xmlregistersetup{xml:demo:base}

  \startxmlsetups xml:document
      \xmlflush{#1}
  \stopxmlsetups

  \startxmlsetups xml:h2
      \section{\xmlflush{#1}}
  \stopxmlsetups

  \startxmlsetups xml:ul
      \startitemize\xmlflush{#1}\stopitemize
  \stopxmlsetups

  \startxmlsetups xml:li
      \startitem\xmlflush{#1}\stopitem
  \stopxmlsetups

  \startxmlsetups xml:last:item
      \startitem\red\xmlflush{#1}\stopitem
  \stopxmlsetups

  \starttext
      \xmlprocessbuffer{main}{demo}{}
  \stoptext

I need to be able to select the last <li> (the one with no <ul> child)
in the <h2> element.

I thought that the lpath for that would be "h2/***/ul/li/!ul", but I
don’t know what I’m missing, since it doesn’t work at all.

Which would be the right lpath to select the last item in each list?

Many thanks for your help,

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-07 20:46 UTC|newest]

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

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=84cb7217-44fb-63ed-d27b-8061257a0f4d@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).