[NTG-context] More on XML and citations

Hans Hagen pragma at wxs.nl
Tue Apr 4 23:43:51 CEST 2006


Johannes Graumann wrote:
> Hello again,
>
> I have a matching rule for cite commands that look as follows:
> <cite id="hunt:86" opt="authoryear"/>
>
> The rule is this (kudoos to Taco):
> \defineXMLargument
>   [cite]
>   {\expanded{\cite[\XMLpar{cite}{opt}{}][\XMLpar{cite}{id}{}]}}
>   
- reset opt, otherwise the previous one will be used when no opt is given
- \XMLop (own parameter) saves a few bytes and can be used here

\defineXMLargument
  [cite]
  [opt=]
  {\expanded{\cite[\XMLop{opt}][\XMLop{id}]}}


> Sometimes I would like to have the '(Hunt et. al., 1986)' produced by above
> combination to look like '(see e.g. Hunt et. al., 1986)'. Taco pointed out
> in response to a question to list that I could do that by handing
> a 'left={(see e.g. }' to the cite command, however I fail to be able to do
> that. A XML node like this 
> <cite id="hunt:86" opt="authoryear,left={(see e.g.}"/>
> results on compilation with above rule in the following error:
>   

hm, the problem is that the { } are  no longer tex's braces (grouping)

\starttext

\defineXMLcommand
  [whatever]
  [test=unknown]
  {\XMLop{test}}

\startXMLdata
<whatever test="{\bf test}"/>
\stopXMLdata

\def\defXMLtex#1#2% the appended space will go away when
  {\begingroup    % \scantokens is fixed
   \disableXML
   \everyeof{\noexpand}% br's hack
   \edef\ascii{#2}%
   \edef\ascii{\scantokens\expandafter{\ascii}}% space appended
   \expandafter\endgroup\expandafter\def\expandafter#1\expandafter{\ascii}}
  
\defineXMLcommand
  [whatever]
  [test=unknown]
  {\defXMLtex\SomethingTex{\XMLop{test}}%
   \SomethingTex}

\startXMLdata
<whatever test="{\bf test}"/>
\stopXMLdata

\stoptext

so, then you can for instance feed \SomethingTex into the scite macros

however, best is not to mix tex this way with xml

Hans  

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------



More information about the ntg-context mailing list