ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Benjamin Buchmuller <benjamin.buchmuller@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: [NTG-context] Re: xmlpos values doubled
Date: Tue, 21 Nov 2023 20:30:43 -0500	[thread overview]
Message-ID: <8CFD1B9D-27E6-4D80-80C8-B9C6DBDEA954@gmail.com> (raw)

Hi list,

I came across this old thread as I was trying to use \xmlpos{#1} to "dynamically" create references such as \item[mystep:\xmlpos{#1}] to be referenced when other elements of this node are parsed at a later point. 

In fact, it seems that \xmlpos{#1} returns duplicate values. This might indeed be the intended meaning of \xmlpos{#1} as it seems related to the XML query foo/bar/index() which only looks up the position in the parent node. (I noticed that if I run this repeatedly, I get somehow different values from times to times. I can't say why.)

Anyways, I was wondering if there is a TeX command to access the absolute position of an element in the tree? Similar to foo/bar[rootposition()] (or foo/bar[order()]? – Can't make sense of the entry in the XML manual.)

Thank you for your help!


Benjamin


> Hi Ben,
> 
> I think that both \xmlpos and \xmldepth give weird results.
> 
> With this minimal sample:
> 
> \startbuffer[text]
> <doc>first level
> <s>second level
> <ss>third level</ss>
> <ss>third level</ss>
> </s>
> <s>second level
> <ss>third level</ss>
> <ss>third level</ss>
> </s>
> <s>second level
> <ss>third level</ss>
> <ss>third level</ss>
> </s>
> </doc>
> \stopbuffer
> 
> \startxmlsetups xml:text
> \xmlsetsetup{#1}{doc|s|ss}{xml:*}
> \stopxmlsetups
> 
> \xmlregistersetup{xml:text}
> 
> \startxmlsetups xml:doc
> \chapter{\xmlpos{#1}\letterat\xmldepth{#1}: \xmlflush{#1}}
> \stopxmlsetups
> 
> \startxmlsetups xml:s
> \section{\xmlpos{#1}\letterat\xmldepth{#1}: \xmlflush{#1}}
> \stopxmlsetups
> 
> \startxmlsetups xml:ss
> \subsection{\xmlpos{#1}\letterat\xmldepth{#1}: \xmlflush{#1}}
> \stopxmlsetups
> 
> \setuphead[chapter,section,subsection][before=,after=,]
> \starttext
> \xmlprocessbuffer{main}{text}{}
> \stoptext
> 
> \xmldepth shows values that I think are +1 than they should be.
> 
> \xmlpos counts in pairs and not in units (as you wrote, 2, 4, 6...).
> 
> Hans, could you check whether this is working as expected?
> 
> Sorry, but if this isn’t a bug, I have no idea of what I may be missing.
> 
> Pablo
> 
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

             reply	other threads:[~2023-11-22  1:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22  1:30 Benjamin Buchmuller [this message]
2023-11-22  9:21 ` Hans Hagen

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=8CFD1B9D-27E6-4D80-80C8-B9C6DBDEA954@gmail.com \
    --to=benjamin.buchmuller@gmail.com \
    --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).