summaryrefslogtreecommitdiff
path: root/tex/context/base/x-xtag.mkiv
blob: 09490cc8ff422b879d5bb397d9eff010641dbf2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
%D \module
%D   [       file=x-xtag,
%D        version=2009.09.23,
%D          title=\CONTEXT\ Modules,
%D       subtitle=\XML\ stream handler,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D Here we load the \MKII\ (mostly) streaming \XML\ parser. We
%D define a couple of catcode regimes first.

\ifdefined\XMLbanner \endinput \fi

\writestatus{xtag}{this module is obsolete, use the mkiv-xml features or use mkii instead}

%D Well, at this time (2011.12.28) I'm not sure if this code still works in
%D \MKIV. But in any case we move snippets here that are only needed for old
%D \MKII\ code.

\unprotect

\newif\ifforcefileexpansion % handy for document level overload

\def\installexpander#1#2#3% changed, no longer \convert..\to...
  {\setvalue{\s!do\c!expansion#1l}{#2}%
   \setvalue{\s!do\c!expansion#1g}{#3}}%

\def\doconvertexpanded#1#2#3% #4 % [l|g] \cs {kind} {data}
  {\csname   % that we assign all exp a value
     \s!do\c!expansion
     \ifforcefileexpansion
       \v!yes
     \else\ifcsname\s!do\c!expansion#3#1\endcsname
       #3%
     \else
       \s!default
     \fi\fi
     #1%
   \endcsname#2}% #3

\def\defconvertexpanded {\doconvertexpanded l}
\def\gdefconvertexpanded{\doconvertexpanded g}

\installexpander\v!command \defconvertedcommand  \gdefconvertedcommand
\installexpander\s!default \defconvertedargument \gdefconvertedargument
\installexpander\empty     \defconvertedargument \gdefconvertedargument
\installexpander\v!no      \defconvertedargument \gdefconvertedargument
\installexpander\v!yes     \defconvertedmeaning  \gdefconvertedmeaning
\installexpander\v!yes     \defconvertedmeaning  \gdefconvertedmeaning
\installexpander\v!strict  \defreducedargument   \gdefreducedargument
\installexpander {utf}     \defreducedtoutf      \gdefreducedtoutf

\def\dodefconvertedmeaning#1#2#3% watch the double expansion !
  {\bgroup
     \xdef\@@globalexpanded{#3}%
     \xdef\@@globalexpanded{\@@globalexpanded}%
   \egroup
   #1#2\@@globalexpanded}

\def\defconvertedmeaning {\dodefconvertedmeaning\defconvertedcommand}
\def\gdefconvertedmeaning{\dodefconvertedmeaning\gdefconvertedcommand}

\def\dodefreducedargument#1#2#3%
  {\begingroup
   \reducetocoding[raw]%
   \edef\ascii{#3}%
   \expandafter\endgroup\expandafter#1\expandafter#2\expandafter{\ascii}}

\def\defreducedargument {\dodefreducedargument\edef}
\def\gdefreducedargument{\dodefreducedargument\xdef}

\protect

%D The \XML\ modules.

\loadmarkfile{catc-xml}

\loadcorefile{xtag-ini.mkii}
\loadcorefile{xtag-ext.mkii}
\loadcorefile{xtag-exp.mkii}
\loadcorefile{xtag-pre.mkii} % has old encoding code
\loadcorefile{xtag-xsd.mkii} % will go away (stub anyway)
\loadcorefile{xtag-rng.mkii} % will go away (stub anyway)

\endinput