ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Re: xmlpos values doubled
@ 2023-11-22  1:30 Benjamin Buchmuller
  2023-11-22  9:21 ` Hans Hagen
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Buchmuller @ 2023-11-22  1:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [NTG-context] Re: xmlpos values doubled
  2023-11-22  1:30 [NTG-context] Re: xmlpos values doubled Benjamin Buchmuller
@ 2023-11-22  9:21 ` Hans Hagen
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2023-11-22  9:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 11/22/2023 2:30 AM, Benjamin Buchmuller wrote:
> 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.)
normally elements are unique, and within n xml instance #1 itself is 
rather unique (but the same even over runs i.e. when it goes via the tuc 
file)

Hans

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-22  9:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-22  1:30 [NTG-context] Re: xmlpos values doubled Benjamin Buchmuller
2023-11-22  9:21 ` Hans Hagen

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).