[NTG-context] Error with XML and JS

Gilles Pérez-Lambert ntg-context@ntg.nl
Tue, 17 Feb 2004 00:56:55 +0100


This is a multi-part message in MIME format.

--Multipart_20040217005654927407
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello,

Continuing the ConTeXt exploration with Hans's help:

<http://www.mail-archive.com/ntg-context@ntg.nl/msg01784.html>

I'm trying to combine Hans's JS programming with XML processing but an error pops up:


%%%%%%%%%%%%%%%
javascript     : loading script set fld
(/Users/gpl/texmf/tex/context/base/java-fld.tex
! Missing \endcsname inserted.
<to be read again> 
                   \unhbox 
\leavevmode ->\unhbox 
                      \voidb@x 
\fakeunderscore ->\leavevmode 
                              \hbox {\setbox \scratchbox \hbox {(}\scratchdi...

\_...fmmode \mathunderscore \else \textunderscore 
                                                  \fi 
\XML:ent:tex-underscore ...tterunderscore \else \_
                                                  \fi 
\ascii ->Sanitized\getXMLentity {tex-underscore}
                                                TeX\getXMLentity {tex-unders...
...
l.115 \stopJSpreamble
%%%%%%%%%%%%%%%


with the attached TeX file. There's some kind of interaction between the two modes. Without \start(stop)XMLdata, it works.

Thanks for your time,

Gilles, preparing the next demo of ConTeXt in June (Paris). :-)


--Multipart_20040217005654927407
Content-Type: application/x-tex; x-unix-mode=0644; x-mac-creator=54655873;
 x-mac-type=54455854; name=xml-js.tex
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=xml-js.tex

\startJSpreamble {Notes} used now

  var lastNote =3D "" ;

  function Show_Note ( Name )
    { if (Name !=3D lastNote)
        { Hide_Note () ;
          var v =3D this.getField(Name) ; if (v)
            { console.println("Show Note: " + Name) ;
              v.display =3D display.visible ;
              v.readonly =3D false ;
              this.dirty =3D false ;
              lastNote =3D Name } } }

  function Hide_Note ( )
    { if (lastNote !=3D "")
        { var v =3D this.getField(lastNote) ; if (v)
            { console.println("Hide Note: " + lastNote) ;
              v.display =3D display.hidden ;
              v.readonly =3D true ;
              this.dirty =3D false } }
          lastNote =3D "" }

\stopJSpreamble

\newcounter\AnotherNote

\def\SomeNote#1#2%
  {\hbox
     {\doglobal\increment\AnotherNote
      \definesymbol[note:\AnotherNote:on][\WhatANote{#2}]%
      \setupfield[notes][offset=3Doverlay,frame=3Doff,option=3D{readonly,hi=
dden}]
    % this confuses acrobat, probably some interference bug, I spent too mu=
ch time on that
    % \setupfield[notes][offset=3Doverlay,frame=3Doff,option=3D{readonly,hi=
dden},clickin=3DJS(Hide_Note)]
      \definefield[note:\AnotherNote][check][notes][note:\AnotherNote:on][n=
ote:\AnotherNote:on]%
      \doifreferencefoundelse{note:\AnotherNote}
        {\setlayer[notes][page=3D\currentrealreference]{\fitfield[note:\Ano=
therNote]}}
        {\setlayer[notes]{\fitfield[note:\AnotherNote]}}%
      \pagereference[note:\AnotherNote]\goto{#1}[JS(Show_Note{note:\Another=
Note})]}}

\setupinteraction
  [state=3Dstart,
   openpageaction=3DJS(Hide_Note),
   closepageaction=3DJS(Hide_Note)]

\setupinteractionscreen
   [option=3Dmax]
  =20
\definereference[CloseNote][JS(Hide_Note)]

\setupfootertexts[{\goto{Fermer la note}[CloseNote]}][]
\setupcolors
  [state=3Dstart]

\definecolor
  [notebackgroundcolor]
  [s=3D.85]

\defineframedtext
  [WhatANote]
  [background=3Dcolor,
   backgroundcolor=3Dnotebackgroundcolor,
   width=3D.45\textwidth,
   height=3Dfit,
   align=3Dnormal,
   style=3D\ss,
   bodyfont=3D8pt]

\definelayer
  [notes]
  [width=3D\paperwidth,
   height=3D\paperheight,
   preset=3Drightbottom,
   offset=3D1cm]

\setupbackgrounds
  [page]
  [background=3Dnotes]


\defineXMLenvironment[note]
=09{}
=09{\SomeNote{(\XMLop{id})}{\getbuffer[\XMLop{id}]}}



\starttext
\startbuffer[3]
My note
\stopbuffer
\startXMLdata
Try <note id=3D'3' />
\stopXMLdata
\stoptext=20
--Multipart_20040217005654927407--