summaryrefslogtreecommitdiff
path: root/tex/context/base/xtag-ini.tex
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2006-11-16 12:02:00 +0100
committerHans Hagen <pragma@wxs.nl>2006-11-16 12:02:00 +0100
commit2129e59b313d0a032b7b6eb3dab287dd32437ef9 (patch)
tree23b8818581484b897723bf6fb42a12a1b660afb6 /tex/context/base/xtag-ini.tex
parentf9c73d27ce69d59cfaeb543664e69c620642a0dc (diff)
downloadcontext-2129e59b313d0a032b7b6eb3dab287dd32437ef9.tar.gz
stable 2006.11.16 12:02
Diffstat (limited to 'tex/context/base/xtag-ini.tex')
-rw-r--r--tex/context/base/xtag-ini.tex427
1 files changed, 257 insertions, 170 deletions
diff --git a/tex/context/base/xtag-ini.tex b/tex/context/base/xtag-ini.tex
index 7579898fa..d7e01afd7 100644
--- a/tex/context/base/xtag-ini.tex
+++ b/tex/context/base/xtag-ini.tex
@@ -16,9 +16,7 @@
%D Beware: don't rely on \longempty things, since this may
%D change!
-%D To be sure:
-
-\newif\ifprocessingXML
+% \newif\ifprocessingXML
\beginTEX
\writestatus{XML}{sorry, XML is only supported in (pdf)etex}
@@ -26,15 +24,10 @@
\endinput
\endTEX
-% to be moved
-
-\ifx\globalscratchtoks \undefined \newtoks \globalscratchtoks \fi
-\ifx\globalscratchdimen\undefined \newdimen\globalscratchdimen \fi
-
% tzt nog eens child grabber maken; mooier in mathml
%D This module is highly optimized for speed, which sometimes
-%D reads to rather unreadable code. Sorry for this.
+%D leads to rather unreadable code. Sorry for this.
\beginETEX XML
@@ -205,6 +198,8 @@
\fi
+\let\normal@@XMLelement\@@XMLelement % we may overload this one later inside a group
+
\newtoks\XMLtoks
\newtoks\XMLresetlist
@@ -244,152 +239,237 @@
% part of this should move to a low level module
-\bgroup
-\catcode`\*=\@@comment
-\catcode`\.=\@@escape
-.catcode`.B=.@@begingroup
-.catcode`.E=.@@endgroup
-.catcode`.P=.@@parameter
-
-.catcode`.&=.@@active * .xdef.letterampersand B.string&E
-.catcode`.<=.@@active * .xdef.letterless B.string<E
- * .xdef.lettermore B.string>E
-.catcode`.#=.@@active * .xdef.letterhash B.string#E
-.catcode`.$=.@@active * .xdef.letterdollar B.string$E
-.catcode`.%=.@@active * .xdef.letterpercent B.string%E
-.catcode`.\=.@@active * .xdef.letterbackslash B.string\E
-.catcode`.^=.@@active * .xdef.letterhat B.string^E
-.catcode`._=.@@active * .xdef.letterunderscore B.string_E
-.catcode`.{=.@@active * .xdef.letterbgroup B.string{E
-.catcode`.}=.@@active * .xdef.letteregroup B.string}E
-.catcode`.|=.@@active * .xdef.letterbar B.string|E
-.catcode`.~=.@@active * .xdef.lettertilde B.string~E
-
-.gdef.enableXMLexpansion
- B.def<B.doXMLelementE.let&=.doXMLentityE
-
-.gdef.disableXMLexpansion
- B.unexpanded.def<B.doXMLelementE.let&=.doXMLentityE
-
-* internally the # becomes two #'s (before expanding, during
-* the parsing stage) which is why we let the first # gobble
-* the second one
-*
-* since this only takes place when reading arguments, as in
-* \startXMLdata ... cum, suis, we can take place of it
-* there; this is needed because reading from file goes wrong
-* (eating up argument)
-
-.unexpanded.gdef.enableXML
- B.catcode`.!=.@@other
- .catcode`.?=.@@other
- .catcode`.:=.@@other * active in french
- .catcode`.;=.@@other * active in french
- .catcode`.&=.@@active
- .catcode`.<=.@@active
- .catcode`.>=.@@other
- .catcode`."=.@@other
- .catcode`./=.@@other
- .catcode`.'=.@@other
- .catcode`.~=.@@other
- .catcode`.#=.@@other
- .let &=.doXMLentity
- .unexpanded.def<B.doXMLelementE*
- .ifcase.XMLtokensreduction
- .entitleXMLescapetokens
- .or
- .reduceXMLescapetokens
- .else
- .ignoreXMLescapetokens
- .fi
- .processingXMLtrue
- .the.everyenableXML
- E
-
-.gdef.activateXMLescapetokens
- B.catcode`.$=.@@active
- .catcode`.%=.@@active
- .catcode`.\=.@@active
- .catcode`.^=.@@active
- .catcode`._=.@@active
- .catcode`.{=.@@active
- .catcode`.}=.@@active
- .catcode`.|=.@@active
- E
-
-* .gdef.entitleXMLescapetokens
-* B.activateXMLescapetokens
-* .def#B&tex-hash;E*
-* .def$B&tex-dollar;E*
-* .def%B&tex-percent;E*
-* .def\B&tex-backslash;E*
-* .def^B&tex-hat;E*
-* .def_B&tex-underscore;E*
-* .def{B&tex-leftbrace;E*
-* .def}B&tex-rightbrace;E*
-* .def|B&tex-bar;E*
-* E
-
-.xdef.entitleXMLescapetokens
- B.noexpand.activateXMLescapetokens
- .noexpand.def.noexpand#B.noexpand&.string#035;E*
- .noexpand.def.noexpand$B.noexpand&.string#036;E*
- .noexpand.def.noexpand%B.noexpand&.string#037;E*
- .noexpand.def.noexpand\B.noexpand&.string#092;E*
- .noexpand.def.noexpand^B.noexpand&.string#094;E*
- .noexpand.def.noexpand_B.noexpand&.string#095;E*
- .noexpand.def.noexpand{B.noexpand&.string#123;E*
- .noexpand.def.noexpand}B.noexpand&.string#125;E*
- .noexpand.def.noexpand|B.noexpand&.string#124;E*
- E
-
-.gdef.reduceXMLescapetokens
- B.activateXMLescapetokens
- .def#B.string#E*
- .def$B.string$E*
- .def%B.string%E*
- .def\B.string\E*
- .def^B.string^E*
- .def_B.string_E*
- .def{B.string{E*
- .def}B.string}E*
- .def|B.string|E*
- E
-
-.gdef.ignoreXMLescapetokens
- B.catcode`.$=.@@other
- .catcode`.%=.@@other
- .catcode`.\=.@@other
- .catcode`.^=.@@other
- .catcode`._=.@@other
- .catcode`.{=.@@other
- .catcode`.}=.@@other
- .catcode`.|=.@@other
- E
-
-* The following macro can be invokes when reading from
-* an auxiliary file.
-
-.unexpanded.gdef.enableXMLelements
- B.catcode60=.@@active * .catcode`.<=.@@active
- .catcode62=.@@other * .catcode`.>=.@@other
- .unexpanded.def<B.doXMLelementE*
- .processingXMLtrue
- E
-
-.unexpanded.gdef.disableXMLelements
- B.catcode60=.@@active * .catcode`.<=.@@active
- .catcode62=.@@other * .catcode`.>=.@@other
- .let<.relax * new
- .processingXMLfalse
- E
-
-.global.let<.relax * new
-.global.let&.relax * new
-
-.egroup
-
-\def\disableXML{\setnormalcatcodes\processingXMLfalse}
+% we predefine some macros, just to satisfy the dep parser
+
+\let\enableXMLexpansion \relax
+\let\disableXMLexpansion \relax
+\let\enableXML \relax
+\let\activateXMLescapetokens\relax
+\let\entitleXMLescapetokens \relax
+\let\reduceXMLescapetokens \relax
+\let\ignoreXMLescapetokens \relax
+\let\enableXMLelements \relax
+\let\disableXMLelements \relax
+
+% \bgroup
+% \catcode`\*=\@@comment
+% \catcode`\.=\@@escape
+% .catcode`.B=.@@begingroup
+% .catcode`.E=.@@endgroup
+% .catcode`.P=.@@parameter
+%
+% .catcode`.&=.@@active
+% .catcode`.<=.@@active
+%
+% .catcode`.#=.@@active
+% .catcode`.$=.@@active
+% .catcode`.%=.@@active
+% .catcode`.\=.@@active
+% .catcode`.^=.@@active
+% .catcode`._=.@@active
+% .catcode`.{=.@@active
+% .catcode`.}=.@@active
+% .catcode`.|=.@@active
+% .catcode`.~=.@@active
+%
+% .gdef.enableXMLexpansion
+% B.def<B.doXMLelementE.let&=.doXMLentityE
+%
+% .gdef.disableXMLexpansion
+% B.unexpanded.def<B.doXMLelementE.let&=.doXMLentityE
+%
+% * internally the # becomes two #'s (before expanding, during
+% * the parsing stage) which is why we let the first # gobble
+% * the second one
+% *
+% * since this only takes place when reading arguments, as in
+% * \startXMLdata ... cum, suis, we can take place of it
+% * there; this is needed because reading from file goes wrong
+% * (eating up argument)
+%
+% .unexpanded.gdef.enableXML
+% B.catcode`.!=.@@other
+% .catcode`.?=.@@other
+% .catcode`.:=.@@other * active in french
+% .catcode`.;=.@@other * active in french
+% .catcode`.&=.@@active
+% .catcode`.<=.@@active
+% .catcode`.>=.@@other
+% .catcode`."=.@@other
+% .catcode`./=.@@other
+% .catcode`.'=.@@other
+% .catcode`.~=.@@other
+% .catcode`.#=.@@other
+% .let &=.doXMLentity
+% .unexpanded.def<B.doXMLelementE*
+% .ifcase.XMLtokensreduction
+% .entitleXMLescapetokens
+% .or
+% .reduceXMLescapetokens
+% .else
+% .ignoreXMLescapetokens
+% .fi
+% .processingXMLtrue
+% .the.everyenableXML
+% E
+%
+% .gdef.activateXMLescapetokens
+% B.catcode`.$=.@@active
+% .catcode`.%=.@@active
+% .catcode`.\=.@@active
+% .catcode`.^=.@@active
+% .catcode`._=.@@active
+% .catcode`.{=.@@active
+% .catcode`.}=.@@active
+% .catcode`.|=.@@active
+% E
+%
+% .xdef.entitleXMLescapetokens
+% B.noexpand.activateXMLescapetokens
+% .noexpand.def.noexpand#B.noexpand&.string#035;E*
+% .noexpand.def.noexpand$B.noexpand&.string#036;E*
+% .noexpand.def.noexpand%B.noexpand&.string#037;E*
+% .noexpand.def.noexpand\B.noexpand&.string#092;E*
+% .noexpand.def.noexpand^B.noexpand&.string#094;E*
+% .noexpand.def.noexpand_B.noexpand&.string#095;E*
+% .noexpand.def.noexpand{B.noexpand&.string#123;E*
+% .noexpand.def.noexpand}B.noexpand&.string#125;E*
+% .noexpand.def.noexpand|B.noexpand&.string#124;E*
+% E
+%
+% .gdef.reduceXMLescapetokens
+% B.activateXMLescapetokens
+% .def#B.string#E*
+% .def$B.string$E*
+% .def%B.string%E*
+% .def\B.string\E*
+% .def^B.string^E*
+% .def_B.string_E*
+% .def{B.string{E*
+% .def}B.string}E*
+% .def|B.string|E*
+% E
+%
+% .gdef.ignoreXMLescapetokens
+% B.catcode`.$=.@@other
+% .catcode`.%=.@@other
+% .catcode`.\=.@@other
+% .catcode`.^=.@@other
+% .catcode`._=.@@other
+% .catcode`.{=.@@other
+% .catcode`.}=.@@other
+% .catcode`.|=.@@other
+% E
+%
+% * The following macro can be invokes when reading from
+% * an auxiliary file.
+%
+% .unexpanded.gdef.enableXMLelements
+% B.catcode60=.@@active * .catcode`.<=.@@active
+% .catcode62=.@@other * .catcode`.>=.@@other
+% .unexpanded.def<B.doXMLelementE*
+% .processingXMLtrue
+% E
+%
+% .unexpanded.gdef.disableXMLelements
+% B.catcode60=.@@active * .catcode`.<=.@@active
+% .catcode62=.@@other * .catcode`.>=.@@other
+% .let<.relax * new
+% .processingXMLfalse
+% E
+%
+% .global.let<.relax * new
+% .global.let&.relax * new
+%
+% .egroup
+%
+% \def\disableXML
+% {\setnormalcatcodes\processingXMLfalse}
+
+\letcatcodecommand\xmlcatcodesn `\& \doXMLentity
+\letcatcodecommand\xmlcatcodesn `\< \doXMLelement
+\letcatcodecommand\xmlcatcodese `\& \doXMLentity
+\letcatcodecommand\xmlcatcodese `\< \doXMLelement
+\letcatcodecommand\xmlcatcodesr `\& \doXMLentity
+\letcatcodecommand\xmlcatcodesr `\< \doXMLelement
+
+\letcatcodecommand\xmlcatcodesr `\# \letterhash
+\letcatcodecommand\xmlcatcodesr `\$ \letterdollar
+\letcatcodecommand\xmlcatcodesr `\% \letterpercent
+\letcatcodecommand\xmlcatcodesr `\\ \letterbackslash
+\letcatcodecommand\xmlcatcodesr `\^ \letterhat
+\letcatcodecommand\xmlcatcodesr `\_ \letterunderscore
+\letcatcodecommand\xmlcatcodesr `\{ \letterleftbrace
+\letcatcodecommand\xmlcatcodesr `\} \letterrightbrace
+\letcatcodecommand\xmlcatcodesr `\| \letterbar
+
+\bgroup \catcode`\&=13
+
+\xdef\entityhash {&\string#035;}
+\xdef\entitydollar {&\string#036;}
+\xdef\entitypercent {&\string#037;}
+\xdef\entitybackslash {&\string#092;}
+\xdef\entityhat {&\string#094;}
+\xdef\entityunderscore{&\string#095;}
+\xdef\entityleftbrace {&\string#123;}
+\xdef\entityrightbrace{&\string#125;}
+\xdef\entitybar {&\string#124;}
+
+\egroup
+
+\letcatcodecommand\xmlcatcodese `\# \entityhash
+\letcatcodecommand\xmlcatcodese `\$ \entitydollar
+\letcatcodecommand\xmlcatcodese `\% \entitypercent
+\letcatcodecommand\xmlcatcodese `\\ \entitybackslash
+\letcatcodecommand\xmlcatcodese `\^ \entityhat
+\letcatcodecommand\xmlcatcodese `\_ \entityunderscore
+\letcatcodecommand\xmlcatcodese `\{ \entityleftbrace
+\letcatcodecommand\xmlcatcodese `\} \entityrightbrace
+\letcatcodecommand\xmlcatcodese `\| \entitybar
+
+% we speed things up by explicitly setting the active char's < &
+
+\bgroup \catcode`\<=13 \catcode`\&=13
+
+\gdef\enableXML
+ {\ifcase\XMLtokensreduction
+ \setcatcodetable\xmlcatcodese \or
+ \setcatcodetable\xmlcatcodesr \else
+ \setcatcodetable\xmlcatcodesn
+ \fi
+ \let&\doXMLentity
+ \unexpanded\def<{\doXMLelement}%
+ \processingXMLtrue
+ \the\everyenableXML}
+
+\gdef\disableXML
+ {\setcatcodetable\ctxcatcodes % maybe \texcatcodes
+ \processingXMLfalse}
+
+\gdef\enableXMLexpansion
+ {\def<{\doXMLelement}%
+ \let&\doXMLentity}
+
+\gdef\disableXMLexpansion
+ {\unexpanded\def<{\doXMLelement}%
+ \let&\doXMLentity}
+
+\unexpanded\gdef\enableXMLelements
+ {\catcode60=\@@active
+ \catcode62=\@@other
+ \unexpanded\def<{\doXMLelement}%
+ \processingXMLtrue}
+
+\unexpanded\gdef\disableXMLelements
+ {\catcode60=\@@active
+ \catcode62=\@@other
+ \let<\relax
+ \processingXMLfalse}
+
+\global\let<\relax
+\global\let&\relax
+
+\egroup
%D An element can be singular or paired. A singular element is
%D called an empty element. The following definitions are
@@ -1419,24 +1499,10 @@
% maybe some day global handling here as well
\fi}
-% \def\dosetXMLattributeC#1%
-% {\ifx\@@XMLspac\originalXMLnamespace
-% \@EA\def\csname\@@XMLvariable:\@@XMLclass:\@@XMLname\endcsname{#1}%
-% \else
-% \@EA\def\csname\@@XMLvariable:\@@XMLclass:\@@XMLspac:\@@XMLname\endcsname{#1}%
-% \fi}
-
\def\dosetXMLattributeC
{\@EA\def\csname\@@XMLvariable:\@@XMLclass\ifx\@@XMLspac
\originalXMLnamespace\else:\@@XMLspac\fi:\@@XMLname\endcsname}
-% \def\dosetXMLattributeD#1%
-% {\ifx\@@XMLspac\originalXMLnamespace
-% \@EA\def\csname\@@XMLvariable:\@@XMLclass:\currentXMLnamespace:\@@XMLname\endcsname{#1}%
-% \else
-% \@EA\def\csname\@@XMLvariable:\@@XMLclass:\@@XMLspac:\@@XMLname\endcsname{#1}%
-% \fi}
-
\def\dosetXMLattributeD
{\@EA\def\csname\@@XMLvariable:\@@XMLclass:\ifx\@@XMLspac
\originalXMLnamespace\currentXMLnamespace\else\@@XMLspac\fi:\@@XMLname\endcsname}
@@ -2009,7 +2075,7 @@
% \doifsomething{#3}{\long\setvalue{\@@XMLpars:#1}{\getrawparameters[#2][#3]}}}}
\long\def\setXMLarguments#1#2#3% element [tag] settings
- {\doifassignmentelse{#2}
+ {\doifassignmentelse{#2} % ROOM FOR OPTIMIZATION
{\letbeundefined{\@@XMLmap:#1}%
\long\setvalue{\@@XMLpars:#1}{\getrawparameters[\@@XMLvariable:#1:][#2]}}
{\long\setvalue{\@@XMLmap:#1}{#2}% later we can init vars by this name
@@ -2575,6 +2641,27 @@
\let\doifXMLparelse\doifXMLvarelse
\let\doifXMLpar \doifXMLvar
+%D Used in x-fo: I really need to document this!
+
+\bgroup \catcode`\<=\active
+
+% usage: \expanded{\rescanXMLatttributes{fo:table-cell}}
+
+\gdef\rescanXMLattributes #1{\noexpand\dogetXMLarguments{#1}\currentXMLarguments>}
+\gdef\parseXMLattributes #1#2{\dogetXMLarguments{#1}#2>}
+
+\egroup
+
+\def\defXMLattributestring#1#2#3#4%
+ {\ifcsname\@@XMLvariable:#2:#3\endcsname
+ \@EA\convertcommand\csname\@@XMLvariable:#2:#3\endcsname\to#1%
+ \else
+ \convertargument#4\to#1%
+ \fi}
+
+\def\XMLprocess#1%
+ {\begingroup\enableXML\XMLflush{#1}\endgroup}
+
\bgroup \catcode`<=\@@active
\long\gdef\ignoreuntilXMLelement#1<{<}