On 09/11/2012 08:18 PM, Hans Hagen wrote:
If the number of bib items is not that large hashing does not save much. (In x-xfdf.mkiv you can see another example). \starttext \startbuffer[demo] <document> <bibitem xml:id="hagen2011"> <author>Hans Hagen</author> <title>The Meaning of Life Is 42</title> <journal>The Rhetoric of Mathematics</journal> <date>2011</date> </bibitem> <bibitem xml:id="hagen2012"> <author>Hans Hagen</author> <title>The New Meaning is Now 43</title> <journal>High Energy Metaphysics</journal> <date>2012</date> </bibitem> <text> <p>This has been successfully proven in papers by <bib ref="#hagen2011"/> and <bib ref="#hagen2012"/>.</p> </text> </document> \stopbuffer \startxmlsetups xml:define \xmlsetsetup{#1}{*}{xml:*} \stopxmlsetups \startxmlsetups xml:document \xmlall{#1}{/text} \stopxmlsetups \startxmlsetups xml:text \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:p \xmlflush{#1} \par \stopxmlsetups \startxmlsetups xml:bib \BibAuthor{#1}{\xmlatt{#1}{ref}} \stopxmlsetups \startxmlsetups xml:author [[\xmlflush{#1}]] \stopxmlsetups \def\BibAuthor#1#2{[1:\xmlfirst{whatever}{/document/bibitem[@xml:id==string.sub('#2',2)]/author}]} \xmlregistersetup{xml:define} \xmlprocessbuffer{whatever}{demo}{} \startluacode userdata = userdata or { } userdata.bibitems = { } \stopluacode \startxmlsetups xml:document \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:bibitem \ctxlua{userdata.bibitems["\letterhash\xmlatt{#1}{xml:id}"] = "#1"} \stopxmlsetups \def\BibAuthor#1#2{[2:\xmlfirst{\cldcontext{userdata.bibitems['#2']}}{/author}]} \xmlprocessbuffer{whatever}{demo}{} \stoptext (I ran into a recently introduced side effect of an optimization so I'll generate you a new beta. Older versions should work anyway as no special trickery is used.) Hans
Ah, wonderful, Hans, I can play with this! Thanks a lot for the swift reply and for the help, this will get me going! All best Thomas ___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________