ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Thomas A. Schmitz" <thomas.schmitz@uni-bonn.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Hans Hagen <pragma@wxs.nl>
Subject: Re: xml cross-references in lua?
Date: Wed, 12 Sep 2012 08:32:53 +0200	[thread overview]
Message-ID: <50502C95.3030606@uni-bonn.de> (raw)
In-Reply-To: <504F806B.4010108@wxs.nl>

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
___________________________________________________________________________________


      reply	other threads:[~2012-09-12  6:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-11 17:22 Thomas A. Schmitz
2012-09-11 18:18 ` Hans Hagen
2012-09-12  6:32   ` Thomas A. Schmitz [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=50502C95.3030606@uni-bonn.de \
    --to=thomas.schmitz@uni-bonn.de \
    --cc=ntg-context@ntg.nl \
    --cc=pragma@wxs.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).