From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/78228 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: xml cross-references in lua? Date: Tue, 11 Sep 2012 20:18:19 +0200 Message-ID: <504F806B.4010108@wxs.nl> References: <504F7345.6050309@uni-bonn.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1347387516 32514 80.91.229.3 (11 Sep 2012 18:18:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Sep 2012 18:18:36 +0000 (UTC) Cc: "Thomas A. Schmitz" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Sep 11 20:18:39 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TBV2l-00008c-8G for gctc-ntg-context-518@m.gmane.org; Tue, 11 Sep 2012 20:18:39 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 5693A101F0; Tue, 11 Sep 2012 20:18:35 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id BCmRJxw+v4dB; Tue, 11 Sep 2012 20:18:33 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 29993101E9; Tue, 11 Sep 2012 20:18:33 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id A6F03101E9 for ; Tue, 11 Sep 2012 20:18:31 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ti7r7c2wwOaN for ; Tue, 11 Sep 2012 20:18:30 +0200 (CEST) Original-Received: from filter5-til.mf.surf.net (filter5-til.mf.surf.net [194.171.167.221]) by balder.ntg.nl (Postfix) with ESMTP id A77C1101E6 for ; Tue, 11 Sep 2012 20:18:30 +0200 (CEST) Original-Received: from smtp.ziggozakelijk.nl (D57D1DA2.static.ziggozakelijk.nl [213.125.29.162]) by filter5-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id q8BIGlxx008374 for ; Tue, 11 Sep 2012 20:16:47 +0200 X-Default-Received-SPF: pass (skip=loggedin (res=PASS)) x-ip-name=10.100.1.100; Original-Received: from [10.100.1.100] (unverified [10.100.1.100]) by pragma-net.nl (SurgeMail 6.1c) with ESMTP (TLS) id 5895-1713362 for multiple; Tue, 11 Sep 2012 20:18:26 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120824 Thunderbird/15.0 In-Reply-To: <504F7345.6050309@uni-bonn.de> X-Authenticated-User: hagen@controller-9 X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=213.125.29.162; country=NL; region=16; city=Zeewolde; latitude=52.3302; longitude=5.5364; http://maps.google.com/maps?q=52.3302,5.5364&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0WHVSgLh8 - d50d22e091b5 - 20120911 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.221 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:78228 Archived-At: On 11-9-2012 19:22, Thomas A. Schmitz wrote: > Hi all, > > I have a question about xml processing and I think that what I want/need > can best be achieved by using lua code, but so far, I'm not really sure > how to proceed, so any help from one of the resident lua gurus would be > welcome. > > So: the question. xml allows to provide elements with unique identifiers > so that one can add cross-references within the document structure. Here > is a sample xml file that shows what I mean: > > > > Hans Hagen > The Meaning of Life Is 42 > The Rhetoric of Mathematics > 2011 > > > Hans Hagen > The New Meaning is Now 43 > High Energy Metaphysics > 2012 > > >

This has been successfully proven in papers by ref="#hagen2011"/> and .

>
>
> > [Note: the TEI guidelines add the hash character in the attribute value > to such references, but after much googling, I'm still not sure if this > is standard or necessary or bizarre.] > > So: at the point of the reference (which may be empty, like here, or > contain text), I want to refer back to the bibitems. The typesetting > engine should then be instructed to pick up the information, so that > this is, e.g., typeset as "This has been successfully proven in papers > by Hans Hagen (2011) and Hans Hagen (2012)." > > My idea: since the xml:id attributes must be unique across the document, > it would be easiest to collect them into a lua table, with the xml:id as > key, so their content could be accessed and typeset later. But > unfortunately, I have no clue how to go about this... Could somebody > provide a pointer? > > Thanks for your interest, if you've read this far! 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] Hans Hagen The Meaning of Life Is 42 The Rhetoric of Mathematics 2011 Hans Hagen The New Meaning is Now 43 High Energy Metaphysics 2012

This has been successfully proven in papers by and .

\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 ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | 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 / 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 ___________________________________________________________________________________