lxml-ini.mkiv /size: 18 Kb    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=lxml-ini,
3
%D version=2007.08.17,
4
%D title=\CONTEXT\ \XML\ Support,
5
%D subtitle=Initialization,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
%D Todo: auto apply setups (manage at lua end)
15
%D Todo: manuak: \xmlinclusion \xmlinclusions
16 17
\writestatus
{
loading
}
{
ConTeXt
XML
Support
/
Initialization
}
18 19
%registerctxluafile{lxml-tab}{} % loader
20
%registerctxluafile{lxml-lpt}{} % parser
21
%registerctxluafile{lxml-xml}{} % xml finalizers
22
%registerctxluafile{lxml-aux}{} % extras using parser
23
%registerctxluafile{lxml-mis}{} % extras independent of parser
24
\registerctxluafile
{
lxml
-
ent
}
{
}
% entity hacks
25
\registerctxluafile
{
lxml
-
tex
}
{
}
% tex finalizers
26
\registerctxluafile
{
lxml
-
dir
}
{
}
% ctx hacks
27
\registerctxluafile
{
lxml
-
ini
}
{
}
% interface
28 29
\unprotect
30 31
% todo: { } mandate so that we can alias
32 33
% undocumented:
34 35
\def
\ctxlxml
#
1
{
\ctxlua{
lxml
.
#
1
}
}
36 37
% for now indirect .. this will change when we have updated luatex (scan_argument)
38 39
\def
\xmlconcat
#
1
#
2
#
3
{
\clf_xmlconcat
{
#
1
}
{
#
2
}
{
\detokenize
{
#
3
}
}
}
40
\def
\xmlconcatrange
#
1
#
2
#
3
#
4
#
5
{
\clf_xmlconcatrange
{
#
1
}
{
#
2
}
{
#
3
}
{
#
4
}
{
\detokenize
{
#
5
}
}
}
41 42
%D Maybe I should add \type {\unexpanded} here:
43 44
\def
\xmlloadfile
#
1
#
2
{
\clf_xmlloadfile
{
#
1
}
{
#
2
}
{
\directxmlparameter
\c!compress
}
}
45
\def
\xmlloadbuffer
#
1
#
2
{
\clf_xmlloadbuffer
{
#
1
}
{
#
2
}
{
\directxmlparameter
\c!compress
}
}
46
\def
\xmlloaddata
#
1
#
2
{
\clf_xmlloaddata
{
#
1
}
{
#
2
}
{
\directxmlparameter
\c!compress
}
}
47 48
\let
\xmlload
\xmlloadfile
49 50
% aliased
51 52
%let\xmlall \clf_xmlall
53
%let\xmlatt \clf_xmlatt
54
%let\xmlattdef \clf_xmlattdef
55
%let\xmlattribute \clf_xmlattribute
56
%let\xmlattributedef \clf_xmlattributedef
57
%let\xmlbadinclusions \clf_xmlbadinclusions
58
%let\xmlchainatt \clf_xmlchainatt
59
%let\xmlchainattdef \clf_xmlchainattdef
60
%let\xmlchecknamespace \clf_xmlchecknamespace
61
%let\xmlcommand \clf_xmlcommand
62
%let\xmlcontext \clf_xmlcontext
63
%let\xmlcount \clf_xmlcount
64
%let\xmldelete \clf_xmldelete
65
%let\xmldirect \clf_xmldirect % in loops, not dt but root
66
%let\xmldirectives \clf_xmldirectives
67
%let\xmldirectivesafter \clf_xmldirectivesafter
68
%let\xmldirectivesbefore \clf_xmldirectivesbefore
69
%let\xmldisplayverbatim \clf_xmldisplayverbatim
70
%let\xmlelement \clf_xmlelement
71
%let\xmlfilter \clf_xmlfilter
72
%let\xmlfilterlist \clf_xmlfilterlist
73
%let\xmlfirst \clf_xmlfirst
74
%let\xmlflush \clf_xmlflush
75
%let\xmlflushcontext \clf_xmlflushcontext
76
%let\xmlflushlinewise \clf_xmlflushlinewise
77
%let\xmlflushpure \clf_xmlflushpure
78
%let\xmlflushspacewise \clf_xmlflushspacewise
79
%let\xmlflushtext \clf_xmlflushtext
80
%let\xmlfunction \clf_xmlfunction
81
%let\xmlinclude \clf_xmlinclude
82
%let\xmlincludeoptions \clf_xmlincludeoptions
83
%let\xmlinclusion \clf_xmlinclusion
84
%let\xmlinclusionbase \clf_xmlinclusionbase
85
%let\xmlinclusions \clf_xmlinclusions
86
%let\xmlindex \clf_xmlindex
87
%let\xmlinlineverbatim \clf_xmlinlineverbatim
88
%let\xmllast \clf_xmllast
89
%let\xmllastatt \clf_xmllastatt
90
%let\xmllastmatch \clf_xmllastmatch
91
%let\xmllastpar \clf_xmllastpar
92
%let\xmlloaddirectives \clf_xmlloaddirectives
93
%let\xmlmain \clf_xmlmain
94
%let\xmlmatch \clf_xmlmatch
95
%let\xmlname \clf_xmlname
96
%let\xmlnamespace \clf_xmlnamespace
97
%let\xmlnonspace \clf_xmlnonspace
98
%let\xmlpar \clf_xmlpar
99
%let\xmlparam \clf_xmlparam
100
%let\xmlpath \clf_xmlpath
101
%let\xmlpopmatch \clf_xmlpopmatch
102
%let\xmlpos \clf_xmlpos
103
%let\xmlpure \clf_xmlpure
104
%let\xmlpushmatch \clf_xmlpushmatch
105
%let\xmlraw \clf_xmlraw
106
%let\xmlrefatt \clf_xmlrefatt
107
%let\xmlregisterns \clf_xmlregisterns % document
108
%let\xmlremapname \clf_xmlremapname % element
109
%let\xmlremapnamespace \clf_xmlremapnamespace % document
110
%let\xmlsave \clf_xmlsave
111
%let\xmlsetatt \clf_xmlsetatt
112
%let\xmlsetattribute \clf_xmlsetattribute
113
%let\xmlsetpar \clf_xmlsetpar
114
%let\xmlsetparam \clf_xmlsetparam
115
%let\xmlsetsetup \clf_xmlsetsetup
116
%let\xmlsnippet \clf_xmlsnippet
117
%let\xmlstrip \clf_xmlstrip
118
%let\xmlstripanywhere \clf_xmlstripanywhere
119
%let\xmlstripnolines \clf_xmlstripnolines
120
%let\xmlstripped \clf_xmlstripped
121
%let\xmlstrippednolines \clf_xmlstrippednolines
122
%let\xmltag \clf_xmltag
123
%let\xmltext \clf_xmltext
124
%let\xmltobuffer \clf_xmltobuffer % id pattern name
125
%let\xmltobuffertextonly \clf_xmltobuffertextonly % id pattern name
126
%let\xmltobufferverbose \clf_xmltobufferverbose % id pattern name
127
%let\xmltofile \clf_xmltofile % id pattern filename
128
%let\xmltoparameters \clf_xmltoparameters
129
%let\xmlverbatim \clf_xmlverbatim
130 131
\let
\xmlposition
\xmlindex
132 133
\unexpanded
\def
\xmlinfo
#
1
{
\hbox
{
\ttxx
[
\xmlname
{
#
1
}
]
}
}
134
\unexpanded
\def
\xmlshow
#
1
{
\startpacked
\ttx
\xmlverbatim
{
#
1
}
\stoppacked
}
135 136
% the next one is handy for mode runs because it enforces a consistent
137
% #1 indexing (needed when using \xmltext{main:123}{...} like calls
138 139
%let\xmladdindex \clf_xmladdindex
140 141
% we need to pass the last argument as function, so
142 143
\unexpanded
\def
\xmlsetfunction
#
1
#
2
#
3
{
\ctxcommand{
xmlsetfunction
(
"
#1
"
,
\!!bs
#2
\!!es
,
#
3
)
}
}
144 145
% goodie:
146 147
\def
\xmltempbuffername
{
xml
-
temp
}
148 149
\unexpanded
\def
\prettyprintbuffer
#
1
#
2
% only used here
150
{
\ifdefined
\scitebuffer
151
\scitebuffer
[
#
2
]
[
#
1
]
%
152
\else
153
\typebuffer
[
#
1
]
[
\c!option
=
#
2
]
%
154
\fi
}
155 156
\unexpanded
\def
\xmlprettyprint
#
1
#
2
%
157
{
\xmltobufferverbose
{
#
1
}
{
.
}
{
\xmltempbuffername
}
%
158
\prettyprintbuffer
\xmltempbuffername
{
#
2
}
}
159 160
\unexpanded
\def
\xmlprettyprinttext
#
1
#
2
%
161
{
\xmltobuffertextonly
{
#
1
}
{
.
}
{
\xmltempbuffername
}
%
162
\prettyprintbuffer
\xmltempbuffername
{
#
2
}
}
163 164
\unexpanded
\def
\inlineprettyprintbuffer
#
1
#
2
% only used here
165
{
\ifdefined
\sciteinlinebuffer
166
\sciteinlinebuffer
[
#
2
]
[
#
1
]
%
167
\else
168
\typeinlinebuffer
[
#
1
]
[
\c!option
=
#
2
]
%
169
\fi
}
170 171
\unexpanded
\def
\xmlinlineprettyprint
#
1
#
2
%
172
{
\xmltobufferverbose
{
#
1
}
{
.
}
{
\xmltempbuffername
}
%
173
\inlineprettyprintbuffer
\xmltempbuffername
{
#
2
}
}
174 175
\unexpanded
\def
\xmlinlineprettyprinttext
#
1
#
2
%
176
{
\xmltobuffertextonly
{
#
1
}
{
.
}
{
\xmltempbuffername
}
%
177
\inlineprettyprintbuffer
\xmltempbuffername
{
#
2
}
}
178 179
% kind of special:
180 181
\let
\xmlstartraw
\clf_xmlstartraw
182
\let
\xmlstopraw
\clf_xmlstopraw
183 184
\let
\startxmlraw
\clf_xmlstartraw
185
\let
\stopxmlraw
\clf_xmlstopraw
186 187
% these are expandable! todo: \xmldoifelseattribute
188 189
%let\xmldoif \clf_xmldoif
190
%let\xmldoifnot \clf_xmldoifnot
191
%let\xmldoifelse \clf_xmldoifelse
192
%let\xmldoiftext \clf_xmldoiftext
193
%let\xmldoifnottext \clf_xmldoifnottext
194
%let\xmldoifelsetext \clf_xmldoifelsetext
195 196
%let\xmldoifatt \clf_xmldoifatt
197
%let\xmldoifnotatt \clf_xmldoifnotatt
198
%let\xmldoifelseatt \clf_xmldoifelseatt
199 200
%let\xmldoifempty \clf_xmldoifempty
201
%let\xmldoifnotempty \clf_xmldoifnotempty
202
%let\xmldoifelseempty \clf_xmldoifelseempty
203
%let\xmldoifselfempty \clf_xmldoifselfempty
204
%let\xmldoifnotselfempty \clf_xmldoifnotselfempty
205
%let\xmldoifelseselfempty \clf_xmldoifelseselfempty
206 207
\let
\xmldoiftextelse
\xmldoifelsetext
208
\let
\xmldoifemptyelse
\xmldoifelseempty
209
\let
\xmldoifselfemptyelse
\xmldoifelseselfempty
210 211
% \startxmlsetups xml:include
212
% \xmlinclude{main}{include}{filename|href}
213
% \stopxmlsetups
214
%
215
% \xmlprependsetup{xml:include}
216 217
% \let\xmlgrab\xmlsetsetup % obsolete
218
% \let\xmlself\s!unknown % obsolete
219 220
\let
\xmlsetup
\setupwithargumentswapped
221
\let
\xmls
\setupwithargumentswapped
% hardly any faster
222
\let
\xmlw
\setupwithargument
% hardly any faster
223 224
% todo: 1:xml:whatever always before 3:xml:something
225 226
\unexpanded
\def
\xmlprependsetup
#
1
{
\clf_xmlprependsetup
{
*
}
{
#
1
}
}
227
\unexpanded
\def
\xmlappendsetup
#
1
{
\clf_xmlappendsetup
{
*
}
{
#
1
}
}
228
\unexpanded
\def
\xmlbeforesetup
#
1
#
2
{
\clf_xmlbeforesetup
{
*
}
{
#
1
}
{
#
2
}
}
229
\unexpanded
\def
\xmlaftersetup
#
1
#
2
{
\clf_xmlaftersetup
{
*
}
{
#
1
}
{
#
2
}
}
230
\unexpanded
\def
\xmlremovesetup
#
1
{
\clf_xmlremovesetup
{
*
}
{
#
1
}
}
231
\unexpanded
\def
\xmlresetsetups
{
\clf_xmlresetsetups
{
*
}
}
232 233
\unexpanded
\def
\xmlprependdocumentsetup
#
1
#
2
{
\clf_xmlprependsetup
{
#
1
}
{
#
2
}
}
234
\unexpanded
\def
\xmlappenddocumentsetup
#
1
#
2
{
\clf_xmlappendsetup
{
#
1
}
{
#
2
}
}
235
\unexpanded
\def
\xmlbeforedocumentsetup
#
1
#
2
#
3
{
\clf_xmlbeforesetup
{
#
1
}
{
#
2
}
{
#
3
}
}
236
\unexpanded
\def
\xmlafterdocumentsetup
#
1
#
2
#
3
{
\clf_xmlaftersetup
{
#
1
}
{
#
2
}
{
#
3
}
}
237
\unexpanded
\def
\xmlremovedocumentsetup
#
1
#
2
{
\clf_xmlremovesetup
{
#
1
}
{
#
2
}
}
238
\unexpanded
\def
\xmlresetdocumentsetups
#
1
{
\clf_xmlresetsetups
{
#
1
}
}
239 240
\unexpanded
\def
\xmlflushsetups
#
1
{
\clf_xmlflushsetups
{
#
1
}
{
*
}
{
}
}
% #1 == id where to apply *
241
\unexpanded
\def
\xmlflushdocumentsetups
#
1
#
2
{
\clf_xmlflushsetups
{
#
1
}
{
*
}
{
#
2
}
}
% #1 == id where to apply * and #2
242 243
\let
\xmlregistersetup
\xmlappendsetup
244
\let
\xmlregisterdocumentsetup
\xmlappenddocumentsetup
245 246
\def
\xmldocument
{
main
}
247 248
\unexpanded
\def
\xmlregisteredsetups
249
{
\xmlstarttiming
250
\xmlflushsetups
\xmldocument
251
\xmldefaulttotext
\xmldocument
% after include
252
\xmlstoptiming
}
253 254
\unexpanded
\def
\xmlregistereddocumentsetups
#
1
#
2
% id setups
255
{
\xmlstarttiming
256
% todo: test for duplicates !
257
\xmlflushdocumentsetups
{
#
1
}
{
#
2
}
%
258
\xmldefaulttotext
{
#
1
}
% after include
259
\xmlstoptiming
}
260 261
\unexpanded
\def
\xmlstarttiming
{
\clf_xmlstarttiming
}
% undocumented
262
\unexpanded
\def
\xmlstoptiming
{
\clf_xmlstoptiming
}
% undocumented
263 264
\def
\lxml_process
#
1
#
2
#
3
#
4
#
5
% flag \loader id name what initializersetup
265
{
\begingroup
266
\edef
\xmldocument
{
#
3
}
% #2 can be \xmldocument and set as such
267
%xmlpushdocument{#3}%
268
#
2
{
#
3
}
{
#
4
}
%
269
\setcatcodetable
\notcatcodes
270
\doifelsenothing
{
#
5
}
%
271
{
\xmlsetup
{
#
3
}
{
xml
:
process
}
}
%
272
{
\xmlsetup
{
#
3
}
{
#
5
}
}
%
273
%xmlpopdocument
274
\endgroup
}
275 276
\unexpanded
\def
\xmlprocessfile
{
\lxml_process
\plusone
\xmlload
}
277
\unexpanded
\def
\xmlprocessdata
{
\lxml_process
\zerocount
\xmlloaddata
}
278
\unexpanded
\def
\xmlprocessbuffer
{
\lxml_process
\zerocount
\xmlloadbuffer
}
279
\let
\xmlprocess
\xmlprocessfile
280 281
\startxmlsetups
xml
:
flush
282
\xmlflush
{
#
1
}
283
\stopxmlsetups
284 285
\startxmlsetups
xml
:
process
286
\xmlregistereddocumentsetups
{
#
1
}
{
#
1
}
287
\xmlmain
{
#
1
}
288
\stopxmlsetups
289 290
\unexpanded
\def
\xmlloadonly
#
1
#
2
#
3
%
291
{
\xmlload
{
#
1
}
{
#
2
}
%
292
\xmlregistereddocumentsetups
{
#
1
}
{
#
3
}
}
293 294
% replaced by concat
295
%
296
% \unexpanded\def\xmlconnect#1#2#3% inefficient
297
% {\scratchcounter\xmlcount{#1}{#2}\relax
298
% \ifcase\scratchcounter \or
299
% \xmlall{#1}{#2}%
300
% \else
301
% \dorecurse \scratchcounter
302
% {\ifnum\recurselevel>\plusone#3\fi
303
% \xmlidx{#1}{#2}\recurselevel}%
304
% \fi}
305 306
\unexpanded
\def
\xmlcdataobeyedline
{
\obeyedline
}
307
\unexpanded
\def
\xmlcdataobeyedspace
{
\strut
\obeyedspace
}
308
\unexpanded
\def
\xmlcdatabefore
{
\begingroup
\tt
}
309
\unexpanded
\def
\xmlcdataafter
{
\endgroup
}
310 311
% verbatim (dodo:pre/post whitespace, maybe splot verbatim and
312
% cdata commands), experimental:
313
%
314
% \xmlsetfunction{main}{verbatim}{lxml.displayverbatim}
315
% \xmlsetfunction{main}{verb} {lxml.inlineverbatim}
316 317
% we use an xml: namespace so one has to define a suitable verbatim, say
318
%
319
% \definetyping[xml:verbatim][typing]
320
%
321
% this is experimental!
322 323
\unexpanded
\def
\startxmldisplayverbatim
324
{
\dosingleempty
\lxml_start_display_verbatim
}
325 326
\let
\stopxmldisplayverbatim
\relax
327 328
\def
\lxml_start_display_verbatim
[
#
1
]
%
329
{
\startpacked
330
\edef
\currenttyping
{
#
1
}
%
331
\ifx
\currenttyping
\empty
332
\let
\currenttyping
\v!typing
333
\else
% maybe test for existence
334
\edef
\currenttyping
{
xml
:
\currenttyping
}
%
335
\fi
336
\unexpanded
\def
\stopxmldisplayverbatim
337
{
\endofverbatimlines
338
\stoppacked
}
%
339
\doinitializeverbatim
340
\beginofverbatimlines
}
341 342
\unexpanded
\def
\startxmlinlineverbatim
343
{
\dosingleempty
\lxml_start_inline_verbatim
}
344 345
\let
\stopxmlinlineverbatim
\relax
346 347
\unexpanded
\def
\lxml_start_inline_verbatim
[
#
1
]
%
348
{
\begingroup
349
\edef
\currenttype
{
#
1
}
%
350
\ifx
\currenttype
\empty
351
\let
\currenttype
\v!type
352
\else
% maybe test for existence
353
\edef
\currenttype
{
xml
:
\currenttype
}
%
354
\fi
355
\let
\stopxmlinlineverbatim
\endgroup
356
\doinitializeverbatim
}
357 358
% processing instructions
359 360
\unexpanded
\def
\xmlinstalldirective
#
1
#
2
%
361
{
\clf_xmlinstalldirective
{
#
1
}
{
\csstring
#
2
}
}
362 363
% an example:
364 365
% <?context-tex-directive bgroup ?>
366 367
\appendtoks
368
\xmlinstalldirective
{
tex
}
{
xmltexcommand
}
%
369
\to
\everyjob
370 371
\def
\xmltexcommand
#
1
{
\begincsname
#
1
\endcsname
}
372 373
% \def\xmlcontextdirective#1% kind class key value
374
% {\executeifdefined{xml#1directive}\gobblethreearguments}
375 376
% setting up xml:
377
%
378
% \setupxml[\c!default=] % mkiv only == text
379
% \setupxml[\c!default=\v!none] % mkiv only, undefined -> hidden
380
% \setupxml[\c!default=\v!text] % mkiv only, undefined -> text
381 382
% \def\xmlctxdirective#1#2#3{\doif{#1}{clue}{\doif{#2}{page}}{\page[#3]}}
383 384
\newconstant
\xmlprocessingmode
% 0=unset, 1=text, 2=hidden
385 386
\installcorenamespace
{
xml
}
387
\installcorenamespace
{
xmldefaults
}
388
\installcorenamespace
{
xmlmapvalue
}
389 390
\installdirectcommandhandler
\??xml
{
xml
}
391 392
\letvalue
{
\??xmldefaults
\v!normal
}
\zerocount
393
\letvalue
{
\??xmldefaults
\v!none
}
\zerocount
394
\letvalue
{
\??xmldefaults
\v!text
}
\plusone
395
\letvalue
{
\??xmldefaults
\v!hidden
}
\plustwo
396 397
\unexpanded
\def
\xmldefaulttotext
398
{
\ifcase
\xmlprocessingmode
399
\expandafter
\gobbleoneargument
% 0 (none)
400
\or
401
\expandafter
\clf_xmlsetcommandtotext
% 1 (normal)
402
\or
403
\expandafter
\clf_xmlsetcommandtonone
% 2 (hidden)
404
\else
405
\expandafter
\gobbleoneargument
% (none)
406
\fi
}
407 408
\appendtoks
409
\xmlprocessingmode
\executeifdefined
{
\??xmldefaults
\directxmlparameter
\c!default
}
\plusone
410
\to
\everysetupxml
411 412
\setupxml
413
[
\c!default
=
,
% flush all
414
\c!compress
=
\v!no
,
% strip comment
415
\c!entities
=
\v!no
]
% load big entity file
416 417
\appendtoks
418
\doif
{
\directxmlparameter
\c!entities
}
\v!yes
\clf_xmlloadentities
419
\to
\everysetupxml
420 421
\def
\xmlmapvalue
#
1
#
2
#
3
{
\setvalue
{
\??xmlmapvalue
#
1
:
#
2
}
{
#
3
}
}
% keep #3 to grab spaces
422
\def
\xmldoifelsevalue
#
1
#
2
{
\ifcsname
\??xmlmapvalue
#
1
:
#
2
\endcsname
\expandafter
\firstoftwoarguments
\else
\expandafter
\secondoftwoarguments
\fi
}
423 424
\def
\xmlvalue
#
1
#
2
% #3
425
{
\ifcsname
\??xmlmapvalue
#
1
:
#
2
\endcsname
426
\expandafter
\expandafter
\expandafter
\lastnamedcs
\expandafter
\gobbleoneargument
427
\else
428
\expandafter
\firstofoneargument
429
\fi
}
430 431
\def
\xmlmappedvalue
#
1
#
2
#
3
%
432
{
\ifcsname
\??xmlmapvalue
#
1
:
#
2
\endcsname
433
\expandafter
\lastnamedcs
434
\else
435
\csname
\??xmlmapvalue
#
1
:
#
3
\expandafter
\endcsname
436
\fi
}
437 438
\let
\xmldoifvalueelse
\xmldoifelsevalue
439 440
\let
\xmlmapval
\xmlmapvalue
441
\let
\xmlval
\xmlvalue
442 443
%D Experimental:
444 445
\def
\xmlgetindex
#
1
{
\clf_xmlgetindex
{
\xmldocument
}
{
#
1
}
}
446
\def
\xmlwithindex
#
1
#
2
{
\clf_xmlwithindex
{
\xmldocument
}
{
#
1
}
{
#
2
}
}
447
\def
\xmlreference
#
1
#
2
{
\string
\xmlwithindex
{
#
1
}
{
#
2
}
}
448 449
%D Entities:
450
%D
451
%D \starttyping
452
%D \xmlsetentity{tex}{\TEX{}} % {} needed
453
%D \stoptyping
454 455
\unexpanded
\def
\xmlsetentity
#
1
#
2
{
\clf_xmlsetentity
{
#
1
}
{
\detokenize
{
#
2
}
}
}
456
\unexpanded
\def
\xmltexentity
#
1
#
2
{
\clf_xmltexentity
{
#
1
}
{
\detokenize
{
#
2
}
}
}
457 458
%D The following might change (or even disappear) so we keep it undocumented.
459 460
\setnewconstant
\xmlautoentities
\plusone
% 0=off, 1=upper, 2=upper,lower
461 462
\unexpanded
\def
\xmle
463
{
\ifcase
\xmlautoentities
464
\expandafter
\lxml_e_none
465
\or
466
\expandafter
\lxml_e_upper
467
\or
468
\expandafter
\lxml_e_upperlower
469
\else
470
\expandafter
\lxml_e_none
471
\fi
}
472 473
\def
\lxml_e_none
#
1
#
2
% safe
474
{
#
1
}
475 476
\def
\lxml_e_upper
#
1
#
2
% can be abbreviation
477
{
\ifcsname
#
2
\endcsname
478
\csname
#
2
\expandafter
\endcsname
479
\else
480
#
1
%
481
\fi
}
482 483
\def
\lxml_e_upperlower
#
1
#
2
% can be anything, so unsafe
484
{
\ifcsname
#
2
\endcsname
485
\csname
#
2
\expandafter
\endcsname
486
\else
\ifcsname
#
1
\endcsname
487
\csname
#
1
\expandafter
\expandafter
\expandafter
\endcsname
488
\else
489
#
1
%
490
\fi
\fi
}
491 492
% \def\lxml_e_upper#1#2% can be abbreviation
493
% {\ifcsname\detokenize{#2}\endcsname
494
% \lastnamedcs
495
% \else
496
% \detokenize{#1}%
497
% \fi}
498 499
% \def\lxml_e_upperlower#1#2% can be anything, so unsafe
500
% {\ifcsname\detokenize{#2}\endcsname
501
% \expandafter\lastnamedcs
502
% \else\ifcsname\detokenize{#1}\endcsname
503
% \doubleexpandafter\lastnamedcs
504
% \else
505
% \detokenize{#1}%
506
% \fi\fi}
507 508
%D We keep these around as there are also MP, LUA and TEX variants but
509
%D they are not the same as in \MKII.
510 511
\unexpanded
\def
\processXMLbuffer
512
{
\dosingleempty
\lxml_process_buffer
}
513 514
\def
\lxml_process_buffer
[
#
1
]
%
515
{
\xmlprocessbuffer
{
temp
}
{
#
1
}
{
}
}
516 517
\unexpanded
\def
\processXMLfile
#
1
%
518
{
\xmlprocessfile
{
temp
}
{
#
1
}
{
}
}
519 520
\unexpanded
\def
\XMLdata
#
1
%
521
{
\xmlprocessdata
{
temp
}
{
#
1
}
{
}
}
522 523
\let
\processxmlbuffer
\processXMLbuffer
524
\let
\processxmlfile
\processXMLfile
525
\let
\xmldata
\XMLdata
526 527
\unexpanded
\def
\xmlsetinjectors
[
#
1
]
%
528
{
\clf_xmlsetinjectors
{
#
1
}
}
529 530
\unexpanded
\def
\xmlresetinjectors
531
{
\clf_xmlresetinjectors
{
}
}
532 533
% \def\xmlinjector#1{\executeifdefined{#1}\donothing}
534 535
\def
\xmlinjector
#
1
{
\fastsetup
{
xml
:
directive
:
injector
:
#
1
}
}
536 537
\startsetups
xml
:
directive
:
injector
:
page
538
\page
539
\stopsetups
540 541
\startsetups
xml
:
directive
:
injector
:
column
542
\column
543
\stopsetups
544 545
\startsetups
xml
:
directive
:
injector
:
blank
546
\blank
547
\stopsetups
548 549
\startsetups
xml
:
directive
:
injector
:
noline
550
\vskip
-
\lineheight
551
\stopsetups
552 553
\let
\xmlapplyselectors
\clf_xmlapplyselectors
554 555
% \let\xmlcatcodes\notcatcodes
556 557
\protect
\endinput
558 559
% \newcount\charactersactiveoffset \charactersactiveoffset="10000
560
%
561
% \startextendcatcodetable\ctxcatcodes
562
% \catcode\numexpr\charactersactiveoffset+`<\relax=13
563
% \catcode\numexpr\charactersactiveoffset+`&\relax=13
564
% \catcode\numexpr\charactersactiveoffset+`>\relax=13
565
% \stopextendcatcodetable
566
%
567
% \startextendcatcodetable\xmlcatcodes % not needed
568
% \catcode\numexpr\charactersactiveoffset+`<\relax=13
569
% \catcode\numexpr\charactersactiveoffset+`&\relax=13
570
% \catcode\numexpr\charactersactiveoffset+`>\relax=13
571
% \stopextendcatcodetable
572
%
573
% \ctxlua { % entities are remembered in the format
574
% commands.remapentity("<",characters.activeoffset + utf.byte("<"))
575
% commands.remapentity("&",characters.activeoffset + utf.byte("&"))
576
% commands.remapentity(">",characters.activeoffset + utf.byte(">"))
577
% }
578