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
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 -----------------------------------------------------------------
participants (2)
-
Benjamin Buchmuller
-
Hans Hagen