ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen via ntg-context <ntg-context@ntg.nl>
To: ntg-context@ntg.nl, denis.maier@unibe.ch
Cc: Hans Hagen <j.hagen@freedom.nl>
Subject: [NTG-context] Re: xml: matches always child of other element
Date: Thu, 10 Aug 2023 20:20:54 +0200	[thread overview]
Message-ID: <8a32a0f7-3793-9848-ded2-5d8af497d5dc@freedom.nl> (raw)
In-Reply-To: <ZRAP278MB0495DF46ADB4405738BFEAE58301A@ZRAP278MB0495.CHEP278.PROD.OUTLOOK.COM>

Hi Denis,

> Ok, after a bit of more testing I can now come up with another example.
> 
> The version using startstop works, but with the normal command, I'm always getting back the content of the first element. I thought it might be an expansion issue, but \expanded and also expansion=yes or expansion=xml on \definedescription have no effect. Perhaps most interestingly, adding using the startstop variant together with the command variant gives correct results for the command as well (xml:index-entry-term-3).
> 
> I have now found a way to proceed with my project (I'll just use the startstop variant), but I'd still be interested in understanding what is happening here. Does anyone know? Or is there anything I'm doing wrong here?

This is kind of tricky but here is a variant test

\startxmlsetups xml:index-entry-term-1 % does not work
     \indexentry{1: \xmlflush{#1}}
%     test \par
     \indexentry{2: \xmlflush{#1}}
     3: \xmlflush{#1}
     \par
\stopxmlsetups

it has to do with the fact that when you don't use a start / stop the 
next paragraph is sees as description content so then you grab the same 
entry (sort of) nested

you can uncomment the "test \par" to see the side effects (twice one 
versus 1/2)

it's kind of hard to debug this, i admit,

Hans


> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> \startxmlsetups xml:test
>                \xmlsetsetup{#1}{*}{-}
>                \xmlsetsetup{#1}{index}{xml:*}
>                \xmlsetsetup{#1}{index-entry}{xml:index-entry}
>                %\xmlsetsetup{#1}{term}{xml:index-entry-term}
>                \xmlsetsetup{#1}{term}{xml:index-entry-term-2}
>                \xmlsetsetup{#1}{term}{xml:index-entry-term-3}
> \stopxmlsetups
> 
> \xmlregisterdocumentsetup{test}{xml:test}
> 
> % Index
> 
> \startxmlsetups xml:book-back
>                \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:index
>                \xmlflush{#1}
> \stopxmlsetups
> 
> \definedescription[indexentry][]
> %\definedescription[indexentry][expansion=yes] % has no effect
> %\definedescription[indexentry][expansion=xml] % has no effect
> 
> 
> \startxmlsetups xml:index-entry
>                \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:index-entry-term % does not work
>                \expanded{\indexentry{\xmlflush{#1}}}
>                \indexentry{\xmlflush{#1}}
>    \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:index-entry-term-2 % works
> \startindexentry{\xmlflush{#1}}
> \xmlflush{#1}
> \stopindexentry
> \stopxmlsetups
> 
> \startxmlsetups xml:index-entry-term-3 % works
> \expanded{\indexentry{\xmlflush{#1}}}
> \indexentry{\xmlflush{#1}}
> \startindexentry{\xmlflush{#1}}
> \xmlflush{#1}
> \stopindexentry
> \stopxmlsetups
> 
> 
> \startbuffer[test]
> <?xml version="1.0" encoding="UTF-8"?>
> <index>
> <index-entry>
> <term>One</term>
> </index-entry>
> <index-entry>
> <term>Two</term>
> </index-entry>
> <index-entry>
> <term>Three</term>
> </index-entry>
> </index>
> \stopbuffer
> 
> \starttext
> 
> \xmlprocessbuffer{test}{test}{}
> 
> \stoptext
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
> Von: denis.maier@unibe.ch <denis.maier@unibe.ch>
> Gesendet: Montag, 24. Juli 2023 15:57
> An: ntg-context@ntg.nl
> Betreff: [NTG-context] Re: xml: matches always child of other element
> 
> Interestingly, we should be in the right subtree as this modified example is supposed to demonstrate (we're getting the correct numbers under each index-entry-term, just the terms are incorrect in all but the first case):
> 
> \startxmlsetups xml:test
>                  \xmlsetsetup{#1}{*}{-}
>                  \xmlsetsetup{#1}{index}{xml:*}
>                  \xmlsetsetup{#1}{index-entry}{xml:index-entry}
>                  %\xmlsetsetup{#1}{index-entry}{xml:index-entry-2}
>                  \xmlsetsetup{#1}{term}{xml:index-entry-term}
>                  \xmlsetsetup{#1}{nav-pointer-group}{xml:*}
>                  \xmlsetsetup{#1}{nav-pointer}{xml:nav-pointer}
>                  \xmlsetsetup{#1}{nav-pointer/ext-link}{xml:nav-pointer-link}
> \stopxmlsetups
> 
> \xmlregisterdocumentsetup{test}{xml:test}
> 
> % Index
> 
> \startxmlsetups xml:book-back
>                  \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:index
>    \startsectionlevel[title={\xmlfilter{#1}{/index-title-group/title/command(xml:index-title)}},]
>                  \xmlflush{#1}
>    \stopsectionlevel
> \stopxmlsetups
> 
> \startxmlsetups xml:index-title
>                  \xmlflush{#1}
> \stopxmlsetups
> 
> \definedescription[indexentry]
>                  [alternative=top,
>                  headstyle=normal,
>      headcommand=\hskip-1cm,
>                  margin=1cm,
>                  inbetween=,
>                  ]
> 
> \startxmlsetups xml:index-entry
>                  \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:index-entry-2
>      \xmlfilter{#1}{/term/command(xml:index-entry-term)}%
>      \xmlverbatim{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:index-entry-term
>                  \indexentry{\xmlflush{#1}}
> \stopxmlsetups
> 
> \startxmlsetups xml:nav-pointer-group
>                  \xmlconcat{#1}{/nav-pointer}{, }
> \stopxmlsetups
> 
> \startxmlsetups xml:nav-pointer
>                  \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:nav-pointer-link
>                  \xmlflush{#1}
> \stopxmlsetups
> 
> \startbuffer[test]
> <?xml version="1.0" encoding="UTF-8"?>
> <index>
>        <index-title-group>
>          <title>Index</title>
>        </index-title-group>
>        <index-entry>
>          <term>First</term>
>          <nav-pointer-group>
>            <nav-pointer>
>              <ext-link>1</ext-link>
>            </nav-pointer>
>            <nav-pointer>
>              <ext-link>2</ext-link>
>            </nav-pointer>
>            <nav-pointer>
>              <ext-link>3</ext-link>
>            </nav-pointer>
>          </nav-pointer-group>
>        </index-entry>
>        <index-entry>
>          <term>Second</term>
>          <nav-pointer-group>
>            <nav-pointer>
>              <ext-link>4</ext-link>
>            </nav-pointer>
>          </nav-pointer-group>
>        </index-entry>
>        <index-entry>
>          <term>Third</term>
>          <nav-pointer-group>
>            <nav-pointer>
>              <ext-link>5</ext-link>
>            </nav-pointer>
>            <nav-pointer>
>              <ext-link>6</ext-link>
>            </nav-pointer>
>            <nav-pointer>
>              <ext-link>7</ext-link>
>            </nav-pointer>
>          </nav-pointer-group>
>        </index-entry>
> </index>
> \stopbuffer
> 
> 
> \starttext
> 
> \xmlprocessbuffer{test}{test}{}
> 
> \stoptext
> 
> Von: denis.maier@unibe.ch<mailto:denis.maier@unibe.ch> <denis.maier@unibe.ch<mailto:denis.maier@unibe.ch>>
> Gesendet: Montag, 24. Juli 2023 13:38
> An: ntg-context@ntg.nl<mailto:ntg-context@ntg.nl>
> Betreff: [NTG-context] xml: matches always child of other element
> 
> Hi,
> 
> I must be missing something obvious, but in this example the pattern for <term> always matches the first element, not the one under the current <index-entry>.
> Interestingly, using xml:index-entry-2 instead of the normal version matches correctly... Any hints what is going off the rails here?
> 
> Best,
> Denis
> 
> \startxmlsetups xml:test
>                  \xmlsetsetup{#1}{*}{-}
>                  \xmlsetsetup{#1}{index}{xml:*}
>                  \xmlsetsetup{#1}{index-entry}{xml:index-entry}
>                  %\xmlsetsetup{#1}{index-entry}{xml:index-entry-2}
>                  \xmlsetsetup{#1}{term}{xml:index-entry-term}
>                  \xmlsetsetup{#1}{nav-pointer-group}{xml:*}
>                  \xmlsetsetup{#1}{nav-pointer}{xml:nav-pointer}
>                  \xmlsetsetup{#1}{nav-pointer/ext-link}{xml:nav-pointer-link}
> \stopxmlsetups
> 
> \xmlregisterdocumentsetup{test}{xml:test}
> 
> % Index
> 
> \startxmlsetups xml:book-back
>                  \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:index
>    \startsectionlevel[title={\xmlfilter{#1}{/index-title-group/title/command(xml:index-title)}},]
>                  \xmlflush{#1}
>    \stopsectionlevel
> \stopxmlsetups
> 
> \startxmlsetups xml:index-title
>                  \xmlflush{#1}
> \stopxmlsetups
> 
> \definedescription[indexentry]
>                  [alternative=top,
>                  headstyle=normal,
>      headcommand=\hskip-1cm,
>                  margin=1cm,
>                  inbetween=,
>                  ]
> 
> \startxmlsetups xml:index-entry
>                  \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:index-entry-2
>      \xmlfilter{#1}{/term/command(xml:index-entry-term)}%
>      \xmlverbatim{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:index-entry-term
>                  \indexentry{\xmlflush{#1}}
> \stopxmlsetups
> 
> \startxmlsetups xml:nav-pointer-group
>                  \xmlconcat{#1}{/nav-pointer}{, }
> \stopxmlsetups
> 
> \startxmlsetups xml:nav-pointer
>                  \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:nav-pointer-link
>                  \xmlflush{#1}
> \stopxmlsetups
> 
> \startbuffer[test]
> <?xml version="1.0" encoding="UTF-8"?>
> <index>
>        <index-title-group>
>          <title>Index</title>
>        </index-title-group>
>        <index-entry>
>          <term>First</term>
>          <nav-pointer-group>
>            <nav-pointer>
>              <ext-link>1</ext-link>
>            </nav-pointer>
>            <nav-pointer>
>              <ext-link>2</ext-link>
>            </nav-pointer>
>            <nav-pointer>
>              <ext-link>3</ext-link>
>            </nav-pointer>
>          </nav-pointer-group>
>        </index-entry>
>        <index-entry>
>          <term>Second</term>
>          <nav-pointer-group>
>            <nav-pointer>
>              <ext-link>1</ext-link>
>            </nav-pointer>
>          </nav-pointer-group>
>        </index-entry>
>        <index-entry>
>          <term>Third</term>
>          <nav-pointer-group>
>            <nav-pointer>
>              <ext-link>1</ext-link>
>            </nav-pointer>
>          </nav-pointer-group>
>        </index-entry>
> </index>
> \stopbuffer
> 
> \starttext
> 
> \xmlprocessbuffer{test}{test}{}
> 
> \stoptext
> 
> 
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : https://contextgarden.net
> ___________________________________________________________________________________

-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

      reply	other threads:[~2023-08-10 18:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24 11:38 [NTG-context] " denis.maier
2023-07-24 13:56 ` [NTG-context] " denis.maier
2023-07-27 12:28   ` denis.maier
2023-08-10 18:20     ` Hans Hagen via ntg-context [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=8a32a0f7-3793-9848-ded2-5d8af497d5dc@freedom.nl \
    --to=ntg-context@ntg.nl \
    --cc=denis.maier@unibe.ch \
    --cc=j.hagen@freedom.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).