[xml/sgml-commit] r179 - in packages: . xmltex xmltex/branches xmltex/branches/upstream xmltex/branches/upstream/current

Graham Wilson graham at haydn.debian.org
Wed Sep 14 02:20:10 UTC 2005


Author: graham
Date: 2004-06-25 11:33:32 -0600 (Fri, 25 Jun 2004)
New Revision: 179

Added:
   packages/xmltex/
   packages/xmltex/branches/
   packages/xmltex/branches/upstream/
   packages/xmltex/branches/upstream/current/
   packages/xmltex/branches/upstream/current/englishutf16.xml
   packages/xmltex/branches/upstream/current/englishutf8.xml
   packages/xmltex/branches/upstream/current/iso-8859-1.xmt
   packages/xmltex/branches/upstream/current/iso-8859-2.xmt
   packages/xmltex/branches/upstream/current/koi8-r.xmt
   packages/xmltex/branches/upstream/current/langtest.tex
   packages/xmltex/branches/upstream/current/langtest.xml
   packages/xmltex/branches/upstream/current/langtest.xmt
   packages/xmltex/branches/upstream/current/manual.html
   packages/xmltex/branches/upstream/current/manual.tex
   packages/xmltex/branches/upstream/current/manual.xml
   packages/xmltex/branches/upstream/current/manual.xsl
   packages/xmltex/branches/upstream/current/mathml2.xmt
   packages/xmltex/branches/upstream/current/pdfxmltex.ini
   packages/xmltex/branches/upstream/current/portugeselatin1.xml
   packages/xmltex/branches/upstream/current/readme.txt
   packages/xmltex/branches/upstream/current/russiankoi8.xml
   packages/xmltex/branches/upstream/current/russianutf8.xml
   packages/xmltex/branches/upstream/current/sec.xmt
   packages/xmltex/branches/upstream/current/tei.xmt
   packages/xmltex/branches/upstream/current/testascii.cfg
   packages/xmltex/branches/upstream/current/testascii.tex
   packages/xmltex/branches/upstream/current/testascii.xml
   packages/xmltex/branches/upstream/current/testsec.tex
   packages/xmltex/branches/upstream/current/testsec.xml
   packages/xmltex/branches/upstream/current/utf-16.xmt
   packages/xmltex/branches/upstream/current/windows-1250.xmt
   packages/xmltex/branches/upstream/current/xmltex.cfg
   packages/xmltex/branches/upstream/current/xmltex.ini
   packages/xmltex/branches/upstream/current/xmltex.tex
   packages/xmltex/tags/
Log:
[svn-inject] Installing original source of xmltex

Added: packages/xmltex/branches/upstream/current/englishutf16.xml
===================================================================
(Binary files differ)


Property changes on: packages/xmltex/branches/upstream/current/englishutf16.xml
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: packages/xmltex/branches/upstream/current/englishutf8.xml
===================================================================
--- packages/xmltex/branches/upstream/current/englishutf8.xml	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/englishutf8.xml	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,6 @@
+<document att="english">
+ <section>
+  <head>Test</head>
+   Hello World!
+ </section>
+</document>

Added: packages/xmltex/branches/upstream/current/iso-8859-1.xmt
===================================================================
--- packages/xmltex/branches/upstream/current/iso-8859-1.xmt	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/iso-8859-1.xmt	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,29 @@
+
+
+  \count at 128\relax
+
+  \loop
+    \bgroup
+      \uccode`\~\count@
+      \uppercase{
+    \egroup
+         \xdef~{\noexpand\utfeightb\string^^c2\string~}
+      }
+  \ifnum\count@<191\relax
+     \advance\count@\@ne
+  \repeat
+
+  \count at 192\relax
+  \loop
+    \bgroup
+      \uccode`\~\count@
+      \advance\count at -64
+      \uccode`\!\count@
+      \uppercase{
+    \egroup
+         \xdef~{\noexpand\utfeightb\string^^c3\string!}
+      }
+  \ifnum\count@<255\relax
+     \advance\count@\@ne
+  \repeat
+

Added: packages/xmltex/branches/upstream/current/iso-8859-2.xmt
===================================================================
--- packages/xmltex/branches/upstream/current/iso-8859-2.xmt	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/iso-8859-2.xmt	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,96 @@
+\InputCharacter{xA0}{x00A0}
+\InputCharacter{xA1}{x0104}
+\InputCharacter{xA2}{x02D8}
+\InputCharacter{xA3}{x0141}
+\InputCharacter{xA4}{x00A4}
+\InputCharacter{xA5}{x013D}
+\InputCharacter{xA6}{x015A}
+\InputCharacter{xA7}{x00A7}
+\InputCharacter{xA8}{x00A8}
+\InputCharacter{xA9}{x0160}
+\InputCharacter{xAA}{x015E}
+\InputCharacter{xAB}{x0164}
+\InputCharacter{xAC}{x0179}
+\InputCharacter{xAD}{x00AD}
+\InputCharacter{xAE}{x017D}
+\InputCharacter{xAF}{x017B}
+\InputCharacter{xB0}{x00B0}
+\InputCharacter{xB1}{x0105}
+\InputCharacter{xB2}{x02DB}
+\InputCharacter{xB3}{x0142}
+\InputCharacter{xB4}{x00B4}
+\InputCharacter{xB5}{x013E}
+\InputCharacter{xB6}{x015B}
+\InputCharacter{xB7}{x02C7}
+\InputCharacter{xB8}{x00B8}
+\InputCharacter{xB9}{x0161}
+\InputCharacter{xBA}{x015F}
+\InputCharacter{xBB}{x0165}
+\InputCharacter{xBC}{x017A}
+\InputCharacter{xBD}{x02DD}
+\InputCharacter{xBE}{x017E}
+\InputCharacter{xBF}{x017C}
+\InputCharacter{xC0}{x0154}
+\InputCharacter{xC1}{x00C1}
+\InputCharacter{xC2}{x00C2}
+\InputCharacter{xC3}{x0102}
+\InputCharacter{xC4}{x00C4}
+\InputCharacter{xC5}{x0139}
+\InputCharacter{xC6}{x0106}
+\InputCharacter{xC7}{x00C7}
+\InputCharacter{xC8}{x010C}
+\InputCharacter{xC9}{x00C9}
+\InputCharacter{xCA}{x0118}
+\InputCharacter{xCB}{x00CB}
+\InputCharacter{xCC}{x011A}
+\InputCharacter{xCD}{x00CD}
+\InputCharacter{xCE}{x00CE}
+\InputCharacter{xCF}{x010E}
+\InputCharacter{xD0}{x0110}
+\InputCharacter{xD1}{x0143}
+\InputCharacter{xD2}{x0147}
+\InputCharacter{xD3}{x00D3}
+\InputCharacter{xD4}{x00D4}
+\InputCharacter{xD5}{x0150}
+\InputCharacter{xD6}{x00D6}
+\InputCharacter{xD7}{x00D7}
+\InputCharacter{xD8}{x0158}
+\InputCharacter{xD9}{x016E}
+\InputCharacter{xDA}{x00DA}
+\InputCharacter{xDB}{x0170}
+\InputCharacter{xDC}{x00DC}
+\InputCharacter{xDD}{x00DD}
+\InputCharacter{xDE}{x0162}
+\InputCharacter{xDF}{x00DF}
+\InputCharacter{xE0}{x0155}
+\InputCharacter{xE1}{x00E1}
+\InputCharacter{xE2}{x00E2}
+\InputCharacter{xE3}{x0103}
+\InputCharacter{xE4}{x00E4}
+\InputCharacter{xE5}{x013A}
+\InputCharacter{xE6}{x0107}
+\InputCharacter{xE7}{x00E7}
+\InputCharacter{xE8}{x010D}
+\InputCharacter{xE9}{x00E9}
+\InputCharacter{xEA}{x0119}
+\InputCharacter{xEB}{x00EB}
+\InputCharacter{xEC}{x011B}
+\InputCharacter{xED}{x00ED}
+\InputCharacter{xEE}{x00EE}
+\InputCharacter{xEF}{x010F}
+\InputCharacter{xF0}{x0111}
+\InputCharacter{xF1}{x0144}
+\InputCharacter{xF2}{x0148}
+\InputCharacter{xF3}{x00F3}
+\InputCharacter{xF4}{x00F4}
+\InputCharacter{xF5}{x0151}
+\InputCharacter{xF6}{x00F6}
+\InputCharacter{xF7}{x00F7}
+\InputCharacter{xF8}{x0159}
+\InputCharacter{xF9}{x016F}
+\InputCharacter{xFA}{x00FA}
+\InputCharacter{xFB}{x0171}
+\InputCharacter{xFC}{x00FC}
+\InputCharacter{xFD}{x00FD}
+\InputCharacter{xFE}{x0163}
+\InputCharacter{xFF}{x02D9}

Added: packages/xmltex/branches/upstream/current/koi8-r.xmt
===================================================================
--- packages/xmltex/branches/upstream/current/koi8-r.xmt	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/koi8-r.xmt	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,131 @@
+\global\tracingmacros2
+\global\tracingcommands2
+
+\InputCharacter{x80}{x2500}
+\InputCharacter{x81}{x2502}
+\InputCharacter{x82}{x250C}
+\InputCharacter{x83}{x2510}
+\InputCharacter{x84}{x2514}
+\InputCharacter{x85}{x2518}
+\InputCharacter{x86}{x251C}
+\InputCharacter{x87}{x2524}
+\InputCharacter{x88}{x252C}
+\InputCharacter{x89}{x2534}
+\InputCharacter{x8A}{x253C}
+\InputCharacter{x8B}{x2580}
+\InputCharacter{x8C}{x2584}
+\InputCharacter{x8D}{x2588}
+\InputCharacter{x8E}{x258C}
+\InputCharacter{x8F}{x2590}
+\InputCharacter{x90}{x2591}
+\InputCharacter{x91}{x2592}
+\InputCharacter{x92}{x2593}
+\InputCharacter{x93}{x2320}
+\InputCharacter{x94}{x25A0}
+\InputCharacter{x95}{x2022}
+\InputCharacter{x96}{x221A}
+\InputCharacter{x97}{x2248}
+\InputCharacter{x98}{x2264}
+\InputCharacter{x99}{x2265}
+\InputCharacter{x9A}{x00A0}
+\InputCharacter{x9B}{x2321}
+\InputCharacter{x9C}{x00B0}
+\InputCharacter{x9D}{x00B2}
+\InputCharacter{x9E}{x00B7}
+\InputCharacter{x9F}{x00F7}
+\InputCharacter{xA0}{x2550}
+\InputCharacter{xA1}{x2551}
+\InputCharacter{xA2}{x2552}
+\InputCharacter{xA3}{x0451}
+\InputCharacter{xA4}{x2553}
+\InputCharacter{xA5}{x2554}
+\InputCharacter{xA6}{x2555}
+\InputCharacter{xA7}{x2556}
+\InputCharacter{xA8}{x2557}
+\InputCharacter{xA9}{x2558}
+\InputCharacter{xAA}{x2559}
+\InputCharacter{xAB}{x255A}
+\InputCharacter{xAC}{x255B}
+\InputCharacter{xAD}{x255C}
+\InputCharacter{xAE}{x255D}
+\InputCharacter{xAF}{x255E}
+\InputCharacter{xB0}{x255F}
+\InputCharacter{xB1}{x2560}
+\InputCharacter{xB2}{x2561}
+\InputCharacter{xB3}{x0401}
+\InputCharacter{xB4}{x2562}
+\InputCharacter{xB5}{x2563}
+\InputCharacter{xB6}{x2564}
+\InputCharacter{xB7}{x2565}
+\InputCharacter{xB8}{x2566}
+\InputCharacter{xB9}{x2567}
+\InputCharacter{xBA}{x2568}
+\InputCharacter{xBB}{x2569}
+\InputCharacter{xBC}{x256A}
+\InputCharacter{xBD}{x256B}
+\InputCharacter{xBE}{x256C}
+\InputCharacter{xBF}{x00A9}
+\InputCharacter{xC0}{x044E}
+\InputCharacter{xC1}{x0430}
+\InputCharacter{xC2}{x0431}
+\InputCharacter{xC3}{x0446}
+\InputCharacter{xC4}{x0434}
+\InputCharacter{xC5}{x0435}
+\InputCharacter{xC6}{x0444}
+\InputCharacter{xC7}{x0433}
+\InputCharacter{xC8}{x0445}
+\InputCharacter{xC9}{x0438}
+\InputCharacter{xCA}{x0439}
+\InputCharacter{xCB}{x043A}
+\InputCharacter{xCC}{x043B}
+\InputCharacter{xCD}{x043C}
+\InputCharacter{xCE}{x043D}
+\InputCharacter{xCF}{x043E}
+\InputCharacter{xD0}{x043F}
+\InputCharacter{xD1}{x044F}
+\InputCharacter{xD2}{x0440}
+\InputCharacter{xD3}{x0441}
+\InputCharacter{xD4}{x0442}
+\InputCharacter{xD5}{x0443}
+\InputCharacter{xD6}{x0436}
+\InputCharacter{xD7}{x0432}
+\InputCharacter{xD8}{x044C}
+\InputCharacter{xD9}{x044B}
+\InputCharacter{xDA}{x0437}
+\InputCharacter{xDB}{x0448}
+\InputCharacter{xDC}{x044D}
+\InputCharacter{xDD}{x0449}
+\InputCharacter{xDE}{x0447}
+\InputCharacter{xDF}{x044A}
+\InputCharacter{xE0}{x042E}
+\InputCharacter{xE1}{x0410}
+\InputCharacter{xE2}{x0411}
+\InputCharacter{xE3}{x0426}
+\InputCharacter{xE4}{x0414}
+\InputCharacter{xE5}{x0415}
+\InputCharacter{xE6}{x0424}
+\InputCharacter{xE7}{x0413}
+\InputCharacter{xE8}{x0425}
+\InputCharacter{xE9}{x0418}
+\InputCharacter{xEA}{x0419}
+\InputCharacter{xEB}{x041A}
+\InputCharacter{xEC}{x041B}
+\InputCharacter{xED}{x041C}
+\InputCharacter{xEE}{x041D}
+\InputCharacter{xEF}{x041E}
+\InputCharacter{xF0}{x041F}
+\InputCharacter{xF1}{x042F}
+\InputCharacter{xF2}{x0420}
+\InputCharacter{xF3}{x0421}
+\InputCharacter{xF4}{x0422}
+\InputCharacter{xF5}{x0423}
+\InputCharacter{xF6}{x0416}
+\InputCharacter{xF7}{x0412}
+\InputCharacter{xF8}{x042C}
+\InputCharacter{xF9}{x042B}
+\InputCharacter{xFA}{x0417}
+\InputCharacter{xFB}{x0428}
+\InputCharacter{xFC}{x042D}
+\InputCharacter{xFD}{x0429}
+\InputCharacter{xFE}{x0427}
+\InputCharacter{xFF}{x042A}

Added: packages/xmltex/branches/upstream/current/langtest.tex
===================================================================
--- packages/xmltex/branches/upstream/current/langtest.tex	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/langtest.tex	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,5 @@
+
+\def\xmlfile{langtest.xml}
+\input xmltex.tex
+
+

Added: packages/xmltex/branches/upstream/current/langtest.xml
===================================================================
--- packages/xmltex/branches/upstream/current/langtest.xml	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/langtest.xml	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,21 @@
+
+<!DOCTYPE langtest [
+
+<!ENTITY englishutf8 SYSTEM "englishutf8.xml">
+<!ENTITY portugeselatin1 SYSTEM "portugeselatin1.xml">
+<!ENTITY englishutf16 SYSTEM "englishutf16.xml">
+<!ENTITY russiankoi8 SYSTEM "russiankoi8.xml">
+<!ENTITY russianutf8 SYSTEM "russianutf8.xml">
+
+]>
+
+<langtest>
+
+&englishutf8;
+&englishutf16;
+&portugeselatin1;
+&russiankoi8;
+&russianutf8;
+
+
+</langtest>

Added: packages/xmltex/branches/upstream/current/langtest.xmt
===================================================================
--- packages/xmltex/branches/upstream/current/langtest.xmt	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/langtest.xmt	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,32 @@
+
+\XMLelement{langtest}
+{}
+  {\documentclass{article}
+    \usepackage[OT2,OT1]{fontenc}
+    \pagestyle{headings}
+   \begin{document}
+   \tableofcontents}
+  {\end{document}}
+
+
+\XMLelement{document}
+  {\XMLattribute{att}{\langatt}{}}{}{}
+
+\XMLelement{head}
+  {}{\xmlgrab}{\section{#1 (\langatt)}}
+
+
+\XMLelement{documento}
+  {\XMLattribute{att}{\langatt}{}}{}{}
+
+\XMLelement{cabeçalho}
+  {}{\xmlgrab}{\section{#1 (\langatt)}}
+
+
+\XMLelement{документ}
+  {\XMLattribute{атт}{\langatt}{}}{\fontencoding{OT2}\selectfont}{}
+
+\XMLelement{голова}
+  {}{\xmlgrab}{\section{\fontencoding{OT2}\selectfont#1 (\langatt)}}
+
+

Added: packages/xmltex/branches/upstream/current/manual.html
===================================================================
--- packages/xmltex/branches/upstream/current/manual.html	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/manual.html	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,882 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html xmlns:lxslt="http://xml.apache.org/xslt" xmlns:saxon="http://icl.com/saxon" xmlns:xalan="org.apache.xalan.xslt.extensions.Xalan">
+<head>
+<title>
+   xmltex: A non validating (and not 100%
+    conforming) namespace aware XML parser implemented in TeX
+  </title>
+<link rel="stylesheet" type="text/css" href="http://www.oucs.ox.ac.uk/stylesheets/tei-oucs.css">
+</head>
+<body>
+<table width="100%">
+<tr>
+<td rowspan="2"></td><td align="left">
+<h2>Numerical Algorithms Group: NAG</h2>
+</td>
+</tr>
+<tr>
+<td align="left">
+<h1>
+   xmltex: A non validating (and not 100%
+    conforming) namespace aware XML parser implemented in TeX
+  </h1>
+</td>
+</tr>
+</table>
+<hr>
+  <h2>
+   xmltex: A non validating (and not 100%
+    conforming) namespace aware XML parser implemented in TeX
+  </h2>
+  Date: 2000-02-02
+  <h2>
+<it>davidc at nag.co.uk</it>
+</h2>
+  <h2>
+<it>David Carlisle</it>
+</h2>
+<h2>Contents</h2>
+<p>
+<div class="subtoc">
+<ul>
+<li>
+<a class="subtoc" href="#intro">Introduction</a>
+</li>
+<li>
+<a class="subtoc" href="#manualN211">Installation</a>
+</li>
+<li>
+<a class="subtoc" href="#manualN343">Using xmltex</a>
+</li>
+<li>
+<a class="subtoc" href="#stopping">Stopping xmltex</a>
+</li>
+<li>
+<a class="subtoc" href="#manualN651">xmltex package files</a>
+</li>
+<li>
+<a class="subtoc" href="#manualN1004">XML processing</a>
+</li>
+<li>
+<a class="subtoc" href="#manualN1059">Accessing TeX</a>
+</li>
+<li>
+<a class="subtoc" href="#manualN1146">Bugs</a>
+</li>
+<li>
+<a class="subtoc" href="#manualN1161">Don't Read Past This Point</a>
+</li>
+</ul>
+</div>
+</p>
+<h2>
+<a name="intro"></a>Introduction</h2>
+
+<p>
+xmltex      implements
+a non     validating parser for documents matching the
+W3C XML Namespaces Recommendation.
+
+
+The system may just be used to parse the file (expanding entity
+references and normalising namespace declarations) in which case it
+records a trace of the parse on the terminal. Normally however the
+information from the parse is used to trigger TeX typesetting code.
+Declarations (in TeX syntax) are provided as part of xmltex to
+associate TeX code with the start and end of each XML element,
+attributes, processing instructions, and with unicode character data.
+</p>
+
+
+<h2>
+<a name="manualN211"></a>Installation</h2>
+
+<p>The xmltex parser itself does not require LaTeX. It may be loaded
+into initex to produce a format capable of parsing XML files. However
+such a format would have no convenient commands for typesetting, and
+so normally xmltex will be used on top of an existing format, normally
+LaTeX. In this section we assume that the document to be
+processed is called <tt>document.xml</tt>.
+</p>
+<h3>
+<a name="manualN228"></a>Using xmltex as an input to the LaTeX command</h3>
+
+<p>LaTeX requires a document in TeX syntax, not XML. To process
+<tt>document.xml</tt>, first produce a two line file called
+<tt>document.tex</tt> of the following form:
+<pre>
+\def\xmlfile{document.xml}
+\input xmltex.tex
+</pre>
+
+Do <em>not</em> put any other commands in this file!</p>
+<p>You may then process the document with either of the commands:
+<tt>latex document</tt>  or <tt>latex document.tex</tt>
+or the equivalent procedure in your TeX environment.
+</p>
+
+<h3>
+<a name="manualN267"></a>Using xmltex as a TeX format built on LaTeX</h3>
+
+<p>
+You may prefer to set up xmltex as a format in its own right.
+This may speed things up slightly (as <tt>xmltex.tex</tt> does not
+have to be read each time) but more importantly perhaps it allows the
+XML file to be processed directly without needing to make the
+<tt>.tex</tt> wrapper.</p>
+<p>To make a format you will need a command such as the following,
+depending on your TeX system.
+<pre>
+initex &amp;latex xmltex
+initex \&amp;latex xmltex
+tex -ini &amp;latex xmltex
+tex -ini \&amp;latex xmltex
+</pre>
+</p>
+<p>This will produce a format file <tt>xmltex.fmt</tt>. You should then
+be able to make a <tt>xmltex</tt> command by copying the way the
+<tt>latex</tt> command is defined in terms of
+<tt>latex.fmt</tt>. Depending on the TeX system, this might be a
+symbolic link, or a shell script, or batch file, or a configuration
+option in a setup menu.
+
+</p>
+
+<h3>
+<a name="manualN311"></a> Making an xmltex format `from scratch'</h3>
+
+<p>
+Whilst it may be convenient to build an xmltex format as above, starting
+from the LaTeX format. You may prefer to instead work with an initex
+with no existing format file. Even if you wish to use a standard LaTeX
+it may be preferable to make a TeX input file that first inputs 
+<tt>latex.ltx</tt> then <tt>xmltex.tex</tt>. In particular this
+will allow you to have a different hyphenation and language
+customisation for xmltex than for LaTeX. Many of the features of
+the language support in LaTeX are related to modifying the input
+syntax to be more convenient. Such changes are not needed in xmltex as
+the input syntax is always XML. Some language files may change the
+meaning of such characters as &lt; which would break the xmltex parser.
+Also, rather than using <tt>latex.ltx</tt> you could in principle
+use a modified <tt>docstrip</tt> install file and produce a
+`cut down' latex that did not have features that are not going to be
+used in xmltex.
+</p>
+<p>
+Unfortunately the support for this method of building xmltex (and access
+to non English hyphenation generally) is not fully designed and totally
+undocumented.</p>
+
+
+<h2>
+<a name="manualN343"></a>Using xmltex</h2>
+
+<p>
+xmltex by default `knows' nothing about any particular type of XML
+file, and so needs to load external files containing specific
+information. This section describes how the information in the XML
+file determines which files will be loaded.
+
+<ol>
+<li> If the file begins with a Byte Order Mark, the default encoding
+  is set to utf-16. Otherwise the default encoding is utf-8.
+</li>
+<li> If (after an optional BOM) the document begins with an XML
+  declaration that specifies an encoding, this encoding will be used,
+  otherwise the default encoding will be used. A file with name of the
+  form <em>encoding</em><tt>.xmt</tt> will be loaded that maps the
+  requested encoding to Unicode positions. (It is an error if this
+  file does not exist for the requested encoding.)
+</li>
+<li> If the document has a <tt>DOCTYPE</tt> declaration that includes
+  a local subset then this will be parsed. If any external DTD entity
+  is referenced (by declaring and then referencing a parameter entity)
+  then the SYSTEM and PUBLIC identifiers of this entity will be looked
+  up in a catalogue (to be described below). If either identifier is
+  known in the catalogue the corresponding xmltex package (often with
+  <tt>.xmt</tt> extension) will be loaded.
+</li>
+<li> After any local subset has been processed, if the DOCTYPE
+  specifies an external entity, the PUBLIC and/or SYSTEM identifiers
+  of the external dtd file will be similarly looked up, and a
+  corresponding xmltex file loaded if known.
+</li>
+<li> As each element is processed, it may be `known' to xmltex by
+  virtue of one of the packages loaded, or it may be unknown. If it is
+  unknown then if it is in a declared namespace, the namespace URI
+  (not the prefix) is looked up in the xmltex catalogue. If the
+  catalogue specifies an xmltex package for this namespace it will be
+  loaded. If the element is not in a namespace, then the element name
+  will be looked up in the catalogue.
+</li>
+<li> If after all these steps the element is still unknown then
+  depending on the configuration setting either a warning or an error
+  will be displayed. (Currently only warning implemented.)
+</li>
+</ol>
+</p>
+<h3>
+<a name="manualN398"></a>The xmltex Catalogue</h3>
+<p>As discussed above, xmltex requires a mapping between PUBLIC and
+SYSTEM identifiers, namespace URI, and element names, to files of
+TeX code. This mapping is implemented by the following commands:
+<pre>
+<tt>\NAMESPACE</tt>{<em>URI</em>}{<em>xmt-file</em>}
+<tt>\PUBLIC</tt>{<em>FPI</em>}{<em>file</em>}
+<tt>\SYSTEM</tt>{<em>URI</em>}{<em>file</em>}
+<tt>\NAME</tt>{<em>element-name</em>}{<em>xmt-file</em>}
+<tt>\XMLNS</tt>{<em>element-name</em>}{<em>URI</em>}
+</pre>
+As described above, if the first argument of one of these commands
+matches the string specified in the XML source file, the corresponding
+TeX commands in the file specified in the second argument are
+loaded. The PUBLIC and SYSTEM catalogue entries may also be used
+to control which XML files should be input in response to external
+entity references. The <tt>\XMLNS</tt> is rather different,
+if an element in the null namespace does not have any definition
+attatched to it, this declaration forces the default namespace to the
+given URI. The catalogue lookup is then repeated. This allows for
+example documents beginning <tt>&lt;html&gt;</tt> to be coerced into
+the xhtml namespace.</p>
+<p>These commands may be placed in a configuration file, either
+<tt>xmltex.cfg</tt>, in which case they apply to all documents,
+or in a configuration file `<tt>\jobname.cfg</tt>' (eg
+<tt>document.cfg</tt> in the example in the Introduction) in which
+case the commands just apply to the specified document.
+</p>
+
+
+<h3>
+<a name="manualN490"></a>Configuring xmltex</h3>
+
+<p>In addition to the `catalogue' commands described earlier there are
+other commands that may be placed in the configuration files.
+
+<ul>
+<li> <p>
+<tt>\xmltraceonly</tt>
+</p>
+<p>  This stops xml from trying to typeset the
+  document. The external files specified in the catalogue are still
+  loaded, so that the trace may report any elements for which no code
+  is defined, but no actual typesetting takes place. In the event of
+  unknown errors it is always worth using xmltex in this mode to
+  isolate any problems.</p>
+<p>It may be noted that if an xmltex format is built just using initex
+without any typesetting commands, the resulting format should still
+be able to parse any XML file if xmltex.cfg just specifies 
+<tt>\xmltraceonly</tt> and \jobname.cfg is empty.</p>
+</li>
+<li> <p>
+<tt>\xmltraceoff</tt>
+</p>
+<p>By default xmltex provides a trace of its XML parse, displaying
+   each element begin and end. This command used in xmltex.cfg or
+   `\jobname.cfg' will stop this trace being produced.</p>
+</li>
+
+<li>
+<p> <tt>\inputonce</tt>{<em>xmt-file</em>}</p>
+<p>The catalogue entries specify that
+  certain files should be loaded if XML constructs are met.
+  Alternatively the files may just always be loaded. The system will
+  ignore any later requests to load. This is especially useful if an
+  xmltex format is being made.</p>
+</li>
+<li>
+<p>
+<tt>\UnicodeCharacter</tt>{<em>hex-or-dec</em>}{<em>tex-code</em>}</p>
+<p>The first argument specifies a unicode character number, in the same
+format as used for XML character entities, namely either a decimal
+number, or an upper case Hex number preceded by a lower case
+`<tt>x</tt>'.</p>
+<p>The second argument specifies arbitrary TeX code to be used when
+typesetting this character. Any code in the XML
+range may be specified (ie up to x10FFFF). Although codes in the
+`ASCII' range, below 128, may be specified, the definitions supplied
+for such characters will not be default be used. The definition will
+howeverbe stored and used if the character is activated using the
+command described below.</p>
+</li>
+<li> <p>
+<tt>\ActivateASCII</tt>{<em>hex-or-dec</em>}</p>
+<p>The argument to this command should be a number less than 128.
+If a character us activated by this command in a configuration file
+then any special typesetting instructions specified for the character
+will be executed whenever the character appears as character data.</p>
+<p>Some ASCII characters are activated by default. The list is
+essentially those characters with special meanings to either TeX or
+XML.</p>
+</li>
+
+</ul>
+</p>
+<p>
+If a format is being made, there are essentially two copies of
+<tt>xmltex.cfg</tt> that may play a role. The configuration file
+input when the format is made will control catalogue entries and
+packages built into the format. A possibly different
+<tt>xmltex.cfg</tt> may be used in the input path of `normal' TeX,
+this will then be used for additional information loaded each run.</p>
+<p>In either case, a separate configuration file specific to the given
+XML document may also be used (which is loaded immediately after
+<tt>xmltex.cfg</tt>).
+</p>
+
+
+
+<h2>
+<a name="stopping"></a>Stopping xmltex</h2>
+
+<p>xmltex  should stop after the end of the document
+element has been processed. If things go wrong and
+you end up at the interactive
+<tt>*</tt> prompt  you might want to exit with
+<tt>&lt;?xmltex \stop?&gt;</tt>).
+</p>
+
+
+<h2>
+<a name="manualN651"></a>xmltex package files</h2>
+
+<p>
+xmltex package files are the link between the XML markup and TeX
+typesetting code. They are written in TeX (rather than XML) syntax
+and may load directly or indirectly other files, including LaTeX
+class and package files. For example a file loaded for a particular
+document type may directly execute <tt>\LoadClass{article}</tt>, or
+alternatively it may cause some XML element in the document to
+execute <tt>\documentclass{article}</tt>. In either case the document will
+suffer the dubious benefit of being formatted based on the style
+implemented in <tt>article.cls</tt>. Beware though that the package
+files may be loaded at strange times, the first time a given namespace
+is declared in a document, and so the code should be written to work
+if loaded inside a local group.</p>
+<p>Characters in xmltex package files have their normal LaTeX meanings
+except that line endings are ignored so that you do not need to add
+a % to the end of lines in macro code. Unlike fd file conventions, other
+white space is <em>not</em> ignored.</p>
+<p>The available commands are:
+
+<ul>
+<li>
+<p>
+<tt>\FileEncoding</tt>{<em>encoding</em>}</p>
+<p>This is the analogue for TeX syntax files of the encoding specification
+in the XML or text declaration of XML files. If it is not specified the
+file will be assumed to be in UTF-8.</p>
+</li>
+
+<li>
+<p>
+<tt>\DeclareNamespace</tt>{<em>prefix</em>}{<em>URI</em>}</p>
+<p>This declares a prefix to be used <em>in this file</em> for referring to
+elements in the specified namespace. If the prefix is empty then this
+declares the default namespace (otherwise, unprefixed element names
+refer to elements that are not in a namespace).</p>
+<p>Note that the elements in the XML document instance may use a
+different prefix, or no prefix at all to access this namespace.
+In order to resolve these different prefixes for the same namespace,
+each time a namespace is encountered for the first time (either 
+by <tt>\DeclareNamespace</tt> in a preloaded package, or in a namespace
+declaration in the XML instance) then it is allocated a new number
+and any further namespace declaration for the same URI just locally
+associates a prefix with this number. It is these numbers that are
+displayed when the XML trace of the parse of the document is shown,
+and also if any element is written out to an external file it will
+have a normalised prefix of a number whichever prefix it had
+originally. (Numeric prefixes are not legal XML, but this is an
+advantage, it ensures these internal forms can not clash with any
+prefix actually used in the document.)</p>
+<p>Three namespaces are predeclared. The null namespace (0), the XML
+namespace (<tt>http://www.w3.org/1998/xml</tt>) (1) which is predeclaed
+with prefix <tt>xml</tt> as specified in the Namespace Recommendation,
+and the xmltex namespace
+(<tt>http://www.dcarlisle.demon.co.uk/xmltex</tt>) (2) which is not
+given a default prefix, but may be used to have XML syntax for some
+internal commands (eg to have .aux files fully in XML, currently they
+are a hybrid mixture of some TeX and some XML syntax).
+</p>
+</li>
+<li>
+<p>
+  <tt>\XMLelement</tt>{<em>element-qname</em>}{<em>attribute-spec</em>}
+{<em>begin-code</em>}{<em>end-code</em>}</p>
+<p>  This is similar to a LaTeX <tt>\newenvironment</tt> command.</p>
+<p> Declare the code to execute at the start and end of each instance of
+this element type. This code will be executed in a local group (like a
+LaTeX environment). The second argument declares a list of attributes
+and their default values using the <tt>\XMLattribute</tt> command
+described below.
+</p>
+</li>
+<li>
+<p> 
+  <tt>\XMLelement</tt>{<em>element-qname</em>}
+{<em>attribute-spec</em>}
+<tt>{\xmlgrab}</tt>{<em>end-code</em>}</p>
+<p>  A special case of the above command (which may be better made into a
+  separate declaration) is to make the <em>start-code</em> just be the command
+  <tt>\xmlgrab</tt>. In this case the <em>end-code</em> has access to the
+  element content (in XML syntax) as <tt>#1</tt>. This content isn't
+  literally the same as the original document, namespaces, white space
+  and attribute quote symbols will all have been normalised.
+</p>
+</li>
+<li> <p>
+  <tt>\XMLattribute</tt>{<em>attribute-qname</em>}
+{<em>command-name</em>}{<em>default</em>}</p>
+<p>This command may only be used in the argument to
+<tt>\XMLelement</tt>.
+ The first argument specifies the name of an attribute (using any
+ namespace prefixes current for this package file, which need not
+ be the same as the prefixes used in the document).
+ The second argument gives a TeX command name that will be used to
+ access the value of this attribute in the begin and end code for the
+ element. (Note using TeX syntax here provides a name independednt of
+ the namespace declarations that are in scope when this code is executed).
+ The third argument provides a default value that wil be used if the
+attribute is not used on an instance of this element.
+ </p>
+<p>The special token <tt>\inherit</tt> may be used which will cause
+the command to have a value set in an ancestor element if this element
+does not specify any value.</p>
+<p>If a TeX token such as <tt>\relax</tt> is used as the default
+the element code may distinguish the case that the attribute is not used
+in the document.</p>
+</li>
+<li> <p>
+  <tt>\XMLnamespaceattribute</tt>
+{<em>prefix</em>}{<em>attribute-qname</em>}
+{<em>command-name</em>}{<em>default</em>}</p>
+<p>This command is similar to <tt>\XMLattribute</tt>
+ but is used at the top level of the package file, not in the argument
+to <tt>\XMLelement</tt>. It is equivalent to specifying the
+attribute in <em>every</em> element in the namespace specified by
+the first argument. As usual the prefix (which may be {} to denote the
+default namespace) refers to the namespace declarations in the xmltex
+package: the prefixes used in the document may be different.</p>
+</li>
+
+<li>
+<p>
+<tt>\XMLentity</tt>{<em>name</em>}{<em>code</em>}</p>
+<p>Declare an (internal parsed) entity, this is equivalent to a
+<tt>&lt;!ENTITY</tt> declaration, except that the
+replacement text is specified in TeX syntax.</p>
+</li>
+
+<li>
+<p>
+<tt>\XMLname</tt>{<em>name</em>}{<em>command-name</em>}</p>
+<p>Declare the TeX command to hold the (normalised, internal form) of
+the XML name given in the first argument. This allows the code specified in
+<tt>\XMLelement</tt> to refer to XML element names without knowing
+the encodings or namespace prefixes used in the document. Of particular
+use might be to compare such a name with <tt>\ifx\XML at parent</tt>
+which will allow element code to take different actions depending on
+the parent of the current element.</p>
+</li>
+
+
+<li>
+<p>
+<tt>\XMLstring</tt>{<em>command-name</em>}&lt;&gt;<em>XML Data</em>&lt;/&gt;</p>
+<p>This saves the XML fragment as the TeX command given in the first
+argument. It may be particularly useful for redefining `fixed strings'
+that are generated by LaTeX document classes to use any special
+typesetting rules specified for individual characters.</p>
+<p>It should also be used for defining any strings used to
+in comparison tests with strings occurring in the XML document.
+Using <tt>\XMLstring</tt> rather than <tt>\def</tt> ensures
+that the characters and encodings in the string are correctly normalised.</p>
+</li>
+
+
+</ul>
+
+</p>
+
+<h2>
+<a name="manualN1004"></a>XML processing</h2>
+
+<p>
+xmltex tries as far as possible to be a fully conforming non
+validating parser. It fails in the following respects.
+<ul>
+<li> Error reporting is virtually non existent. Names are not checked
+  against the list of allowed characters, and various other
+  constraints are not enforced.
+</li>
+<li>
+<p> A non validating parser is not forced to read external dtd
+  entities (and this one does not) It is obliged to read the local
+  subset and process entity definitions and attribute declarations.
+  Entity declarations are reasonably well handled: External parameter
+  entities are handled as above, loading a corresponding xmltex file
+  if known. External entities are similarly processed, inputting
+  the XML file, a difference in this case is that if the entity is not
+  found in the catalogue, the SYSTEM identifier will be used directly
+  to <tt>\input</tt> as often this is a local file reference. Internal
+  parsed entities and parameter entities are essentially treated as
+  TeX macros, and nonparsed entities are saved along with their
+  NDATA type, for use presumably by <tt>\includegraphics</tt>.</p>
+<p>Attribute defaults are processed in the local subset of the dtd, however
+   note that this is `namespace unaware' defaulting and only applies to
+   elements using the same prefix and local name, unlike the defaulting
+   done by <tt>\XMLattribute</tt>. </p>  
+</li>
+<li>
+<p> Support for encodings depends on having an encoding mapping
+  file. Any 8bit encoding that matches Unicode for the first 127 positions
+  may be used by making a trivial mapping file. (The one for latin1
+  looks over complicated as it programs a loop rather than having 127
+  declarations saying that latin1 and Unicode are identical in this
+  range).</p>
+<p>  UTF-8 is supported, but support for UTF-16 is minimal. Currently
+  only latin-1 values work: (In this range UTF-16 is just latin-1 with
+  a null byte inserted after (or before, depending on endedness)
+  each latin-1 byte. The UTF-16 implementation just ignores this null
+  byte then processes as for latin-1. Probably the first few 8bit
+  pages could be similarly supported by making the low ascii control
+  characters activate UTF-16 processing but this will never be
+  satisfactory using a standard TeX. Hopefully a setup for a 16bit
+  TeX such as Omega will correct this.</p>
+</li>
+</ul>
+
+</p>
+
+<h2>
+<a name="manualN1059"></a>Accessing TeX</h2>
+
+<p>In theory you should be able to control the document just be suitable
+code specified by <tt>\XMLelement</tt> and friends, but sometimes it may be
+necessary to `tweak' the output by placing commands directly in the
+source.</p>
+<p>Two mechanisms are availalable to do this.
+<ul>
+<li>
+<p> Using the xmltex namespace. The xmltex namespace conatins a
+  small (currently empty) set of useful TeX constructs that are
+  accessed by XML syntax. For example if xmltex provides a mechanism
+  for having XML (rather than LaTeX) syntax toc files, it will need
+  an analogue of <tt>\contentsline</tt> which might be an element
+  accessed by <tt>&lt;xmltex:contentsline&gt;</tt>&hellip; where the xmltex
+  prefix is declared on this or a parent element to be
+ <tt>xmlns:xmltex="http://www.dcarlisle.demon.co.uk/xmltex"</tt>.</p>
+<p>  As the xmltex namespace is declared but currently empty, a more
+  useful variant of this might be:</p>
+</li>
+<li> Declare your own namespace for TeX tweaks, and load a suitable
+  package file that attatches TeX code to the elements in this
+  namespace (or at least specify the correspondence between the
+  namespace and the package using <tt>\NAMESPACE</tt>).
+  For instance if you put <tt>&lt;clearpage xmlns="/my/tex/tweak"/&gt;</tt>
+  in your document, this will force a page break if you have at
+  suitable points, <tt>\NAMESPACE{/my/tex/tweak}{tweak.xmt}</tt>
+  and
+<pre>
+\DeclareNamespace{tweak}{"/my/tex/tweak"}
+\XMLelement{tweak:clearpage}{\clearpage}
+</pre>
+</li>
+<li>
+<p> A second different mechanism is available, to use XML processing
+  instructions. A Processing Instruction of the form:
+<tt>&lt;?xmltex&gt;</tt>  <em>TeX commands</em> <tt>?&gt;</tt>
+will execute the TeX commands.</p>
+</li>
+</ul>
+
+</p>
+
+
+<h2>
+<a name="manualN1146"></a>Bugs</h2>
+
+<p>None, of course.</p>
+
+
+<h2>
+<a name="manualN1161"></a>Don't Read Past This Point</h2>
+
+<p>Thus section discusses some of the more experimental features of xmltex
+that may get a cleaner syntax (or be removed, as a bad idea) in later releases,
+and also describes some of the internal interfaces (which are also
+subject to change)</p>
+
+<h3>
+<a name="manualN1175"></a>Input Encodings and States</h3>
+
+<p>At any point while processing a document, xmltex is in one of two 
+<em>states</em>: <em>tex</em> or <em>xml</em>.</p>
+<h4>
+<a name="manualN1201"></a>States</h4>
+<p>In the xml <em>state</em>,
+ &lt; and &amp; are the only two characters that
+trigger special markup codes. Other characters, such as !, &gt;, =,
+&hellip; may be used in certain XML constructs as markup but unless
+some code has been triggered by &lt; they are treated simply as
+character data. All characters above 127 are `active' to TeX
+and are used to translate the input encoding to UTF-8. All internal
+character handling is based on UTF-8, as described below. Some
+characters in the ASCII range, below 127 are also active by default
+(mainly punctuation characters used in XML constructs, such as
+the ones listed above). Some or all of the others may be activated
+using the <tt>\ActivateASCII</tt> command, which allows special
+typesetting rules to be activated for the characters, at some cost in
+processing speed.</p>
+<p>In the tex <em>state</em>,
+characters in the ASCII range have their usual
+TeX meanings, so letters are `catcode 11' and may be used in TeX
+control sequences, \ is the escape character, &amp; the table cell
+separator, etc. Characters above 127 have the meanings current for the
+current encoding just as for the xml state, probably this means that
+they are unusable in TeX code, except for the special case of
+referring to XML element names in the first argument to
+<tt>\XMLelement</tt> and releated commands.</p>
+
+<h4>
+<a name="manualN1233"></a>Encodings</h4>
+<p>Whenever a new (XML or TeX) file is input by the xmltex system the
+<em>encoding</em> is first switched to UTF-8. At the end of the
+input the encoding is returned to whatever was the current encoding.
+The encoding current while the file is read is determined by the
+encoding pseudo-attribute on the XML or text declaration in the case
+of XML files, or by the <tt>\FileEncoding</tt> command for TeX
+files. Note that the encoding mechanism <em>only</em> is triggered
+by xmltex file includes. Once an xmltex package file is loaded it may
+include other TeX files by <tt>\input</tt> or
+<tt>\includepackage</tt> these input command swill be transparent
+to the xmltex encoding system. The vast majority of TeX macro
+packages only use ASCII characters so this should not be a
+problem.</p>
+<p>Note that if the <tt>\includepackage</tt> occurs directly in
+the xmltex package file, the TeX code will be included with a known
+encoding, the one specified in the xmltex package, or UTF-8. If
+however the <tt>\includepackage</tt> is included in code specified
+by <tt>\XMLelement</tt>, then it will be executed with whatever
+encoding is current in the document at the point that element is
+reached. Before xmltex executes the code for that element it will
+switch to the tex state, thus normalising the ascii characters
+but characters above 127 will not have predefined definitions in this
+case.</p>
+<p>Internally eveything is stored as UTF-8. So `aux' and `toc' files
+will be in UTF-8 even if the document (or parts of the document) used
+different encodings.</p>
+<p>To specify a new encoding, if it is an 8 bit encoding that matches
+ASCII in the printable ASCII range, then one just needs to produce a
+file with name <em>encoding</em><tt>.xmt</tt> (in lowercase,
+on case sensitive systems) this should consist of a series of
+<tt>\InputCharacter</tt> commands, giving the input character slot
+and the equivalent Unicode. If an encoding is specified in this manner
+character data will be converted to UTF-8 by <em>expansion</em>
+and so ligatures and inter letter kerns will be preserved. (Conversely
+if characers are accessed by character references, &amp;#1234; then
+TeX arithmetic is used to decode the information and ligature
+information will be lost. For some large character sets, especially
+for Asian languages, these mechanisms will probably not prove to be
+sufficient, some mechanisms are being investigated, but in the short
+term it may be necessary to always use UTF-8 if the input encoding
+is not strictly a ine byte extension of the ASCII code page.
+</p>
+
+
+
+<h3>
+<a name="manualN1298"></a>xmltex Package Commands</h3>
+
+<p>You can use arbitrary TeX commands in an xmltex package,
+althought you should be aware that the file may be input into a local
+group, at the point in a document that a particular namespace is first
+used, for example. There are however some specific commands designed
+to be used in the begin or end code of <tt>\XMLElement</tt>.
+<ul>
+
+<li>
+<p>
+<tt>\ignorespaces</tt>
+</p>
+<p>This is actually a TeX primitive
+(for the moment!)</p>
+</li>
+
+<li>
+<p>
+<tt>\obeyspaces</tt>
+</p>
+<p>Obey consecutive space characters,
+rather than treating consecutive runs as a single space.
+(A command of this name, but not this definition is in plain TeX.)</p>
+</li>
+
+<li>
+<p>
+<tt>\obeylines</tt>
+</p>
+<p>Obey end of line characters,
+rather than treating then as a space, force a line break.
+(A command of this name, but not this definition is in plain TeX.)</p>
+</li>
+
+<li>
+<p>
+<tt>\xmltexfirstchild#1\@</tt>
+</p>
+<p>If the <em>start-code</em> for an element is specified as
+<tt>\xmlgrab</tt> then the  <em>end-code</em> may use
+<tt>#1</tt> in order to execute the element content. Sometimes you
+do not want all of the content. The a construction (with currently
+unpleasant syntax) <tt>\xmltexfirstchild#1\@</tt> will just evaluate
+the first child element of the content, discarding the remaining
+elements.</p>
+</li>
+
+<li>
+<p>
+<tt>\xmltextwochildren\csa\csb#1</tt>
+</p>
+<p>If you know that the content will be exactly two child elements (for
+examle a MathML frac or sub element) then this command may be used.
+It will execute the TeX code 
+<tt>\csa{</tt><em>child-1</em><tt>}\csb{</tt><em>child-2</em>
+So either two TeX command smay be supplied, one will be applied to
+each child, or the second argument may be <tt>{}</tt> in which case
+the first argument may be a TeX command that takes two arguments.
+For example the code for MathMl frac might be
+<pre>
+\XMLelement{m:mfrac}
+  {}
+  {\xmlgrab}
+  {\xmltextwochildren\frac{}#1}
+</pre>
+</p>
+</li>
+
+<li>
+<p>
+<tt>\xmltexthreechildren\csa\csb\csc#1</tt>
+</p>
+<p>As above, but more so.</p>
+</li>
+
+<li>
+<p>
+<tt>\xmltexforall\csa{#1}</tt>
+</p>
+<p>The TeX command <tt>\csa</tt> is called repeatedly,
+taking each child element of the current element as argument
+on each iteration. As a convenience the command <tt>\xml at name</tt>
+is defined before each iteration to have the (internal, normalised)
+name of the element being processed.</p>
+</li>
+
+<li>
+<p>
+<tt>\NDATAEntity\csa\csb\attvalue</tt>
+</p>
+<p>If the XML parser encounters an internalor external entity reference
+it expands it without executing any special hook that may be defined in
+an xmltex package. However NDATA entites are never directly encountered
+in an entity reference. They may only be used as an attribute value.
+If <tt>\attvalue</tt>. is a TeX command holding the value of an
+attribute, as declared in <tt>\XMLattribute</tt> then
+<tt>\NDATAEntity\csa\csb\attvalue</tt> applies the two TeX
+commands <tt>\csa</tt> and <tt>\csb</tt> to the notation type
+and the value, in a way exactly corresponding to
+<tt>\xmltextwochildren</tt> so for example the XML document for this
+manual specifies
+<pre>
+ &lt;!NOTATION URL SYSTEM "" &gt;
+ &lt;!ENTITY lppl SYSTEM "http://www.latex-project.org/lppl.txt" NDATA URL&gt;
+</pre>
+and this is handled by the following xmltex code
+<pre>
+\XMLelement{xptr}
+ {\XMLattribute{doc}{\xptrdoc}{}}
+ {\NDATAEntity\xptrdoc\@gobble\url}
+ {}
+</pre>
+which saves the attribute value in  <tt>\xptrdoc</tt> and then
+discards the notation name (URL) and applies the command
+<tt>\url</tt> to typeset the supplied URL.
+</p>
+</li>
+
+</ul>
+</p>
+
+
+
+<h3>
+<a name="manualN1489"></a>Character Data Internals</h3>
+
+<p>
+<div align="center">
+<table>
+<tr>
+<td></td> <td>int.</td><td>ext. xml</td>
+<td>ext. mixed</td><td>csn typeout</td>
+<td></td>
+</tr>
+<tr>
+<td>d</td><td>xabc</td><td>xabc</td>
+<td>xabc (12)</td><td>xabc (12)</td><td>xabc (12)</td>
+<td></td>
+</tr>
+<tr>
+<td>c</td><td>xab</td><td>xab</td>
+<td>xab  (12)</td><td>xab  (12)</td><td>xab  (12)</td>
+<td></td>
+</tr>
+<tr>
+<td>b</td><td>xa</td><td>xa</td>
+<td>xa   (12)</td><td>xa   (12)</td><td>xa   (12)</td>
+<td></td>
+</tr>
+<tr>
+<td>ax</td><td>x</td><td>x</td>
+<td>x</td><td>x</td><td>x    (12)</td>
+<td>(!)</td>
+</tr>
+<tr>
+<td>ay</td><td>x</td><td>x</td>
+<td>x</td><td>&amp;#123;</td><td>x    (12)</td>
+<td>(e)</td>
+</tr>
+<tr>
+<td>az</td><td>x</td><td>\az x</td>
+<td>&amp;#123;</td><td>&amp;#123;</td><td>x    (12)</td>
+<td>(&amp;lt;)</td>
+</tr>
+<tr>
+<td>&lt;</td><td>&lt;</td><td>&lt;</td>
+<td>&lt;</td><td>&lt;</td><td>&lt;    (12)</td>
+<td>(&lt;)</td>
+</tr>
+</table>
+</div>
+
+</p>
+
+
+
+
+
+
+<hr>
+<div align="center">
+[<a href="http://www.tei-c.org/">NAG</a>
+| <a href="http://www.nag.co.uk/">NAG</a>
+]
+ </div>
+<hr>
+<address>
+ Last updated: Date: 2000-02-02.
+ <br> Copyright 2000 David Carlisle, NAG
+
+<!--Created by a version 1
+ XSLT stylesheet by  James Clark--></address>
+</body>
+</html>

Added: packages/xmltex/branches/upstream/current/manual.tex
===================================================================
--- packages/xmltex/branches/upstream/current/manual.tex	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/manual.tex	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,4 @@
+\def\xmlfile{manual.xml}
+\input xmltex
+
+

Added: packages/xmltex/branches/upstream/current/manual.xml
===================================================================
--- packages/xmltex/branches/upstream/current/manual.xml	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/manual.xml	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,799 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE TEI.2 SYSTEM "http://www.oucs.ox.ac.uk/dtds/tei-oucs.dtd" [
+
+ <!NOTATION URL SYSTEM "" >
+ <!ENTITY lppl SYSTEM "http://www.latex-project.org/lppl.txt" NDATA URL>
+
+ <!ENTITY ldots "&#x2026;">
+
+ <!ENTITY TeX "TeX">
+ <!ENTITY LaTeX "LaTeX">
+
+]> 
+<TEI.2>
+  <teiHeader>
+    <fileDesc>
+      <titleStmt>
+        <title>xmltex</title>
+      </titleStmt>
+      <publicationStmt>
+        <availability>
+        <p>
+   This file is distributed under the LaTeX Project Public License
+   (LPPL) as found at <xptr doc="lppl"/>.
+   Either version 1.0, or at your option, any later version.
+      </p>
+      </availability>
+      </publicationStmt>
+      <sourceDesc>
+        <p></p>
+      </sourceDesc>
+    </fileDesc>
+    <profileDesc>
+    </profileDesc>
+    <revisionDesc>
+      <list>
+        <head></head>
+         <item><date>February 2nd 2000</date>
+               <name>David Carlisle</name>Updated)</item>
+         <item><date>January 24th 2000</date>
+               <name>David Carlisle</name>Updated)</item>
+         <item><date>January 19th 2000</date>
+               <name>David Carlisle</name>Updated)</item>
+         <item><date>January 18th 2000</date>
+               <name>David Carlisle</name>Updated)</item>
+         <item><date>January 15th 2000</date>
+               <name>David Carlisle</name>Updated)</item>
+         <item><date>January 10th 2000</date>
+               <name>Sebastian Rahtz</name>corrections</item>
+         <item><date>January 10th 2000</date>
+               <name>David Carlisle</name>Updated (in XML)</item>
+         <item><date>January 6th 2000</date>
+               <name>Sebastian Rahtz</name>Converted to TEI XML</item>
+         <item><date>January 6th 2000</date>
+               <name>David Carlisle</name>written in LaTeX</item>
+      </list>
+    </revisionDesc>
+  </teiHeader>
+  <text>
+<front>
+  <docTitle>
+   <titlePart type="main">xmltex: A non validating (and not 100%
+    conforming) namespace aware XML parser implemented in &TeX;</titlePart>
+  </docTitle>
+  <docDate>Date: 2000-02-02</docDate>
+  <docAuthor rend="email">davidc at nag.co.uk</docAuthor>
+  <docAuthor>David Carlisle</docAuthor>
+</front>
+<body>
+<div id="intro">
+<head>Introduction</head>
+<p>
+xmltex      implements
+a non     validating parser for documents matching the
+W3C XML Namespaces Recommendation.
+
+
+The system may just be used to parse the file (expanding entity
+references and normalising namespace declarations) in which case it
+records a trace of the parse on the terminal. Normally however the
+information from the parse is used to trigger &TeX; typesetting code.
+Declarations (in &TeX; syntax) are provided as part of xmltex to
+associate &TeX; code with the start and end of each XML element,
+attributes, processing instructions, and with unicode character data.
+</p>
+</div>
+
+<div>
+<head>Installation</head>
+<p>The xmltex parser itself does not require &LaTeX;. It may be loaded
+into initex to produce a format capable of parsing XML files. However
+such a format would have no convenient commands for typesetting, and
+so normally xmltex will be used on top of an existing format, normally
+&LaTeX;. In this section we assume that the document to be
+processed is called <code>document.xml</code>.
+</p>
+<div>
+<head>Using xmltex as an input to the &LaTeX; command</head>
+<p>&LaTeX; requires a document in &TeX; syntax, not XML. To process
+<code>document.xml</code>, first produce a two line file called
+<code>document.tex</code> of the following form:
+<eg>
+\def\xmlfile{document.xml}
+\input xmltex.tex
+</eg>
+
+Do <emph>not</emph> put any other commands in this file!</p>
+<p>You may then process the document with either of the commands:
+<code>latex document</code>  or <code>latex document.tex</code>
+or the equivalent procedure in your &TeX; environment.
+</p>
+</div>
+<div>
+<head>Using xmltex as a &TeX; format built on &LaTeX;</head>
+<p>
+You may prefer to set up xmltex as a format in its own right.
+This may speed things up slightly (as <code>xmltex.tex</code> does not
+have to be read each time) but more importantly perhaps it allows the
+XML file to be processed directly without needing to make the
+<code>.tex</code> wrapper.</p>
+<p>To make a format you will need a command such as the following,
+depending on your &TeX; system.
+<eg>
+initex &amp;latex xmltex
+initex \&amp;latex xmltex
+tex -ini &amp;latex xmltex
+tex -ini \&amp;latex xmltex
+</eg></p>
+<p>This will produce a format file <code>xmltex.fmt</code>. You should then
+be able to make a <code>xmltex</code> command by copying the way the
+<code>latex</code> command is defined in terms of
+<code>latex.fmt</code>. Depending on the &TeX; system, this might be a
+symbolic link, or a shell script, or batch file, or a configuration
+option in a setup menu.
+
+</p>
+</div>
+<div>
+<head> Making an xmltex format `from scratch'</head>
+<p>
+Whilst it may be convenient to build an xmltex format as above, starting
+from the &LaTeX; format. You may prefer to instead work with an initex
+with no existing format file. Even if you wish to use a standard &LaTeX;
+it may be preferable to make a &TeX; input file that first inputs 
+<code>latex.ltx</code> then <code>xmltex.tex</code>. In particular this
+will allow you to have a different hyphenation and language
+customisation for xmltex than for &LaTeX;. Many of the features of
+the language support in &LaTeX; are related to modifying the input
+syntax to be more convenient. Such changes are not needed in xmltex as
+the input syntax is always XML. Some language files may change the
+meaning of such characters as &lt; which would break the xmltex parser.
+Also, rather than using <code>latex.ltx</code> you could in principle
+use a modified <code>docstrip</code> install file and produce a
+`cut down' latex that did not have features that are not going to be
+used in xmltex.
+</p>
+<p>
+Unfortunately the support for this method of building xmltex (and access
+to non English hyphenation generally) is not fully designed and totally
+undocumented.</p>
+</div>
+</div>
+<div>
+<head>Using xmltex</head>
+<p>
+xmltex by default `knows' nothing about any particular type of XML
+file, and so needs to load external files containing specific
+information. This section describes how the information in the XML
+file determines which files will be loaded.
+
+<list type="ordered">
+<item> If the file begins with a Byte Order Mark, the default encoding
+  is set to utf-16. Otherwise the default encoding is utf-8.
+</item>
+<item> If (after an optional BOM) the document begins with an XML
+  declaration that specifies an encoding, this encoding will be used,
+  otherwise the default encoding will be used. A file with name of the
+  form <emph>encoding</emph><code>.xmt</code> will be loaded that maps the
+  requested encoding to Unicode positions. (It is an error if this
+  file does not exist for the requested encoding.)
+</item>
+<item> If the document has a <code>DOCTYPE</code> declaration that includes
+  a local subset then this will be parsed. If any external DTD entity
+  is referenced (by declaring and then referencing a parameter entity)
+  then the SYSTEM and PUBLIC identifiers of this entity will be looked
+  up in a catalogue (to be described below). If either identifier is
+  known in the catalogue the corresponding xmltex package (often with
+  <code>.xmt</code> extension) will be loaded.
+</item>
+<item> After any local subset has been processed, if the DOCTYPE
+  specifies an external entity, the PUBLIC and/or SYSTEM identifiers
+  of the external dtd file will be similarly looked up, and a
+  corresponding xmltex file loaded if known.
+</item>
+<item> As each element is processed, it may be `known' to xmltex by
+  virtue of one of the packages loaded, or it may be unknown. If it is
+  unknown then if it is in a declared namespace, the namespace URI
+  (not the prefix) is looked up in the xmltex catalogue. If the
+  catalogue specifies an xmltex package for this namespace it will be
+  loaded. If the element is not in a namespace, then the element name
+  will be looked up in the catalogue.
+</item>
+<item> If after all these steps the element is still unknown then
+  depending on the configuration setting either a warning or an error
+  will be displayed. (Currently only warning implemented.)
+</item>
+</list>
+</p>
+<div><head>The xmltex Catalogue</head>
+<p>As discussed above, xmltex requires a mapping between PUBLIC and
+SYSTEM identifiers, namespace URI, and element names, to files of
+&TeX; code. This mapping is implemented by the following commands:
+<eg>
+<code>\NAMESPACE</code>{<emph>URI</emph>}{<emph>xmt-file</emph>}
+<code>\PUBLIC</code>{<emph>FPI</emph>}{<emph>file</emph>}
+<code>\SYSTEM</code>{<emph>URI</emph>}{<emph>file</emph>}
+<code>\NAME</code>{<emph>element-name</emph>}{<emph>xmt-file</emph>}
+<code>\XMLNS</code>{<emph>element-name</emph>}{<emph>URI</emph>}
+</eg>
+As described above, if the first argument of one of these commands
+matches the string specified in the XML source file, the corresponding
+&TeX; commands in the file specified in the second argument are
+loaded. The PUBLIC and SYSTEM catalogue entries may also be used
+to control which XML files should be input in response to external
+entity references. The <code>\XMLNS</code> is rather different,
+if an element in the null namespace does not have any definition
+attatched to it, this declaration forces the default namespace to the
+given URI. The catalogue lookup is then repeated. This allows for
+example documents beginning <code>&lt;html&gt;</code> to be coerced into
+the xhtml namespace.</p>
+<p>These commands may be placed in a configuration file, either
+<code>xmltex.cfg</code>, in which case they apply to all documents,
+or in a configuration file `<code>\jobname.cfg</code>' (eg
+<code>document.cfg</code> in the example in the Introduction) in which
+case the commands just apply to the specified document.
+</p>
+</div>
+
+<div>
+<head>Configuring xmltex</head>
+<p>In addition to the `catalogue' commands described earlier there are
+other commands that may be placed in the configuration files.
+
+<list type="unordered">
+<item> <p><code>\xmltraceonly</code></p>
+<p>  This stops xml from trying to typeset the
+  document. The external files specified in the catalogue are still
+  loaded, so that the trace may report any elements for which no code
+  is defined, but no actual typesetting takes place. In the event of
+  unknown errors it is always worth using xmltex in this mode to
+  isolate any problems.</p>
+<p>It may be noted that if an xmltex format is built just using initex
+without any typesetting commands, the resulting format should still
+be able to parse any XML file if xmltex.cfg just specifies 
+<code>\xmltraceonly</code> and \jobname.cfg is empty.</p>
+</item>
+<item> <p><code>\xmltraceoff</code></p>
+<p>By default xmltex provides a trace of its XML parse, displaying
+   each element begin and end. This command used in xmltex.cfg or
+   `\jobname.cfg' will stop this trace being produced.</p>
+</item>
+
+<item><p> <code>\inputonce</code>{<emph>xmt-file</emph>}</p>
+<p>The catalogue entries specify that
+  certain files should be loaded if XML constructs are met.
+  Alternatively the files may just always be loaded. The system will
+  ignore any later requests to load. This is especially useful if an
+  xmltex format is being made.</p>
+</item>
+<item><p><code>\UnicodeCharacter</code>{<emph>hex-or-dec</emph>}{<emph>tex-code</emph>}</p>
+<p>The first argument specifies a unicode character number, in the same
+format as used for XML character entities, namely either a decimal
+number, or an upper case Hex number preceded by a lower case
+`<code>x</code>'.</p>
+<p>The second argument specifies arbitrary &TeX; code to be used when
+typesetting this character. Any code in the XML
+range may be specified (ie up to x10FFFF). Although codes in the
+`ASCII' range, below 128, may be specified, the definitions supplied
+for such characters will not be default be used. The definition will
+howeverbe stored and used if the character is activated using the
+command described below.</p>
+</item>
+<item> <p><code>\ActivateASCII</code>{<emph>hex-or-dec</emph>}</p>
+<p>The argument to this command should be a number less than 128.
+If a character us activated by this command in a configuration file
+then any special typesetting instructions specified for the character
+will be executed whenever the character appears as character data.</p>
+<p>Some ASCII characters are activated by default. The list is
+essentially those characters with special meanings to either &TeX; or
+XML.</p>
+</item>
+
+</list>
+</p>
+<p>
+If a format is being made, there are essentially two copies of
+<code>xmltex.cfg</code> that may play a role. The configuration file
+input when the format is made will control catalogue entries and
+packages built into the format. A possibly different
+<code>xmltex.cfg</code> may be used in the input path of `normal' &TeX;,
+this will then be used for additional information loaded each run.</p>
+<p>In either case, a separate configuration file specific to the given
+XML document may also be used (which is loaded immediately after
+<code>xmltex.cfg</code>).
+</p>
+</div>
+</div>
+
+<div  id="stopping">
+<head>Stopping xmltex</head>
+<p>xmltex  should stop after the end of the document
+element has been processed. If things go wrong and
+you end up at the interactive
+<code>*</code> prompt  you might want to exit with
+<code><![CDATA[<?xmltex \stop?>]]></code>).
+</p>
+</div>
+
+<div>
+<head>xmltex package files</head>
+<p>
+xmltex package files are the link between the XML markup and &TeX;
+typesetting code. They are written in &TeX; (rather than XML) syntax
+and may load directly or indirectly other files, including &LaTeX;
+class and package files. For example a file loaded for a particular
+document type may directly execute <code>\LoadClass{article}</code>, or
+alternatively it may cause some XML element in the document to
+execute <code>\documentclass{article}</code>. In either case the document will
+suffer the dubious benefit of being formatted based on the style
+implemented in <code>article.cls</code>. Beware though that the package
+files may be loaded at strange times, the first time a given namespace
+is declared in a document, and so the code should be written to work
+if loaded inside a local group.</p>
+<p>Characters in xmltex package files have their normal &LaTeX; meanings
+except that line endings are ignored so that you do not need to add
+a % to the end of lines in macro code. Unlike fd file conventions, other
+white space is <emph>not</emph> ignored.</p>
+<p>The available commands are:
+
+<list type="unordered">
+<item><p><code>\FileEncoding</code>{<emph>encoding</emph>}</p>
+<p>This is the analogue for &TeX; syntax files of the encoding specification
+in the XML or text declaration of XML files. If it is not specified the
+file will be assumed to be in UTF-8.</p>
+</item>
+
+<item><p><code>\DeclareNamespace</code>{<emph>prefix</emph>}{<emph>URI</emph>}</p>
+<p>This declares a prefix to be used <emph>in this file</emph> for referring to
+elements in the specified namespace. If the prefix is empty then this
+declares the default namespace (otherwise, unprefixed element names
+refer to elements that are not in a namespace).</p>
+<p>Note that the elements in the XML document instance may use a
+different prefix, or no prefix at all to access this namespace.
+In order to resolve these different prefixes for the same namespace,
+each time a namespace is encountered for the first time (either 
+by <code>\DeclareNamespace</code> in a preloaded package, or in a namespace
+declaration in the XML instance) then it is allocated a new number
+and any further namespace declaration for the same URI just locally
+associates a prefix with this number. It is these numbers that are
+displayed when the XML trace of the parse of the document is shown,
+and also if any element is written out to an external file it will
+have a normalised prefix of a number whichever prefix it had
+originally. (Numeric prefixes are not legal XML, but this is an
+advantage, it ensures these internal forms can not clash with any
+prefix actually used in the document.)</p>
+<p>Three namespaces are predeclared. The null namespace (0), the XML
+namespace (<code>http://www.w3.org/1998/xml</code>) (1) which is predeclaed
+with prefix <code>xml</code> as specified in the Namespace Recommendation,
+and the xmltex namespace
+(<code>http://www.dcarlisle.demon.co.uk/xmltex</code>) (2) which is not
+given a default prefix, but may be used to have XML syntax for some
+internal commands (eg to have .aux files fully in XML, currently they
+are a hybrid mixture of some &TeX; and some XML syntax).
+</p>
+</item>
+<item><p>
+  <code>\XMLelement</code>{<emph>element-qname</emph>}{<emph>attribute-spec</emph>}
+{<emph>begin-code</emph>}{<emph>end-code</emph>}</p>
+<p>  This is similar to a &LaTeX; <code>\newenvironment</code> command.</p>
+<p> Declare the code to execute at the start and end of each instance of
+this element type. This code will be executed in a local group (like a
+&LaTeX; environment). The second argument declares a list of attributes
+and their default values using the <code>\XMLattribute</code> command
+described below.
+</p>
+</item>
+<item><p> 
+  <code>\XMLelement</code>{<emph>element-qname</emph>}
+{<emph>attribute-spec</emph>}
+<code>{\xmlgrab}</code>{<emph>end-code</emph>}</p>
+<p>  A special case of the above command (which may be better made into a
+  separate declaration) is to make the <emph>start-code</emph> just be the command
+  <code>\xmlgrab</code>. In this case the <emph>end-code</emph> has access to the
+  element content (in XML syntax) as <code>#1</code>. This content isn't
+  literally the same as the original document, namespaces, white space
+  and attribute quote symbols will all have been normalised.
+</p>
+</item>
+<item> <p>
+  <code>\XMLattribute</code>{<emph>attribute-qname</emph>}
+{<emph>command-name</emph>}{<emph>default</emph>}</p>
+<p>This command may only be used in the argument to
+<code>\XMLelement</code>.
+ The first argument specifies the name of an attribute (using any
+ namespace prefixes current for this package file, which need not
+ be the same as the prefixes used in the document).
+ The second argument gives a &TeX; command name that will be used to
+ access the value of this attribute in the begin and end code for the
+ element. (Note using &TeX; syntax here provides a name independednt of
+ the namespace declarations that are in scope when this code is executed).
+ The third argument provides a default value that wil be used if the
+attribute is not used on an instance of this element.
+ </p>
+<p>The special token <code>\inherit</code> may be used which will cause
+the command to have a value set in an ancestor element if this element
+does not specify any value.</p>
+<p>If a &TeX; token such as <code>\relax</code> is used as the default
+the element code may distinguish the case that the attribute is not used
+in the document.</p>
+</item>
+<item> <p>
+  <code>\XMLnamespaceattribute</code>
+{<emph>prefix</emph>}{<emph>attribute-qname</emph>}
+{<emph>command-name</emph>}{<emph>default</emph>}</p>
+<p>This command is similar to <code>\XMLattribute</code>
+ but is used at the top level of the package file, not in the argument
+to <code>\XMLelement</code>. It is equivalent to specifying the
+attribute in <emph>every</emph> element in the namespace specified by
+the first argument. As usual the prefix (which may be {} to denote the
+default namespace) refers to the namespace declarations in the xmltex
+package: the prefixes used in the document may be different.</p>
+</item>
+
+<item><p><code>\XMLentity</code>{<emph>name</emph>}{<emph>code</emph>}</p>
+<p>Declare an (internal parsed) entity, this is equivalent to a
+<code><![CDATA[<!ENTITY]]></code> declaration, except that the
+replacement text is specified in &TeX; syntax.</p>
+</item>
+
+<item><p><code>\XMLname</code>{<emph>name</emph>}{<emph>command-name</emph>}</p>
+<p>Declare the &TeX; command to hold the (normalised, internal form) of
+the XML name given in the first argument. This allows the code specified in
+<code>\XMLelement</code> to refer to XML element names without knowing
+the encodings or namespace prefixes used in the document. Of particular
+use might be to compare such a name with <code>\ifx\XML at parent</code>
+which will allow element code to take different actions depending on
+the parent of the current element.</p>
+</item>
+
+
+<item><p><code>\XMLstring</code>{<emph>command-name</emph>}&lt;&gt;<emph>XML Data</emph>&lt;/&gt;</p>
+<p>This saves the XML fragment as the &TeX; command given in the first
+argument. It may be particularly useful for redefining `fixed strings'
+that are generated by &LaTeX; document classes to use any special
+typesetting rules specified for individual characters.</p>
+<p>It should also be used for defining any strings used to
+in comparison tests with strings occurring in the XML document.
+Using <code>\XMLstring</code> rather than <code>\def</code> ensures
+that the characters and encodings in the string are correctly normalised.</p>
+</item>
+
+
+</list>
+
+</p>
+</div>
+<div>
+<head>XML processing</head>
+<p>
+xmltex tries as far as possible to be a fully conforming non
+validating parser. It fails in the following respects.
+<list type="unordered">
+<item> Error reporting is virtually non existent. Names are not checked
+  against the list of allowed characters, and various other
+  constraints are not enforced.
+</item>
+<item><p> A non validating parser is not forced to read external dtd
+  entities (and this one does not) It is obliged to read the local
+  subset and process entity definitions and attribute declarations.
+  Entity declarations are reasonably well handled: External parameter
+  entities are handled as above, loading a corresponding xmltex file
+  if known. External entities are similarly processed, inputting
+  the XML file, a difference in this case is that if the entity is not
+  found in the catalogue, the SYSTEM identifier will be used directly
+  to <code>\input</code> as often this is a local file reference. Internal
+  parsed entities and parameter entities are essentially treated as
+  &TeX; macros, and nonparsed entities are saved along with their
+  NDATA type, for use presumably by <code>\includegraphics</code>.</p>
+<p>Attribute defaults are processed in the local subset of the dtd, however
+   note that this is `namespace unaware' defaulting and only applies to
+   elements using the same prefix and local name, unlike the defaulting
+   done by <code>\XMLattribute</code>. </p>  
+</item>
+<item><p> Support for encodings depends on having an encoding mapping
+  file. Any 8bit encoding that matches Unicode for the first 127 positions
+  may be used by making a trivial mapping file. (The one for latin1
+  looks over complicated as it programs a loop rather than having 127
+  declarations saying that latin1 and Unicode are identical in this
+  range).</p>
+<p>  UTF-8 is supported, but support for UTF-16 is minimal. Currently
+  only latin-1 values work: (In this range UTF-16 is just latin-1 with
+  a null byte inserted after (or before, depending on endedness)
+  each latin-1 byte. The UTF-16 implementation just ignores this null
+  byte then processes as for latin-1. Probably the first few 8bit
+  pages could be similarly supported by making the low ascii control
+  characters activate UTF-16 processing but this will never be
+  satisfactory using a standard &TeX;. Hopefully a setup for a 16bit
+  &TeX; such as Omega will correct this.</p>
+</item>
+</list>
+
+</p>
+</div>
+<div>
+<head>Accessing &TeX;</head>
+<p>In theory you should be able to control the document just be suitable
+code specified by <code>\XMLelement</code> and friends, but sometimes it may be
+necessary to `tweak' the output by placing commands directly in the
+source.</p>
+<p>Two mechanisms are availalable to do this.
+<list type="unordered">
+<item><p> Using the xmltex namespace. The xmltex namespace conatins a
+  small (currently empty) set of useful &TeX; constructs that are
+  accessed by XML syntax. For example if xmltex provides a mechanism
+  for having XML (rather than &LaTeX;) syntax toc files, it will need
+  an analogue of <code>\contentsline</code> which might be an element
+  accessed by <gi>xmltex:contentsline</gi>&ldots; where the xmltex
+  prefix is declared on this or a parent element to be
+ <code>xmlns:xmltex="http://www.dcarlisle.demon.co.uk/xmltex"</code>.</p>
+<p>  As the xmltex namespace is declared but currently empty, a more
+  useful variant of this might be:</p>
+</item>
+<item> Declare your own namespace for &TeX; tweaks, and load a suitable
+  package file that attatches &TeX; code to the elements in this
+  namespace (or at least specify the correspondence between the
+  namespace and the package using <code>\NAMESPACE</code>).
+  For instance if you put <gi>clearpage xmlns="/my/tex/tweak"/</gi>
+  in your document, this will force a page break if you have at
+  suitable points, <code>\NAMESPACE{/my/tex/tweak}{tweak.xmt}</code>
+  and
+<eg>
+\DeclareNamespace{tweak}{"/my/tex/tweak"}
+\XMLelement{tweak:clearpage}{\clearpage}
+</eg>
+</item>
+<item><p> A second different mechanism is available, to use XML processing
+  instructions. A Processing Instruction of the form:
+<gi>?xmltex</gi>  <emph>&TeX; commands</emph> <code>?></code>
+will execute the &TeX; commands.</p>
+</item>
+</list>
+
+</p>
+</div>
+
+<div>
+<head>Bugs</head>
+<p>None, of course.</p>
+</div>
+
+<div>
+<head>Don't Read Past This Point</head>
+<p>Thus section discusses some of the more experimental features of xmltex
+that may get a cleaner syntax (or be removed, as a bad idea) in later releases,
+and also describes some of the internal interfaces (which are also
+subject to change)</p>
+
+<div>
+<head>Input Encodings and States</head>
+<p>At any point while processing a document, xmltex is in one of two 
+<emph>states</emph>: <emph>tex</emph> or <emph>xml</emph>.</p>
+<div><head>States</head>
+<p>In the xml <emph>state</emph>,
+ &lt; and &amp; are the only two characters that
+trigger special markup codes. Other characters, such as !, &gt;, =,
+&ldots; may be used in certain XML constructs as markup but unless
+some code has been triggered by &lt; they are treated simply as
+character data. All characters above 127 are `active' to &TeX;
+and are used to translate the input encoding to UTF-8. All internal
+character handling is based on UTF-8, as described below. Some
+characters in the ASCII range, below 127 are also active by default
+(mainly punctuation characters used in XML constructs, such as
+the ones listed above). Some or all of the others may be activated
+using the <code>\ActivateASCII</code> command, which allows special
+typesetting rules to be activated for the characters, at some cost in
+processing speed.</p>
+<p>In the tex <emph>state</emph>,
+characters in the ASCII range have their usual
+&TeX; meanings, so letters are `catcode 11' and may be used in &TeX;
+control sequences, \ is the escape character, &amp; the table cell
+separator, etc. Characters above 127 have the meanings current for the
+current encoding just as for the xml state, probably this means that
+they are unusable in &TeX; code, except for the special case of
+referring to XML element names in the first argument to
+<code>\XMLelement</code> and releated commands.</p>
+</div>
+<div><head>Encodings</head>
+<p>Whenever a new (XML or &TeX;) file is input by the xmltex system the
+<emph>encoding</emph> is first switched to UTF-8. At the end of the
+input the encoding is returned to whatever was the current encoding.
+The encoding current while the file is read is determined by the
+encoding pseudo-attribute on the XML or text declaration in the case
+of XML files, or by the <code>\FileEncoding</code> command for &TeX;
+files. Note that the encoding mechanism <emph>only</emph> is triggered
+by xmltex file includes. Once an xmltex package file is loaded it may
+include other &TeX; files by <code>\input</code> or
+<code>\includepackage</code> these input command swill be transparent
+to the xmltex encoding system. The vast majority of &TeX; macro
+packages only use ASCII characters so this should not be a
+problem.</p>
+<p>Note that if the <code>\includepackage</code> occurs directly in
+the xmltex package file, the &TeX; code will be included with a known
+encoding, the one specified in the xmltex package, or UTF-8. If
+however the <code>\includepackage</code> is included in code specified
+by <code>\XMLelement</code>, then it will be executed with whatever
+encoding is current in the document at the point that element is
+reached. Before xmltex executes the code for that element it will
+switch to the tex state, thus normalising the ascii characters
+but characters above 127 will not have predefined definitions in this
+case.</p>
+<p>Internally eveything is stored as UTF-8. So `aux' and `toc' files
+will be in UTF-8 even if the document (or parts of the document) used
+different encodings.</p>
+<p>To specify a new encoding, if it is an 8 bit encoding that matches
+ASCII in the printable ASCII range, then one just needs to produce a
+file with name <emph>encoding</emph><code>.xmt</code> (in lowercase,
+on case sensitive systems) this should consist of a series of
+<code>\InputCharacter</code> commands, giving the input character slot
+and the equivalent Unicode. If an encoding is specified in this manner
+character data will be converted to UTF-8 by <emph>expansion</emph>
+and so ligatures and inter letter kerns will be preserved. (Conversely
+if characers are accessed by character references, &amp;#1234; then
+&TeX; arithmetic is used to decode the information and ligature
+information will be lost. For some large character sets, especially
+for Asian languages, these mechanisms will probably not prove to be
+sufficient, some mechanisms are being investigated, but in the short
+term it may be necessary to always use UTF-8 if the input encoding
+is not strictly a ine byte extension of the ASCII code page.
+</p></div>
+
+</div>
+
+<div>
+<head>xmltex Package Commands</head>
+<p>You can use arbitrary &TeX; commands in an xmltex package,
+althought you should be aware that the file may be input into a local
+group, at the point in a document that a particular namespace is first
+used, for example. There are however some specific commands designed
+to be used in the begin or end code of <code>\XMLElement</code>.
+<list type="unordered">
+
+<item><p><code>\ignorespaces</code></p>
+<p>This is actually a &TeX; primitive
+(for the moment!)</p>
+</item>
+
+<item><p><code>\obeyspaces</code></p>
+<p>Obey consecutive space characters,
+rather than treating consecutive runs as a single space.
+(A command of this name, but not this definition is in plain &TeX;.)</p>
+</item>
+
+<item><p><code>\obeylines</code></p>
+<p>Obey end of line characters,
+rather than treating then as a space, force a line break.
+(A command of this name, but not this definition is in plain &TeX;.)</p>
+</item>
+
+<item><p><code>\xmltexfirstchild#1\@</code></p>
+<p>If the <emph>start-code</emph> for an element is specified as
+<code>\xmlgrab</code> then the  <emph>end-code</emph> may use
+<code>#1</code> in order to execute the element content. Sometimes you
+do not want all of the content. The a construction (with currently
+unpleasant syntax) <code>\xmltexfirstchild#1\@</code> will just evaluate
+the first child element of the content, discarding the remaining
+elements.</p>
+</item>
+
+<item><p><code>\xmltextwochildren\csa\csb#1</code></p>
+<p>If you know that the content will be exactly two child elements (for
+examle a MathML frac or sub element) then this command may be used.
+It will execute the &TeX; code 
+<code>\csa{</code><emph>child-1</emph><code>}\csb{</code><emph>child-2</emph>
+So either two &TeX; command smay be supplied, one will be applied to
+each child, or the second argument may be <code>{}</code> in which case
+the first argument may be a &TeX; command that takes two arguments.
+For example the code for MathMl frac might be
+<eg>
+\XMLelement{m:mfrac}
+  {}
+  {\xmlgrab}
+  {\xmltextwochildren\frac{}#1}
+</eg>
+</p>
+</item>
+
+<item><p><code>\xmltexthreechildren\csa\csb\csc#1</code></p>
+<p>As above, but more so.</p></item>
+
+<item><p><code>\xmltexforall\csa{#1}</code></p>
+<p>The &TeX; command <code>\csa</code> is called repeatedly,
+taking each child element of the current element as argument
+on each iteration. As a convenience the command <code>\xml at name</code>
+is defined before each iteration to have the (internal, normalised)
+name of the element being processed.</p>
+</item>
+
+<item><p><code>\NDATAEntity\csa\csb\attvalue</code></p>
+<p>If the XML parser encounters an internalor external entity reference
+it expands it without executing any special hook that may be defined in
+an xmltex package. However NDATA entites are never directly encountered
+in an entity reference. They may only be used as an attribute value.
+If <code>\attvalue</code>. is a &TeX; command holding the value of an
+attribute, as declared in <code>\XMLattribute</code> then
+<code>\NDATAEntity\csa\csb\attvalue</code> applies the two &TeX;
+commands <code>\csa</code> and <code>\csb</code> to the notation type
+and the value, in a way exactly corresponding to
+<code>\xmltextwochildren</code> so for example the XML document for this
+manual specifies
+<eg><![CDATA[
+ <!NOTATION URL SYSTEM "" >
+ <!ENTITY lppl SYSTEM "http://www.latex-project.org/lppl.txt" NDATA URL>]]>
+</eg>
+and this is handled by the following xmltex code
+<eg><![CDATA[
+\XMLelement{xptr}
+ {\XMLattribute{doc}{\xptrdoc}{}}
+ {\NDATAEntity\xptrdoc\@gobble\url}
+ {}]]>
+</eg>
+which saves the attribute value in  <code>\xptrdoc</code> and then
+discards the notation name (URL) and applies the command
+<code>\url</code> to typeset the supplied URL.
+</p>
+</item>
+
+</list>
+</p>
+
+</div>
+
+<div>
+<head>Character Data Internals</head>
+<p>
+<table>
+<row>
+<cell/> <cell>int.</cell><cell>ext. xml</cell>
+<cell>ext. mixed</cell><cell>csn typeout</cell>
+<cell/>
+</row>
+<row>
+<cell>d</cell><cell>xabc</cell><cell>xabc</cell>
+<cell>xabc (12)</cell><cell>xabc (12)</cell><cell>xabc (12)</cell>
+<cell/>
+</row>
+<row>
+<cell>c</cell><cell>xab</cell><cell>xab</cell>
+<cell>xab  (12)</cell><cell>xab  (12)</cell><cell>xab  (12)</cell>
+<cell/>
+</row>
+<row>
+<cell>b</cell><cell>xa</cell><cell>xa</cell>
+<cell>xa   (12)</cell><cell>xa   (12)</cell><cell>xa   (12)</cell>
+<cell/>
+</row>
+<row>
+<cell>ax</cell><cell>x</cell><cell>x</cell>
+<cell>x</cell><cell>x</cell><cell>x    (12)</cell>
+<cell>(!)</cell>
+</row>
+<row>
+<cell>ay</cell><cell>x</cell><cell>x</cell>
+<cell>x</cell><cell>&amp;#123;</cell><cell>x    (12)</cell>
+<cell>(e)</cell>
+</row>
+<row>
+<cell>az</cell><cell>x</cell><cell>\az x</cell>
+<cell>&amp;#123;</cell><cell>&amp;#123;</cell><cell>x    (12)</cell>
+<cell>(&amp;lt;)</cell>
+</row>
+<row>
+<cell>&lt;</cell><cell>&lt;</cell><cell>&lt;</cell>
+<cell>&lt;</cell><cell>&lt;</cell><cell>&lt;    (12)</cell>
+<cell>(&lt;)</cell>
+</row>
+</table>
+
+</p>
+</div>
+
+
+</div>
+
+
+</body>
+</text>
+</TEI.2>
+
+

Added: packages/xmltex/branches/upstream/current/manual.xsl
===================================================================
--- packages/xmltex/branches/upstream/current/manual.xsl	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/manual.xsl	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,29 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+version="1.0">
+<xsl:import href="http://www.oucs.ox.ac.uk/stylesheets/teihtml.xsl"/>
+<xsl:variable name="subTocDepth">-2</xsl:variable>
+<xsl:variable name="masterFile">manual</xsl:variable>
+<xsl:variable name="splitLevel">-1</xsl:variable>
+<xsl:variable name="alignNavigationPanel">center</xsl:variable>
+<xsl:variable name="topNavigationPanel"></xsl:variable>
+<xsl:variable name="bottomNavigationPanel">true</xsl:variable>
+<xsl:variable name="institution">Numerical Algorithms Group: NAG</xsl:variable>
+<xsl:variable name="homeURL">http://www.nag.co.uk/</xsl:variable>
+<xsl:variable name="homeWords">NAG</xsl:variable>
+<xsl:variable name="parentURL">http://www.tei-c.org/</xsl:variable>
+<xsl:variable name="parentWords">NAG</xsl:variable>
+<xsl:variable name="feedbackURL">http://www.nag.co.uk/</xsl:variable>
+<xsl:variable name="feedbackWords">NAG</xsl:variable>
+<xsl:variable name="searchURL"></xsl:variable>
+<xsl:variable name="searchWords"></xsl:variable>
+<xsl:variable name="showTitleAuthor">true</xsl:variable>
+<xsl:template name="logoPicture"/>
+<xsl:template name="copyrightStatement"> Copyright 2000 David Carlisle, NAG
+
+</xsl:template>
+
+
+
+</xsl:stylesheet>
+
+

Added: packages/xmltex/branches/upstream/current/mathml2.xmt
===================================================================
--- packages/xmltex/branches/upstream/current/mathml2.xmt	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/mathml2.xmt	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,190 @@
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% mathml2.xmt
+
+%% Copyright 2000 David Carlisle
+
+%% This file is distributed under the LaTeX Project Public License
+%% (LPPL) as found at http://www.latex-project.org/lppl.txt
+%% Either version 1.0, or at your option, any later version.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\DeclareNamespace{m}{http://www.w3.org/1998/Math/MathML}
+
+
+\XMLstring\att at BLOCK<>block</>
+\XMLstring\att at PREFIX<>prefix</>
+\XMLstring\att at EQUATION<>equation</>
+
+\XMLname{m:math}{\MATH}
+\XMLname{m:mlabeledtr}{\LABELEDTR}
+
+\XMLnamespaceattribute{m}{open}{\XML at fenceopen}{(}
+\XMLnamespaceattribute{m}{close}{\XML at fenceclose}{)}
+\XMLnamespaceattribute{m}{width}{\XML at mspacewidth}{0}
+
+\XMLelement{m:math}
+  {\XMLattribute{display}{\XML at mathmlmode}{foo}
+   }
+  {\def\GATHER{1}%
+     \ifx\XML at mathmlmode\att at BLOCK\[\else\(\fi
+   }
+  {
+     \ifx\XML at mathmlmode\att at BLOCK\]\else\)\fi
+  }
+
+
+\XMLelement{m:mi}
+  {}
+  {\xmlgrab}
+  {\def\a{#1}\mi at test#1\relax}
+
+\gdef\mi at test#1#2\relax{
+  \ifx\mi at test#2\mi at test
+   \expandafter#1
+  \else
+   \mathrm{#1#2}
+  \fi}
+
+\XMLelement{m:mn}
+  {}
+  {\xmlgrab}
+  {\mathrm{#1}}
+
+\XMLelement{m:mo}
+  {\XMLattribute{form}{\XML at mathmlform}{inline}}
+  {\xmlgrab}
+  {\ifx\XML at mathmlform\att at PREFIX
+    \mathop{{\operator at font #1}}%
+   \else
+     #1%
+   \fi
+   }
+
+\XMLelement{m:mrow}
+  {}
+  {}
+  {}
+
+
+\XMLelement{m:msub}
+  {}
+  {\xmlgrab}
+  {\xmltextwochildren\@firstofone\sb#1}
+
+\XMLelement{m:msup}
+  {}
+  {\xmlgrab}
+  {\xmltextwochildren\@firstofone\sp#1}
+
+
+\XMLelement{m:msubsup}
+  {}
+  {\xmlgrab}
+  {\xmltexthreechildren\@firstofone\sb\sp#1}
+
+\XMLelement{m:mroot}
+  {}
+  {\xmlgrab}
+  {\xmltextwochildren\mathmlroot{}#1}
+
+\gdef\mathmlroot#1#2{\root#2\of{#1}}
+
+
+\XMLelement{m:mfrac}
+  {}
+  {\xmlgrab}
+  {\xmltextwochildren\frac{}#1}
+
+
+\XMLelement{m:msqrt}
+  {}
+  {\xmlgrab}
+  {\sqrt{#1}}
+
+\XMLelement{m:mtext}
+  {}
+  {\xmlgrab}
+  {\hbox{#1}}
+
+
+% accent? stackrel?
+\XMLelement{m:mover}
+  {}
+  {}
+  {}
+
+% \DeclareMathDelimiter{{}{\mathopen} {operators}{"28}{largesymbols}{"00}
+\global\delcode`{"66308
+\global\delcode`}"67309
+
+\XMLelement{m:mfenced}
+  {   }
+  {\left\XML at fenceopen}
+  {\right\XML at fenceclose}
+
+\XMLelement{m:mtable}
+  {\XMLattribute{class}{\XML at mtableclass}{}}
+  {
+  \def\StartTable{1}%
+  \def\LABELED{0}%
+  \ifx\XML at mtableclass\att at EQUATION
+     \def\GATHER{1}%
+     \begin{gathered}
+  \else
+     \def\GATHER{0}%
+     \begin{array}{*{99}{c}}
+  \fi
+  }
+  {
+  \ifx\XML at mtableclass\att at EQUATION
+   \end{gathered}
+  \else
+    \end{array}
+  \fi
+  }
+
+
+\XMLelement{m:mtr}
+ {}
+ {\xmlgrab}
+ {\ifnum\StartTable=1
+    \gdef\temp{#1\def\StartTable{0}}%
+  \else
+    \gdef\temp{\\#1}%
+  \fi
+  \aftergroup\temp}
+
+\XMLelement{m:mlabeledtr}
+ {}
+ {\xmlgrab}
+ {\xmltextwochildren{\tag*}\@firstofone#1\gdef\temp{\\}\aftergroup\temp}
+ 
+\XMLelement{m:mtd}
+ {}
+ {\xmlgrab}
+ {\ifnum\GATHER=1
+   \gdef\temp{#1}%
+  \else
+   \gdef\temp{#1\tabcellsep}%
+  \fi
+  \aftergroup\temp
+ }
+
+\XMLelement{m:munderover}
+  {}
+  {}
+  {}
+
+\XMLelement{m:mover}
+  {}
+  {}
+  {}
+
+\XMLelement{m:mspace}
+  {}
+  {}
+  {\@defaultunits\dimen@\XML at mspacewidth pt\relax\@nnil
+   \ifnum\dimen@=\z@\else\kern\dimen@\fi}
+

Added: packages/xmltex/branches/upstream/current/pdfxmltex.ini
===================================================================
--- packages/xmltex/branches/upstream/current/pdfxmltex.ini	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/pdfxmltex.ini	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,2 @@
+\input xmltex
+

Added: packages/xmltex/branches/upstream/current/portugeselatin1.xml
===================================================================
--- packages/xmltex/branches/upstream/current/portugeselatin1.xml	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/portugeselatin1.xml	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<documento att="português">
+ <secção>
+ <cabeçalho>Teste</cabeçalho>
+   Olá Mundo!
+  </secção>
+</documento>

Added: packages/xmltex/branches/upstream/current/readme.txt
===================================================================
--- packages/xmltex/branches/upstream/current/readme.txt	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/readme.txt	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,123 @@
+
+ xmltex.tex
+ ==========
+
+Copyright 2000 David Carlisle
+
+This collection of files is distributed under the LaTeX Project Public
+License a (LPPL) as found at http://www.latex-project.org/lppl.txt
+Either version 1.0, or at your option, any later version.
+
+
+xmltex is a system for typesetting XML files with TeX. It may be used
+on its own or in conjunction with another TeX format. (LaTeX is
+assumed for most examples).
+
+xmltex supports the XML Namespace Recommendation. Arbitrary prefixes
+may be used in document instances, and in definition files. It
+supports any encoding that matches ASCII in the first 127 positions.
+UTF-8, latin-1 and KOI8-R are included in the distribution, other
+encodings may be trivially added.
+
+Further documentation may be obtained by running manual.tex through
+LaTeX.
+
+The distribution of 2000-01-18 consists of:
+
+* readme.txt
+  This file.
+
+
+
+* xmltex.tex
+  The source code for xmltex.
+
+* xmltex.cfg
+  Configuration file for xmltex, with sufficient information about
+  Unicode to typeset the latin-1 and Cyrillic examples in the
+  distribution, and information about the namespaces and dtd used in the
+  examples.
+
+* iso-8859-1.xmt
+  internal file defining latin-1 input encoding
+
+* utf-16.xmt
+  place holder for a file supporting UTF-16 (not really possible with
+  standard TeX).
+
+* koi8-r.xmt
+  internal file defining the Cyrillic encoding KOI8-R.
+  Support for any 8 bit encoding that matches ASCII for the first 127
+  positions may be added by copying the format of file.
+
+
+
+* manual.xml
+  The manual for xmltex (marked up in TEI XML).
+
+* manual.tex
+  Support files for processing the manual.
+  LaTeX manual.tex with your standard LaTeX format, to obtain
+  the typeset documentation.
+
+* manual.html manual.xsl
+  HTML version of manual, generated via XSL (thanks to Sebastian Rahtz).
+
+
+* tei.xmt
+  xmltex package file for TEI XML markup as used in the xmltex manual.
+  (The much of this file was implemented by Sebastian Rahtz)
+
+* mathml2.xmt
+  A small start towards an xmltex package for MathML2.
+  Used in one of the test files.
+
+* sec.xmt
+  A package for a small XML document language used in sone of the test
+  files.
+
+
+
+* langtest.xml langtest.tex
+  This test example file demonstrates a small `hello world' document in
+  different languages and different encodings all input into the same
+  document. Note that the table of contents is constructed correctly
+  despite the fact taht different encodings are used. Also note that
+  typesetting commands only need to be defined once, irrespective of
+  encoding. So the Cyrillic command for `document' looks quite different
+  in the utf-8 and koi8-r files, but the same definitions work in both
+  cases.
+
+* englishutf8.xml
+  English markup in utf-8, used by langtest.xml
+
+* English markup in utf-16,  used by langtest.xml.
+  Note that utf-16 support is limited to the latin-1 range (it just
+  consists of ignoring the null byte).
+
+* portugeselatin1.xml
+  Portugese example, note that the markup is in latin 1, but the
+  definitions (in langtest.cfg are in utf-8).
+
+* russiankoi8.xml
+  Russian Example, KOI8-R. This test file typesets Cyrillic letters
+  This assumes the AMS `OT2' encoded cyrillic fonts are present on your
+  system. (Better support for cyrillic is available with the T2 encoded
+  fonts but these are not used in this example to enable the example
+  to be run on as many sites as possible.)
+
+* russiankutf8.xml
+  Russian Example, utf-8.
+  
+
+* testsec.xml testsec.tex
+  A small example testing varius features.
+  The final section includes some tests of MathML.
+  Note that the elements defined in this file use a namespace prefix
+  even though the elements in the XML document (testsec) do not.
+
+* testascii.xml testascii.tex testascii.cfg
+  A test file in which all characters are activated, allowing for some
+  special effects. (Here vowels are red and numbers are old style.)
+
+ 
\ No newline at end of file

Added: packages/xmltex/branches/upstream/current/russiankoi8.xml
===================================================================
--- packages/xmltex/branches/upstream/current/russiankoi8.xml	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/russiankoi8.xml	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="KOI8-R"?>
+
+<ÄÏËÕÍÅÎÔ ÁÔÔ="ÒÕÓÓËÉÊ">
+ <ÒÁÚÄÅÌ>  
+  <ÇÏÌÏ×Á>ôÅÓÔ</ÇÏÌÏ×Á>
+   úÄÒÁ×ÓÔ×ÕÊ íÉÒ!
+ </ÒÁÚÄÅÌ>
+</ÄÏËÕÍÅÎÔ>
+

Added: packages/xmltex/branches/upstream/current/russianutf8.xml
===================================================================
--- packages/xmltex/branches/upstream/current/russianutf8.xml	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/russianutf8.xml	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,7 @@
+<документ  атт="русский" >
+  <раздел>  
+   <голова>Тест</голова>
+    Здравствуй Мир!
+  </раздел>
+</документ>
+

Added: packages/xmltex/branches/upstream/current/sec.xmt
===================================================================
--- packages/xmltex/branches/upstream/current/sec.xmt	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/sec.xmt	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,42 @@
+
+\DeclareNamespace{dpcsec}{http://www.dcarlisle.demon.co.uk/sec}
+
+
+\XMLelement{dpcsec:doc}
+{}
+  {\documentclass{article}
+    \usepackage[TS1,T1]{fontenc}
+    \usepackage{color,textcomp}
+    \textheight15\baselineskip
+    \parskip1\baselineskip plus \baselineskip
+    \pagestyle{headings}
+   \begin{document}
+   \tableofcontents}
+  {\end{document}}
+
+\XMLelement{dpcsec:sec}
+{}
+  {}
+  {}
+
+\XMLelement{dpcsec:head}
+{}
+  {\xmlgrab}
+  {\section{{\tt aaa} #1}}
+
+\XMLelement{dpcsec:p}
+{}
+{\par}
+  {\par}
+
+
+\XMLelement{dpcsec:tt}
+{}
+{\ttfamily}
+{}
+
+\XMLelement{dpcsec:it}
+{}
+{\itshape}
+{\/}
+

Added: packages/xmltex/branches/upstream/current/tei.xmt
===================================================================
--- packages/xmltex/branches/upstream/current/tei.xmt	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/tei.xmt	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,142 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% tei.xmt
+
+%% Copyright 2000 Sebastian Rahtz, David Carlisle
+
+%% This file is distributed under the LaTeX Project Public License
+%% (LPPL) as found at http://www.latex-project.org/lppl.txt
+%% Either version 1.0, or at your option, any later version.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\XMLelement{TEI.2}{}
+  { \documentclass{article}
+    \usepackage{ifthen,url}
+    \begin{document}  }
+  {\end{document}}
+
+\XMLelement{p}{}
+ {\par}
+ {}
+
+\newcount\SCOUNT
+\global\SCOUNT-1\relax
+
+
+
+
+\XMLelement{div}{
+ \XMLattribute{id}{\idval}{\@nil}}
+ {\advance\SCOUNT\@ne}
+ {}
+
+\XMLelement{head}{  }
+  {\xmlgrab}
+  {\protected at xdef\temp{
+     \expandafter\noexpand\ifcase\SCOUNT
+     \section\or\subsection\or\subsubsection\fi
+     {#1}\ifx\idval\@nnil\else\noexpand\label{\idval}
+   \fi}
+   \aftergroup\temp
+}
+
+
+\XMLelement{emph}{}
+ {\itshape}
+ {}
+
+\XMLelement{code}{}
+ {\ttfamily}
+ {}
+
+\XMLelement{gi}{}
+ {\ttfamily\textless}
+ {\textgreater}
+
+\XMLelement{eg}{}
+ {\begin{quote}\ttfamily\obeylines}
+ {\end{quote}}
+
+\XMLelement{teiHeader}{}
+ {\xmlgrab}
+ {\xmltexfirstchild#1\@empty\@}
+
+\XMLelement{fileDesc}{}
+ {}
+ {}
+
+\XMLelement{titleStmt}{}
+ {\xmlgrab}
+ {}
+
+\XMLelement{availability}{}
+ {\xmlgrab}
+ {\gdef\header at availability{#1}}
+
+\XMLelement{docTitle}{}
+ {\xmlgrab}
+ {\gdef\nopar{\let\par\relax}
+  \title{#1\unskip\thanks{\protect\nopar\ignorespaces\header at availability}}}
+
+\XMLelement{xptr}
+ {\XMLattribute{doc}{\xptrdoc}{}}
+ {\NDATAEntity\xptrdoc\@gobble\url}
+ {}
+
+\XMLelement{docDate}{}
+ {\xmlgrab}
+ {\date{#1}}
+
+\XMLelement{docAuthor}{}
+ {\xmlgrab}
+ {\author{#1}}
+
+\XMLelement{front}{}
+ {}
+ {\maketitle\tableofcontents}
+
+\XMLelement{item}{}
+ {\item}
+ {}
+
+\XMLelement{list}{
+ \XMLattribute{type}{\listtype}{itemize}}
+ {\ifthenelse{\equal{\listtype}{ordered}}
+        {\begin{enumerate}}{\begin{itemize}}}
+ {\ifthenelse{\equal{\listtype}{ordered}}
+        {\end{enumerate}}{\end{itemize}}}
+
+
+\XMLelement{q}{
+ \XMLattribute{rend}{\qrend}{}}
+ {\begin{quote}
+   \ifthenelse{\equal{\qrend}{eg}}{\ttfamily\obeylines}{}}
+ {\end{quote}}
+
+\XMLelement{ptr}{
+ \XMLattribute{target}{\ptrtarget}{}}
+ {\ref{\ptrtarget}}{}
+
+\XMLelement{ref}{
+ \XMLattribute{target}{\ptrtarget}{}}
+ {\ref{\ptrtarget}}{}
+
+
+
+
+\XMLelement{table}{}
+ {\begin{tabular}{*{20}{l}}}
+ {\end{tabular}}
+
+\XMLelement{row}{}
+ {\xmlgrab}
+ {\gdef\temp{#1\\}\aftergroup\temp}
+
+\XMLelement{cell}{}
+ {\xmlgrab}
+ {\gdef\temp{#1\tabcellsep}\aftergroup\temp}
+
+
+% cheating, a bit
+\XMLentity{TeX}{\TeX}
+\XMLentity{LaTeX}{\LaTeX}
\ No newline at end of file

Added: packages/xmltex/branches/upstream/current/testascii.cfg
===================================================================
--- packages/xmltex/branches/upstream/current/testascii.cfg	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/testascii.cfg	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,159 @@
+
+\ActivateASCII{0}
+\ActivateASCII{1}
+\ActivateASCII{2}
+\ActivateASCII{3}
+\ActivateASCII{4}
+\ActivateASCII{5}
+\ActivateASCII{6}
+\ActivateASCII{7}
+\ActivateASCII{8}
+\ActivateASCII{9}
+\ActivateASCII{0}
+\ActivateASCII{11}
+\ActivateASCII{12}
+\ActivateASCII{13}
+\ActivateASCII{14}
+\ActivateASCII{15}
+\ActivateASCII{16}
+\ActivateASCII{17}
+\ActivateASCII{18}
+\ActivateASCII{19}
+\ActivateASCII{20}
+\ActivateASCII{21}
+\ActivateASCII{22}
+\ActivateASCII{23}
+\ActivateASCII{24}
+\ActivateASCII{25}
+\ActivateASCII{26}
+\ActivateASCII{27}
+\ActivateASCII{28}
+\ActivateASCII{29}
+\ActivateASCII{30}
+\ActivateASCII{31}
+\ActivateASCII{32}
+\ActivateASCII{33}
+\ActivateASCII{34}
+\ActivateASCII{35}
+\ActivateASCII{36}
+\ActivateASCII{37}
+\ActivateASCII{38}
+\ActivateASCII{39}
+\ActivateASCII{30}
+\ActivateASCII{31}
+\ActivateASCII{32}
+\ActivateASCII{33}
+\ActivateASCII{34}
+\ActivateASCII{35}
+\ActivateASCII{36}
+\ActivateASCII{37}
+\ActivateASCII{38}
+\ActivateASCII{39}
+\ActivateASCII{40}
+\ActivateASCII{41}
+\ActivateASCII{42}
+\ActivateASCII{43}
+\ActivateASCII{44}
+\ActivateASCII{45}
+\ActivateASCII{46}
+\ActivateASCII{47}
+\ActivateASCII{48}
+\ActivateASCII{49}
+\ActivateASCII{50}
+\ActivateASCII{51}
+\ActivateASCII{52}
+\ActivateASCII{53}
+\ActivateASCII{54}
+\ActivateASCII{55}
+\ActivateASCII{56}
+\ActivateASCII{57}
+\ActivateASCII{58}
+\ActivateASCII{59}
+\ActivateASCII{60}
+\ActivateASCII{61}
+\ActivateASCII{62}
+\ActivateASCII{63}
+\ActivateASCII{64}
+\ActivateASCII{65}
+\ActivateASCII{66}
+\ActivateASCII{67}
+\ActivateASCII{68}
+\ActivateASCII{69}
+\ActivateASCII{70}
+\ActivateASCII{71}
+\ActivateASCII{72}
+\ActivateASCII{73}
+\ActivateASCII{74}
+\ActivateASCII{75}
+\ActivateASCII{76}
+\ActivateASCII{77}
+\ActivateASCII{78}
+\ActivateASCII{79}
+\ActivateASCII{80}
+\ActivateASCII{81}
+\ActivateASCII{82}
+\ActivateASCII{83}
+\ActivateASCII{84}
+\ActivateASCII{85}
+\ActivateASCII{86}
+\ActivateASCII{87}
+\ActivateASCII{88}
+\ActivateASCII{89}
+\ActivateASCII{90}
+\ActivateASCII{91}
+\ActivateASCII{92}
+\ActivateASCII{93}
+\ActivateASCII{94}
+\ActivateASCII{95}
+\ActivateASCII{96}
+\ActivateASCII{97}
+\ActivateASCII{98}
+\ActivateASCII{99}
+\ActivateASCII{100}
+\ActivateASCII{101}
+\ActivateASCII{102}
+\ActivateASCII{103}
+\ActivateASCII{104}
+\ActivateASCII{105}
+\ActivateASCII{106}
+\ActivateASCII{107}
+\ActivateASCII{108}
+\ActivateASCII{109}
+\ActivateASCII{110}
+\ActivateASCII{111}
+\ActivateASCII{112}
+\ActivateASCII{113}
+\ActivateASCII{114}
+\ActivateASCII{115}
+\ActivateASCII{116}
+\ActivateASCII{117}
+\ActivateASCII{118}
+\ActivateASCII{119}
+\ActivateASCII{120}
+\ActivateASCII{121}
+\ActivateASCII{122}
+\ActivateASCII{123}
+\ActivateASCII{124}
+\ActivateASCII{125}
+\ActivateASCII{126}
+\ActivateASCII{127}
+
+
+\UnicodeCharacter{105}{\textcolor{red}{i}}
+\UnicodeCharacter{97}{\textcolor{red}{a}}
+\UnicodeCharacter{101}{\textcolor{red}{e}}
+\UnicodeCharacter{105}{\textcolor{red}{i}}
+\UnicodeCharacter{111}{\textcolor{red}{o}}
+\UnicodeCharacter{117}{\textcolor{red}{u}}
+
+\UnicodeCharacter{48}{\textzerooldstyle}
+\UnicodeCharacter{49}{\textoneoldstyle}
+\UnicodeCharacter{50}{\texttwooldstyle}
+\UnicodeCharacter{51}{\textthreeoldstyle}
+\UnicodeCharacter{52}{\textfouroldstyle}
+\UnicodeCharacter{53}{\textfiveoldstyle}
+\UnicodeCharacter{54}{\textsixoldstyle}
+\UnicodeCharacter{55}{\textsevenoldstyle}
+\UnicodeCharacter{56}{\texteightoldstyle}
+\UnicodeCharacter{57}{\textnineoldstyle}
+

Added: packages/xmltex/branches/upstream/current/testascii.tex
===================================================================
--- packages/xmltex/branches/upstream/current/testascii.tex	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/testascii.tex	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,4 @@
+\def\xmlfile{testascii.xml}
+\input xmltex
+
+

Added: packages/xmltex/branches/upstream/current/testascii.xml
===================================================================
--- packages/xmltex/branches/upstream/current/testascii.xml	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/testascii.xml	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,22 @@
+
+<doc xmlns="http://www.dcarlisle.demon.co.uk/sec">
+
+<sec><head>Heading <it>iii</it> example (123) </head>
+<p>
+This is an example of an experimental mode in which some
+of the characters in the standard `ascii' range are given special
+definitions. Vowels are made red, and digits (0123456789) are typeset in
+oldstyle form. Note that you may still use the sepcial letters as part
+of XML names, for example the follwoin word is set using the element `it':
+<it>italic</it>.
+</p>
+<p>
+While the special definitions apply to any text originating in the XML
+document they do not apply to texts coming from the TeX code and in
+particular from LaTeX packages. Note in this example that the
+section numbers are not old style and the vowels in the word `contents'
+are not coloured.
+</p>
+</sec>
+
+</doc>

Added: packages/xmltex/branches/upstream/current/testsec.tex
===================================================================
--- packages/xmltex/branches/upstream/current/testsec.tex	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/testsec.tex	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,5 @@
+
+\def\xmlfile{testsec.xml}
+\input xmltex.tex
+
+

Added: packages/xmltex/branches/upstream/current/testsec.xml
===================================================================
--- packages/xmltex/branches/upstream/current/testsec.xml	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/testsec.xml	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,77 @@
+
+<!DOCTYPE doc [
+<!ENTITY xx "<p>some text some text some text.</p>" >
+<!ENTITY xxx "&xx;" >
+]>
+
+<doc xmlns="http://www.dcarlisle.demon.co.uk/sec">
+
+<tt>lll</tt>
+<sec>
+ <head>This+&amp;&lt;&gt; <tt>code 111 {\tt 222} 333</tt></head>
+<p>The first section.</p>
+</sec>
+
+<sec>
+ <head>This+<![CDATA[&<>]]> <tt>code 999 {\tt 222} 333</tt></head>
+<p>The second section.</p>
+</sec>
+
+
+
+<p>abc+xyz &#113; (1:&amp; 2:&#38;)</p>
+
+&xxx;&xxx;&xxx;&xxx;&xxx;
+&xxx;&xxx;&xxx;&xxx;&xxx;
+
+<sec>
+ <head>Some utf8 [áéíóú] and some ascii [^^c3^^a1^^c3^^a9^^c3^^ad^^c3^^b3^^c3^^ba]</head>
+<p>and some more áéíóú</p>
+</sec>
+
+
+&xxx;&xxx;&xxx;&xxx;&xxx;
+&xxx;&xxx;&xxx;&xxx;&xxx;
+
+<sec>
+ <head>The End</head>
+<p>The last section.</p>
+</sec>
+
+<math xmlns="http://www.w3.org/1998/Math/MathML">
+<msub><mrow><mi>a</mi> <mo>+</mo> <mi>b</mi></mrow> <mn>2</mn> </msub>
+</math>
+
+
+<math xmlns="http://www.w3.org/1998/Math/MathML">
+<mroot><mrow><mi>xxx</mi> <mo>-</mo> <mi>b</mi></mrow> <mn>3</mn> </mroot>
+</math>
+
+
+<math xmlns="http://www.w3.org/1998/Math/MathML">
+<msubsup>
+  <mi>xxx</mi>
+  <mrow><mi>j</mi><mo>,</mo><mi>k</mi></mrow>
+  <mn>4</mn>
+</msubsup>
+</math>
+
+
+<math xmlns="http://www.w3.org/1998/Math/MathML">
+<mfenced>
+<msup>
+  <mi>xxx</mi>
+  <mn>4</mn>
+</msup>
+</mfenced>
+
+<mfenced open="{" close="]" >
+<msup>
+  <mi>xxx</mi>
+  <mn>4</mn>
+</msup>
+</mfenced>
+
+</math>
+
+</doc>
\ No newline at end of file

Added: packages/xmltex/branches/upstream/current/utf-16.xmt
===================================================================
--- packages/xmltex/branches/upstream/current/utf-16.xmt	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/utf-16.xmt	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,4 @@
+% not a serious implementation
+
+\input iso-8859-1.xmt
+\catcode0=9
\ No newline at end of file

Added: packages/xmltex/branches/upstream/current/windows-1250.xmt
===================================================================
--- packages/xmltex/branches/upstream/current/windows-1250.xmt	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/windows-1250.xmt	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,123 @@
+\InputCharacter{x80}{x20AC}
+\InputCharacter{x82}{x201A}
+\InputCharacter{x84}{x201E}
+\InputCharacter{x85}{x2026}
+\InputCharacter{x86}{x2020}
+\InputCharacter{x87}{x2021}
+\InputCharacter{x89}{x2030}
+\InputCharacter{x8A}{x0160}
+\InputCharacter{x8B}{x2039}
+\InputCharacter{x8C}{x015A}
+\InputCharacter{x8D}{x0164}
+\InputCharacter{x8E}{x017D}
+\InputCharacter{x8F}{x0179}
+\InputCharacter{x91}{x2018}
+\InputCharacter{x92}{x2019}
+\InputCharacter{x93}{x201C}
+\InputCharacter{x94}{x201D}
+\InputCharacter{x95}{x2022}
+\InputCharacter{x96}{x2013}
+\InputCharacter{x97}{x2014}
+\InputCharacter{x99}{x2122}
+\InputCharacter{x9A}{x0161}
+\InputCharacter{x9B}{x203A}
+\InputCharacter{x9C}{x015B}
+\InputCharacter{x9D}{x0165}
+\InputCharacter{x9E}{x017E}
+\InputCharacter{x9F}{x017A}
+\InputCharacter{xA0}{x00A0}
+\InputCharacter{xA1}{x02C7}
+\InputCharacter{xA2}{x02D8}
+\InputCharacter{xA3}{x0141}
+\InputCharacter{xA4}{x00A4}
+\InputCharacter{xA5}{x0104}
+\InputCharacter{xA6}{x00A6}
+\InputCharacter{xA7}{x00A7}
+\InputCharacter{xA8}{x00A8}
+\InputCharacter{xA9}{x00A9}
+\InputCharacter{xAA}{x015E}
+\InputCharacter{xAB}{x00AB}
+\InputCharacter{xAC}{x00AC}
+\InputCharacter{xAD}{x00AD}
+\InputCharacter{xAE}{x00AE}
+\InputCharacter{xAF}{x017B}
+\InputCharacter{xB0}{x00B0}
+\InputCharacter{xB1}{x00B1}
+\InputCharacter{xB2}{x02DB}
+\InputCharacter{xB3}{x0142}
+\InputCharacter{xB4}{x00B4}
+\InputCharacter{xB5}{x00B5}
+\InputCharacter{xB6}{x00B6}
+\InputCharacter{xB7}{x00B7}
+\InputCharacter{xB8}{x00B8}
+\InputCharacter{xB9}{x0105}
+\InputCharacter{xBA}{x015F}
+\InputCharacter{xBB}{x00BB}
+\InputCharacter{xBC}{x013D}
+\InputCharacter{xBD}{x02DD}
+\InputCharacter{xBE}{x013E}
+\InputCharacter{xBF}{x017C}
+\InputCharacter{xC0}{x0154}
+\InputCharacter{xC1}{x00C1}
+\InputCharacter{xC2}{x00C2}
+\InputCharacter{xC3}{x0102}
+\InputCharacter{xC4}{x00C4}
+\InputCharacter{xC5}{x0139}
+\InputCharacter{xC6}{x0106}
+\InputCharacter{xC7}{x00C7}
+\InputCharacter{xC8}{x010C}
+\InputCharacter{xC9}{x00C9}
+\InputCharacter{xCA}{x0118}
+\InputCharacter{xCB}{x00CB}
+\InputCharacter{xCC}{x011A}
+\InputCharacter{xCD}{x00CD}
+\InputCharacter{xCE}{x00CE}
+\InputCharacter{xCF}{x010E}
+\InputCharacter{xD0}{x0110}
+\InputCharacter{xD1}{x0143}
+\InputCharacter{xD2}{x0147}
+\InputCharacter{xD3}{x00D3}
+\InputCharacter{xD4}{x00D4}
+\InputCharacter{xD5}{x0150}
+\InputCharacter{xD6}{x00D6}
+\InputCharacter{xD7}{x00D7}
+\InputCharacter{xD8}{x0158}
+\InputCharacter{xD9}{x016E}
+\InputCharacter{xDA}{x00DA}
+\InputCharacter{xDB}{x0170}
+\InputCharacter{xDC}{x00DC}
+\InputCharacter{xDD}{x00DD}
+\InputCharacter{xDE}{x0162}
+\InputCharacter{xDF}{x00DF}
+\InputCharacter{xE0}{x0155}
+\InputCharacter{xE1}{x00E1}
+\InputCharacter{xE2}{x00E2}
+\InputCharacter{xE3}{x0103}
+\InputCharacter{xE4}{x00E4}
+\InputCharacter{xE5}{x013A}
+\InputCharacter{xE6}{x0107}
+\InputCharacter{xE7}{x00E7}
+\InputCharacter{xE8}{x010D}
+\InputCharacter{xE9}{x00E9}
+\InputCharacter{xEA}{x0119}
+\InputCharacter{xEB}{x00EB}
+\InputCharacter{xEC}{x011B}
+\InputCharacter{xED}{x00ED}
+\InputCharacter{xEE}{x00EE}
+\InputCharacter{xEF}{x010F}
+\InputCharacter{xF0}{x0111}
+\InputCharacter{xF1}{x0144}
+\InputCharacter{xF2}{x0148}
+\InputCharacter{xF3}{x00F3}
+\InputCharacter{xF4}{x00F4}
+\InputCharacter{xF5}{x0151}
+\InputCharacter{xF6}{x00F6}
+\InputCharacter{xF7}{x00F7}
+\InputCharacter{xF8}{x0159}
+\InputCharacter{xF9}{x016F}
+\InputCharacter{xFA}{x00FA}
+\InputCharacter{xFB}{x0171}
+\InputCharacter{xFC}{x00FC}
+\InputCharacter{xFD}{x00FD}
+\InputCharacter{xFE}{x0163}
+\InputCharacter{xFF}{x02D9}
\ No newline at end of file

Added: packages/xmltex/branches/upstream/current/xmltex.cfg
===================================================================
--- packages/xmltex/branches/upstream/current/xmltex.cfg	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/xmltex.cfg	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,177 @@
+% xmltex Catalogue
+\xmltraceoff
+\SYSTEM   {http://www.oucs.ox.ac.uk/dtds/tei-oucs.dtd} {tei.xmt}
+\NAMESPACE{http://www.w3.org/1998/Math/MathML}         {mathml2.xmt}
+\NAMESPACE{http://www.dcarlisle.demon.co.uk/sec}       {sec.xmt}
+\NAME{langtest}                                        {langtest.xmt}
+\NAME{TEI.2} {tei.xmt}
+\NAME{html}                                  {html.xmt}
+\NAMESPACE{http://www.w3.org/1999/XSL/Format}           {fotex.xmt}
+
+% latin 1 and cyrillic (using OT2 encoded fonts) only
+
+
+\UnicodeCharacter{160}{\nobreakspace}
+\UnicodeCharacter{161}{\textexclamdown }
+\UnicodeCharacter{162}{\ifmmode \mbox{\textcent}\else \textcent \fi}% 
+\UnicodeCharacter{163}{\ifmmode \pounds \else \textsterling \fi}% 
+\UnicodeCharacter{164}{\ifmmode \mbox{\textcurrency}\else \textcurrency \fi}% 
+\UnicodeCharacter{165}{\ifmmode \yen \else \textyen \fi}% 
+\UnicodeCharacter{166}{\ifmmode \textbrokenbar \else \textbrokenbar \fi}% 
+\UnicodeCharacter{167}{\ifmmode \S \else \textsection \fi}% 
+\UnicodeCharacter{168}{\textasciidieresis }
+\UnicodeCharacter{169}{\ifmmode \copyright \else \textcopyright \fi}% 
+\UnicodeCharacter{170}{\textordfeminine }
+\UnicodeCharacter{171}{\ifmmode \mbox{\guillemotleft}\else \guillemotleft \fi}% 
+\UnicodeCharacter{172}{\ensuremath{\lnot }}
+\UnicodeCharacter{173}{\ensuremath{\-}}
+\UnicodeCharacter{174}{\ifmmode \circledR \else \textregistered \fi}% 
+\UnicodeCharacter{175}{\textasciimacron }
+\UnicodeCharacter{176}{\ifmmode \mbox{\textdegree}\else \textdegree \fi}% 
+\UnicodeCharacter{177}{\ensuremath{\pm }}
+\UnicodeCharacter{178}{\ensuremath{{^2}}}
+\UnicodeCharacter{179}{\ensuremath{{^3}}}
+\UnicodeCharacter{180}{\textasciiacute }
+\UnicodeCharacter{181}{\ensuremath{\mathrm{\mu}}}
+\UnicodeCharacter{182}{\ifmmode \P \else \textparagraph \fi}% 
+\UnicodeCharacter{183}{\ensuremath{\cdot }}
+\UnicodeCharacter{184}{\ifmmode \mbox{\c{}}\else \c{}\fi}% 
+\UnicodeCharacter{185}{\ensuremath{{^1}}}
+\UnicodeCharacter{186}{\textordmasculine }
+\UnicodeCharacter{187}{\ifmmode \mbox{\guillemotright}\else \guillemotright \fi}% 
+\UnicodeCharacter{188}{\textonequarter }
+\UnicodeCharacter{189}{\textonehalf }
+\UnicodeCharacter{190}{\textthreequarters }
+\UnicodeCharacter{191}{\textquestiondown }
+\UnicodeCharacter{192}{\ifmmode \grave{A}\else \`{A}\fi}% 
+\UnicodeCharacter{193}{\ifmmode \acute{A}\else \'{A}\fi}% 
+\UnicodeCharacter{194}{\ifmmode \hat{A}\else \^{A}\fi}% 
+\UnicodeCharacter{195}{\ifmmode \tilde{A}\else \~{A}\fi}% 
+\UnicodeCharacter{196}{\ifmmode \ddot{A}\else \"{A}\fi}% 
+\UnicodeCharacter{197}{\AA }
+\UnicodeCharacter{198}{\AE }
+\UnicodeCharacter{199}{\ifmmode \mbox{\c{C}}\else \c{C}\fi}% 
+\UnicodeCharacter{200}{\ifmmode \grave{E}\else \`{E}\fi}% 
+\UnicodeCharacter{201}{\ifmmode \acute{E}\else \'{E}\fi}% 
+\UnicodeCharacter{202}{\ifmmode \hat{E}\else \^{E}\fi}% 
+\UnicodeCharacter{203}{\ifmmode \ddot{E}\else \"{E}\fi}% 
+\UnicodeCharacter{204}{\ifmmode \grave{I}\else \`{I}\fi}% 
+\UnicodeCharacter{205}{\ifmmode \acute{I}\else \'{I}\fi}% 
+\UnicodeCharacter{206}{\ifmmode \hat{I}\else \^{I}\fi}% 
+\UnicodeCharacter{207}{\ifmmode \ddot{I}\else \"{I}\fi}% 
+\UnicodeCharacter{208}{\DH }
+\UnicodeCharacter{209}{\ifmmode \tilde{N}\else \~{N}\fi}% 
+\UnicodeCharacter{210}{\ifmmode \grave{O}\else \`{O}\fi}% 
+\UnicodeCharacter{211}{\ifmmode \acute{O}\else \'{O}\fi}% 
+\UnicodeCharacter{212}{\ifmmode \hat{O}\else \^{O}\fi}% 
+\UnicodeCharacter{213}{\ifmmode \tilde{O}\else \~{O}\fi}% 
+\UnicodeCharacter{214}{\ifmmode \ddot{O}\else \"{O}\fi}% 
+\UnicodeCharacter{215}{\ifmmode \times \else \texttimes \fi}% 
+\UnicodeCharacter{216}{\O }
+\UnicodeCharacter{217}{\ifmmode \grave{U}\else \`{U}\fi}% 
+\UnicodeCharacter{218}{\ifmmode \acute{U}\else \'{U}\fi}% 
+\UnicodeCharacter{219}{\ifmmode \hat{U}\else \^{U}\fi}% 
+\UnicodeCharacter{220}{\ifmmode \ddot{U}\else \"{U}\fi}% 
+\UnicodeCharacter{221}{\ifmmode \acute{Y}\else \'{Y}\fi}% 
+\UnicodeCharacter{222}{\TH }
+\UnicodeCharacter{223}{\ss }
+\UnicodeCharacter{224}{\ifmmode \grave{a}\else \`{a}\fi}% 
+\UnicodeCharacter{225}{\ifmmode \acute{a}\else \'{a}\fi}% 
+\UnicodeCharacter{226}{\ifmmode \hat{a}\else \^{a}\fi}% 
+\UnicodeCharacter{227}{\ifmmode \tilde{a}\else \~{a}\fi}% 
+\UnicodeCharacter{228}{\ifmmode \ddot{a}\else \"{a}\fi}% 
+\UnicodeCharacter{229}{\aa }
+\UnicodeCharacter{230}{\ae }
+\UnicodeCharacter{231}{\ifmmode \mbox{\c{c}}\else \c{c}\fi}% 
+\UnicodeCharacter{232}{\ifmmode \grave{e}\else \`{e}\fi}% 
+\UnicodeCharacter{233}{\ifmmode \acute{e}\else \'{e}\fi}% 
+\UnicodeCharacter{234}{\ifmmode \hat{e}\else \^{e}\fi}% 
+\UnicodeCharacter{235}{\ifmmode \ddot{e}\else \"{e}\fi}% 
+\UnicodeCharacter{236}{\ifmmode \grave{\imath}\else \`{\i}\fi}% 
+\UnicodeCharacter{237}{\ifmmode \acute{\imath}\else \'{\i}\fi}% 
+\UnicodeCharacter{238}{\ifmmode \hat{\imath}\else \^{\i}\fi}% 
+\UnicodeCharacter{239}{\ifmmode \ddot{\imath}\else \"{\i}\fi}% 
+\UnicodeCharacter{240}{\dh }
+\UnicodeCharacter{241}{\ifmmode \tilde{n}\else \~{n}\fi}% 
+\UnicodeCharacter{242}{\ifmmode \grave{o}\else \`{o}\fi}% 
+\UnicodeCharacter{243}{\ifmmode \acute{o}\else \'{o}\fi}% 
+\UnicodeCharacter{244}{\ifmmode \hat{o}\else \^{o}\fi}% 
+\UnicodeCharacter{245}{\ifmmode \tilde{o}\else \~{o}\fi}% 
+\UnicodeCharacter{246}{\ifmmode \ddot{o}\else \"{o}\fi}% 
+\UnicodeCharacter{247}{\ensuremath{\div }}
+\UnicodeCharacter{248}{\o }
+\UnicodeCharacter{249}{\ifmmode \grave{u}\else \`{u}\fi}% 
+\UnicodeCharacter{250}{\ifmmode \acute{u}\else \'{u}\fi}% 
+\UnicodeCharacter{251}{\ifmmode \hat{u}\else \^{u}\fi}% 
+\UnicodeCharacter{252}{\ifmmode \ddot{u}\else \"{u}\fi}% 
+\UnicodeCharacter{253}{\ifmmode \acute{y}\else \'{y}\fi}% 
+\UnicodeCharacter{254}{\th }
+\UnicodeCharacter{255}{\ifmmode \ddot{y}\else \"{y}\fi}%
+
+
+\UnicodeCharacter{x044E}{yu}
+\UnicodeCharacter{x0430}{a}
+\UnicodeCharacter{x0431}{b}
+\UnicodeCharacter{x0446}{ts}
+\UnicodeCharacter{x0434}{d}
+\UnicodeCharacter{x0435}{e}
+\UnicodeCharacter{x0444}{f}
+\UnicodeCharacter{x0433}{g}
+\UnicodeCharacter{x0445}{kh}
+\UnicodeCharacter{x0438}{i}
+\UnicodeCharacter{x0439}{{\u\i}}
+\UnicodeCharacter{x043A}{k}
+\UnicodeCharacter{x043B}{l}
+\UnicodeCharacter{x043C}{m}
+\UnicodeCharacter{x043D}{n}
+\UnicodeCharacter{x043E}{o}
+\UnicodeCharacter{x043F}{p}
+\UnicodeCharacter{x044F}{ya}
+\UnicodeCharacter{x0440}{r}
+\UnicodeCharacter{x0441}{s}
+\UnicodeCharacter{x0442}{t}
+\UnicodeCharacter{x0443}{u}
+\UnicodeCharacter{x0436}{zh}
+\UnicodeCharacter{x0432}{v}
+\UnicodeCharacter{x044C}{{\cprime}}
+\UnicodeCharacter{x044B}{y}
+\UnicodeCharacter{x0437}{z}
+\UnicodeCharacter{x0448}{sh}
+\UnicodeCharacter{x044D}{{\`e}}
+\UnicodeCharacter{x0449}{shch}
+\UnicodeCharacter{x0447}{ch}
+\UnicodeCharacter{x044A}{{\cdprime}}
+\UnicodeCharacter{x042E}{YU}
+\UnicodeCharacter{x0410}{A}
+\UnicodeCharacter{x0411}{B}
+\UnicodeCharacter{x0426}{TS}
+\UnicodeCharacter{x0414}{D}
+\UnicodeCharacter{x0415}{E}
+\UnicodeCharacter{x0424}{F}
+\UnicodeCharacter{x0413}{G}
+\UnicodeCharacter{x0425}{KH}
+\UnicodeCharacter{x0418}{I}
+\UnicodeCharacter{x0419}{{\U\I}}
+\UnicodeCharacter{x041A}{K}
+\UnicodeCharacter{x041B}{L}
+\UnicodeCharacter{x041C}{M}
+\UnicodeCharacter{x041D}{N}
+\UnicodeCharacter{x041E}{O}
+\UnicodeCharacter{x041F}{P}
+\UnicodeCharacter{x042F}{YA}
+\UnicodeCharacter{x0420}{R}
+\UnicodeCharacter{x0421}{S}
+\UnicodeCharacter{x0422}{T}
+\UnicodeCharacter{x0423}{U}
+\UnicodeCharacter{x0416}{ZH}
+\UnicodeCharacter{x0412}{V}
+\UnicodeCharacter{x042C}{{\CPRIME}}
+\UnicodeCharacter{x042B}{Y}
+\UnicodeCharacter{x0417}{Z}
+\UnicodeCharacter{x0428}{SH}
+\UnicodeCharacter{x042D}{{\`E}}
+\UnicodeCharacter{x0429}{SHCH}
+\UnicodeCharacter{x0427}{CH}
+\UnicodeCharacter{x042A}{{\CDPRIME}}
+
+

Added: packages/xmltex/branches/upstream/current/xmltex.ini
===================================================================
--- packages/xmltex/branches/upstream/current/xmltex.ini	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/xmltex.ini	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1 @@
+\input xmltex

Added: packages/xmltex/branches/upstream/current/xmltex.tex
===================================================================
--- packages/xmltex/branches/upstream/current/xmltex.tex	2004-06-12 17:30:13 UTC (rev 178)
+++ packages/xmltex/branches/upstream/current/xmltex.tex	2004-06-25 17:33:32 UTC (rev 179)
@@ -0,0 +1,2400 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% xmltex.tex
+
+%% Copyright 2000 David Carlisle, NAG Ltd.
+%% re-released by Sebastian Rahtz June 2002
+%% This file is distributed under the LaTeX Project Public License
+%% (LPPL) as found at http://www.latex-project.org/lppl.txt
+%% Either version 1.0, or at your option, any later version.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\catcode`\{=1 \catcode`\}=2 \catcode`\@=11 \catcode`\#=6
+
+\gdef\XML at tempa#1: #2.tex,v #3 #4 #5 #6 #7${
+  \def\xmltexversion{#4 v#3 (#6)}}
+
+\XML at tempa
+$Id: xmltex.tex,v 1.9 2002/06/25 rahtz Exp $
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% initial setup so that xmltex independent of any existing format
+% even if normally built on top of latex
+
+\endlinechar-1
+
+\catcode`\&=4
+\catcode`\^=7
+\catcode`\_13
+\catcode`\|=14 %
+\catcode`\~=13 %
+
+\ifx\count@\@undefined
+  \countdef\count at 200 % fingers crossed
+  \countdef\XML at ns@count201\relax
+  \expandafter\def\csname newcount\endcsname#1{}
+  \expandafter\def\csname newtoks\endcsname#1{}
+  \toksdef\toks at 200\relax
+  \toksdef\XML at catalogue201\relax
+  \toksdef\XML at attribute@toks202\relax
+  \def\maxdimen{16383.99999pt}
+  \def\space{ }
+  \chardef\active13 %
+  \countdef\z at 0 %
+\fi
+\ifx\@tempcnta\@undefined
+  \countdef\@tempcnta202 % fingers crossed
+  \countdef\@tempcntb203 % fingers crossed
+  \edef\@spaces{\space\space\space\space}
+  \begingroup
+    \catcode`\>12
+    \gdef\strip at prefix#1>{}
+    \endgroup
+\fi
+
+
+% set up 7bit range
+\count at 0
+\catcode0=13
+\gdef\XML at tempa{
+ \begingroup
+   \uccode0\count@
+  \uppercase{\endgroup
+    \edef^^@{
+      \ifnum\catcode\count@=11 %
+        \noexpand\utfeightay\else\noexpand\utfeightax\fi
+      \noexpand^^@}
+    \expandafter\edef\csname 8:\string^^@\endcsname{\string^^@}}
+ \ifnum\count@<127\advance\count at 1 \expandafter\XML at tempa\fi}
+\XML at tempa
+\catcode0=9
+
+\begingroup
+\catcode`\^^M=\active\gdef^^M{\utfeightay^^M}
+\catcode`\^=\active\gdef^{\utfeightay^}
+\catcode`\_=\active\gdef_{\utfeightay_}
+\catcode`\~=\active\gdef~{\utfeightay~}
+\catcode`\%=\active\gdef%{\utfeightay%}
+\catcode`\$=\active\gdef${\utfeightay$}
+\catcode`\#=\active\gdef#{\utfeightay#}
+\catcode`\(=1
+\catcode`\)=2
+\catcode`\{=\active\gdef{(\utfeightay{)
+\catcode`\}=\active\gdef}(\utfeightay})
+\catcode`\/0 \catcode`\\=\active /gdef\(/utfeightay\)
+/endgroup
+
+
+
+\long\def\@gobble#1{}
+\def\@empty{}
+
+\ifx\@@end\@undefined
+  \let\@@end\end
+\fi
+
+\ifx\nfss at catcodes\@undefined
+ \def\nfss at catcodes{
+  \catcode`\\0
+  \catcode`\{1
+  \catcode`\}2
+  \catcode`\%14
+  \catcode`\@11
+  \catcode`\#6
+  \catcode`\"12
+  \catcode`\'12
+  \catcode`\<12
+  \catcode`\=12
+  \catcode`\>12
+  \catcode`\^7 %
+  }
+\fi
+
+% This is standard in LaTeX.
+\ifx\zap at space\@undefined
+\def\zap at space#1 {#1}
+\fi
+
+\newlinechar`\^^J
+
+\ifx\@@input\@undefined
+\let\@@input\input
+\def\input#1{\@@input#1 }
+\fi
+\chardef\active=13
+\chardef\@ne=1
+
+%
+\ifx\IfFileExists\@undefined
+  \def\IfFileExists#1#2#3{\def\@filef at und{#1 }#2}
+\fi
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\immediate\write20{xmltex version: \xmltexversion}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\let\tabcellsep&
+
+\def\afterfi#1\fi{\fi#1}
+
+
+% set catcodes of low chars to 12 and hight 10 13.
+\gdef\XML at tempa#1#2{
+  \catcode\count@#2\relax
+  \ifnum\count@<#1\relax
+     \advance\count@\@ne
+     \afterfi
+     \XML at tempa{#1}{#2}
+  \fi
+  }
+\count at 0\relax
+\XML at tempa{`\^^K}{12}
+
+\count at 127\relax
+\XML at tempa{255}{13}
+
+
+\def\XML at catcodes{
+% white
+  \catcode`\ \active
+  \catcode`\^^M\active
+  \catcode`\^^I\active
+% xml
+  \catcode`\<\active
+  \catcode`\>\active
+  \catcode`\:\active
+  \catcode`\[\active
+  \catcode`\]\active
+  \catcode`\%\active
+  \catcode`\&\active
+  \catcode`\"\active
+  \catcode`\'\active
+  \catcode`\=\active
+% tex
+  \catcode`\/\active
+  \catcode`\!\active
+  \catcode`\?\active
+  \catcode`\-\active
+  \catcode`\$\active
+  \catcode`\{\active
+  \catcode`\}\active
+  \catcode`\#\active
+  \catcode`\_\active
+  \catcode`\\\active
+  \catcode`\~\active\def~{\utfeightay~}
+% and these are not catcodes
+  \let\XML at ns@a@\XML at ns@a at xml
+  \let\XML at ns\XML at ns@xml
+}
+
+
+\catcode`\/\active
+\catcode`\!\active
+\catcode`\?\active
+\catcode`\"\active
+\catcode`\'\active
+\catcode`\<\active
+\catcode`\>\active
+\catcode`\&\active
+\catcode`\_\active
+\catcode`\ 10
+\catcode`\^^M\active
+
+
+
+%% half baked bom and utf-16 support
+\catcode`^^ff\active
+\catcode`^^fe\active
+\catcode0=9
+
+% do this also in everyjob incase a <?xmltex dump?> has turned it iff.
+\def^^ff^^fe{
+  \def\XML at thisencoding{utf-16}}
+\def^^fe^^ff{
+  \def\XML at thisencoding{utf-16}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%% warnings
+\def\XML at warnNI#1{
+  {\let\protect\string\utfeight at protect@typeout\message{^^J#1}}}
+\def\XML at warn#1{
+  {\let\protect\string\utfeight at protect@typeout\message{^^J\XML at w@#1}}}
+\let\XML at trace@warn\XML at warn
+\let\XML at trace@warnNI\XML at warnNI
+\let\XML at trace@warnE\message
+
+\let\XML at w@\@empty
+
+% quoted literals
+% " or '
+% #1 command to call, gets quoted string as #1
+% #2 " or '
+% " and ' assumed active
+\def\XML at quoted#1#2{
+   \ifx#2"\expandafter\XML at qq
+   \else\ifx#2'\expandafter\expandafter\expandafter\XML at q
+   \else
+     \ERROR#2
+   \fi
+   \fi
+   #1}
+
+
+\def\XML at qq#1#2"{#1{#2}}
+\def\XML at q#1#2'{#1{#2}}
+
+
+%%%%%%%%%%%%%%%%%
+
+% < handler
+
+% / ! ? assumed active
+\def\XML at lt@markup#1{
+  \catcode`\^^I=10 %
+  \catcode`\^^M=10 %
+  \catcode`\ =10 %
+  \ifx/#1\XML at getend
+  \else\ifx!#1\XML at getdecl
+  \else\ifx?#1\XML at getpi
+  \else\XML at getname#1\@}
+
+\def\XML at first@lt{
+  \let<\XML at lt@markup
+  \let^^ff\@undefined
+  \let^^fe\@undefined
+  \XML at lt@markup}
+
+
+%% reset catcodes
+\def\XML at reset{
+  \nfss at catcodes
+  \catcode`\$3
+  \catcode`\&4
+  \catcode`\^7
+  \catcode`\_8
+  \catcode`\:12
+  \catcode`\!12
+  \catcode`\=12
+  \catcode`\=12
+  \catcode`\|12
+  \catcode`\ =10 
+  \catcode`\~\active\def~{\nobreakspace{}}
+% catcodes?
+  \let\XML at ns@a@\XML at ns@a at tex
+  \let\XML at ns\XML at ns@tex}
+
+
+%% begin tag
+\begingroup
+  \catcode`\^^M\active
+  \catcode`\^^I\active
+  \catcode`\ \active
+%
+% #1 first char of name
+% grab the name into an xdef so that derminating string can
+% be any of whitespace / or >
+\gdef\XML at getname#1\@{
+\fi\fi\fi
+\begingroup
+\catcode`\^^M\active
+\catcode`\^^I\active
+\catcode`\ \active
+\def {\iffalse{\fi}\XML at getname@}
+\let^^M %
+\let^^I %
+\def/{\iffalse{\fi}\XML at getname@/}
+\def>{\iffalse{\fi}\XML at getname@>}
+\unrestored at protected@xdef\XML at tempa{\iffalse}\fi#1}
+
+\endgroup
+
+% finish the special group for the name xdef, start an XML at begingroup
+% for the element, and begin processing any attributes.
+\def\XML at getname@{
+  \endgroup
+  \XML at begingroup
+  \edef\XML at w@{ \XML at w@}
+  \let\begintag\XML at tempa
+  \let\XML at parent\XML at this@element
+  \XML at attribute@toks{}
+  \XML at getattrib}
+
+% elements put in an \XML at begingroup which is a not a group at the
+% outer level to save save stack, but turns itself into a group
+% for nexted elements.
+\def\XML at begingroup{
+ \def\XML at begingroup{
+   \begingroup
+   \let\XML at begingroup\begingroup
+   \let\XML at endgroup\endgroup}}
+
+\let\XML at endgroup\@@end
+
+
+
+%% attributes
+
+% #1 first letter of attribute name, or / or > to finish.
+\def\XML at getattrib#1{
+  \ifx#1/
+    \expandafter\XML at endempty
+  \else
+  \ifx#1>
+     \expandafter\expandafter\expandafter\XML at startelement
+  \else
+    \XML at getattrib@a#1
+  \fi
+  \fi}
+
+\let\XML@@getattrib\XML at getattrib
+
+\begingroup
+\catcode`\:\active
+\catcode`\<12
+\catcode`\>12
+
+% restore normal XML whitespace regime
+% namespace check element name (has to be done after attribute handling)
+% trace the element start then `do' the element which might be
+% noop, execute package code, or grab, depending.
+
+\gdef\XML at startelement{
+  \XML at default@attributes
+  \catcode`\^^M\active
+  \catcode`\^^I\active
+  \catcode`\ \active
+  \XML at ns\begintag
+  \edef\XML at this@element{
+    \csname XMLNS@\XML at this@prefix\expandafter\endcsname\noexpand:
+                          \XML at this@local}
+  \XML at trace@warn{<\XML at this@element}
+  \XML at checkknown
+  \XML at attrib@trace
+  \XML at doelement}
+
+\endgroup
+
+% This is a noop if tracing turned off, otherwise loop through
+% attlist with a typeout on each.
+\def\XML at attrib@trace{
+  \begingroup
+    \let\XML at doattribute\XML at doattribute@warn
+    \def\XMLNS@{0}
+    \utfeight at protect@typeout
+    \the\XML at attribute@toks
+    \XML at trace@warnE{ >}
+  \endgroup}
+
+% execute package code for an element start.
+\def\XML at doelement{
+  \csname
+    E:\XML at this@element
+  \endcsname
+}
+
+\begingroup
+\catcode`\:\active
+\uccode`\~`\^^I%
+
+% grab element content into a token register.
+% has to pass through xdef to normalise encodings.
+\uppercase{
+\gdef\XML at grabelement{
+\catcode`\ \active\catcode`\^^M\active\catcode`\^^I\active
+  \global\XMLgrabtoks\expandafter{
+    \the\expandafter\XMLgrabtoks
+      \expandafter<\XML at this@element~}
+% check if I can switch this just once, where grabelement switched.
+   \begingroup
+   \let\XML at doattribute\XML at grabattribute
+   \def\XMLNS@{0}
+   \expandafter\let\csname XMLNS at 0\endcsname\XMLNS@
+   \the\XML at attribute@toks
+   \endgroup
+%
+\catcode`\ \active\catcode`\^^M\active\catcode`\^^I\active
+  \global\XMLgrabtoks\expandafter{
+    \the\XMLgrabtoks
+    >}
+   \XMLgrab@}
+}
+
+% #1  namespace
+% #2  local name
+% #3  value
+
+\catcode`\=\active
+\gdef\XML at grabattribute#1#2#3{
+  \protected at xdef\XML at tempa{\csname XMLNS@#1\endcsname:#2}
+  \global\XMLgrabtoks\expandafter{
+    \the\expandafter\XMLgrabtoks
+    \XML at tempa="#3" }}
+\endgroup
+
+% #1 should be empty, between the / and the >
+% probably should put some internal form here rather than literally adding
+% end tag to be reparsed, but this simplifies grab code.
+\def\XML at endempty#1>{
+  \expandafter\XML at startelement
+  \expandafter<\expandafter/\begintag>}
+
+
+%% check we know what to do with an element
+\def\XML at checkknown{
+  \expandafter\ifx
+% catcode :?    \csname E:\XML at this@element\endcsname
+    \csname E:\csname XMLNS@\XML at this@prefix\endcsname:\XML at this@local\endcsname
+    \relax
+   \let\XML at use\@empty
+   \ifnum0=\csname XMLNS@\XML at this@prefix\endcsname
+     \let\XML at NAME\XML at this@local
+% prerun catalogue in this case which might coerce element into a new namespace
+     \the\XML at catalogue
+   \else
+     \edef\XML at NAMESPACE{\csname XMLNS@\XML at this@prefix\endcsname}
+     \fi
+   \let\XML at NAME\relax
+   \the\XML at catalogue
+   \inputonce\XML at use
+   \expandafter\ifx\csname E:\csname
+       XMLNS@\XML at this@prefix\endcsname:\XML at this@local\endcsname\relax
+     \XML at trace@warnE{Undefined}
+   \fi
+ \fi}
+
+
+
+%% end tag
+
+\def\XML at getend#1\@#2>{
+  \fi
+\catcode`\ \active
+% removed by Peter Housel housel at acm.org 2000/09/06 
+% \catcode`\^^M\active\catcode`\^^I\active
+  \XML at getend@a#2 \@}
+
+\begingroup
+\catcode`\/=12
+\catcode`\<=12
+\catcode`\>=12
+\catcode`\:=12
+
+% namespace normalise element name in end tag.
+\gdef\XML at getend@a#1 #2\@{
+\catcode`\ \active\catcode`\^^M\active\catcode`\^^I\active
+  \def\endtag{#1}
+  \XML at ns\endtag
+  \XML at trace@warn{</\csname XMLNS@\XML at this@prefix\endcsname:\XML at this@local>}
+  \XML at doend
+}
+
+% execute package code for element end.
+\gdef\XML at doend{
+  \csname
+    E/:\csname XMLNS@\XML at this@prefix\endcsname:\XML at this@local
+  \endcsname
+  \XML at endgroup
+% added by Peter Housel housel at acm.org 2000/09/06 
+ \catcode`\^^M\active \catcode`\^^I\active \catcode`\ \active}
+\endgroup
+
+% flag children: put \@empty after every child element
+% used by \xmltextwochildren and friends
+
+% need active and non active : and / so...
+\begingroup
+\catcode`\:\active
+\uccode`\*=`\:
+\uccode`\.=`\/
+\uccode`\a\z@
+\uccode`\b\z@
+\uccode`\c\z@
+\uccode`\d\z@
+\uccode`\e\z@
+\uccode`\n\z@
+\uccode`\r\z@
+\uccode`\o\z@
+\uccode`\t\z@
+
+\uppercase{
+\gdef\XML at grabend{
+  \ifx\XML at this@level\XML at w@
+% end inner group to restore \XML at doelement and friends
+    \endgroup
+    \XML at trace@warn{Grabbed content}
+    \csname
+      E.*\csname XMLNS@\XML at this@prefix\endcsname
+        *\XML at this@local
+    \expandafter\endcsname\expandafter{
+      \the\XMLgrabtoks}
+    \XML at trace@warn{End grabbed content}
+    \XML at endgroup
+% \XMLstring usage means catcode restoring varies
+% must fix this one day, for now use ifnum avoidance
+\ifnum\catcode`\^^M=10
+\catcode`\ \active\catcode`\^^M\active\catcode`\^^I\active
+\fi
+  \else
+    \xdef\XML at tempa{\noexpand<\noexpand/
+      \csname XMLNS@\XML at this@prefix\expandafter\endcsname\noexpand:
+             \XML at this@local
+    \noexpand>
+    \ifx\XML at next@level\XML at w@\noexpand\@empty\fi}
+    \global\XMLgrabtoks\expandafter{
+      \the\expandafter\XMLgrabtoks
+      \XML at tempa}
+    \XML at endgroup
+  \expandafter
+    \XMLgrab@
+  \fi}}
+\endgroup
+%%%
+
+% syntax for these will probably change.
+\def\xmltexfirstchild#1\@empty#2\@{
+  #1}
+\def\xmltextwochildren#1#2#3\@empty#4\@empty{
+  #1{#3}#2{#4}}
+\def\xmltexthreechildren#1#2#3#4\@empty#5\@empty#6\@empty{
+  #1{#4}#2{#5}#3{#6}}
+\def\xmltexforall#1#2{
+  \xmltexf at rall#1#2< >\@empty}
+
+\def\xmltexf at rall#1#2<#3 #4>#5\@empty{
+  \ifx\relax#3\relax
+  \else
+  \def\xml at name{#3}#1{<#3 #4>#5}
+  \expandafter\xmltexf at rall\expandafter#1
+  \fi}
+
+% #1  entity name (or tex macro holding same, eg from an attrbute)
+% #2 #3 inserted before each compontent
+% so #2{GIF}#3{xxx/yyy.gif}
+\begingroup
+\catcode`\&12
+\catcode`\+12
+
+\gdef\NDATAEntity#1{
+  \expandafter\expandafter\expandafter
+  \XML at ndataentity\csname+&#1\endcsname}
+
+\gdef\XML at ndataentity#1#2#3#4{
+  #3{#1}#4{#2}}
+
+\endgroup  
+
+
+%%%%%%%
+
+% this relies on = being catcode 13.
+\begingroup
+\catcode`\=\active
+
+\gdef\XML at getattrib@a#1\fi\fi#2={
+  \fi\fi
+   \XML at set@this at attribute#1#2 \@
+   \XML at quoted\XML at attribval}
+
+\endgroup
+
+%% remove trailing space from `foo ='
+\def\XML at set@this at attribute#1 #2\@{
+% should probably do an edef at this point, and optimise
+% later code
+  \def\XML at this@attribute{#1}}
+
+% #1 = attribute value
+\def\XML at attribval#1{
+% allow for arbitrary catcodes.
+  \xdef\XML at tempa{\expandafter\strip at prefix\meaning\XML at this@attribute}
+  \ifx\XML at tempa\XML at ns@decl
+    \XML at ns@uri{}{#1}
+   \else
+     \XML at ns\XML at this@attribute
+% catcode avoidance
+     \edef\XML at this@prefix{\expandafter\strip at prefix\meaning\XML at this@prefix}
+     \ifx\XML at this@prefix\XML at ns@decl
+       \XML at ns@uri\XML at this@local{#1}
+     \else
+      \begingroup
+% check if this still needed with protect setting?
+%       \def"{\noexpand&quot;}
+      \utfeight at protect@internal
+       \xdef\XML at tempa{
+          \the\XML at attribute@toks
+          \noexpand\XML at doattribute{\XML at this@prefix}{\XML at this@local}{#1}}
+       \endgroup
+       \XML at attribute@toks\expandafter{\XML at tempa}
+      \fi
+    \fi
+  \XML at getattrib}
+
+
+%% activate attributes
+
+% this seems over complicated and perhaps I should re-implement.
+% currently tries to avoid making a csname for each attribute.
+% declaration of attributes provides a normal tex command name
+% to access the value in the element code, could  have instead
+% just had declaration of attribute name and default and used something
+% like \attributevalue{html:href} but would need to work out a way
+% of resolving prefixes at definition time if this was embedded in
+% the element code. (The prefix such as `html' used in the definition
+% file isn't known by the time the code is run.) 
+\def\XML at doattribute@warn#1#2#3{
+  \XML at trace@warn{\@spaces\csname XMLNS@#1\endcsname:#2 = \string"#3\string"}}
+
+% #1 element specific attribute defaults, first token is
+% macro for namespace-global attributes (hence \expandafter)
+\def\XML at setattributes#1{
+  \let\XMLNS@@\XMLNS@
+   \def\XMLNS@{0}
+   \the\expandafter\XML at attribute@toks#1\relax\relax
+   \let\XMLNS@\XMLNS@@}
+
+% #1 prefix
+% #2 local name
+% #3 value
+\def\XML at doattribute#1#2#3{
+  \xdef\XML at tempa##1{\noexpand##1{
+       \noexpand\XML at attrib\csname XMLNS@#1\endcsname:#2\relax}}
+  \XML at tempa\XML at attrib@x{#3}
+  \XML at tempa\XML at attrib@y}
+
+% #1 \XML at attrib qname\relax
+% #2 value given in document instance
+\def\XML at attrib@x#1#2{
+    \gdef\XML at tempb##1#1##2##3##4\relax\relax{
+    \def##2{#2}
+    ##1##4\relax\relax}}
+
+% #1 \XML at attrib qname\relax
+% #2 original attribute defaults
+\def\XML at attrib@y#1#2\relax\relax{
+  \XML at tempb#2#1\XML at temp@l{6}\relax\relax}
+
+
+% if default is inherit, set it to \relax the first time, otherwise
+% let whatever value it has drop through. Note this is inheritance of the
+% tex csname declared as the internal access, not of the xml attribute name. 
+% #1 = junk
+% #2 = tex csname
+% #3 = attribute default (should be encoding neutral: not normalised)
+\def\XML at attrib#1\relax#2#3{
+  \ifx\inherit#3\relax% #3 might be empty
+    \ifx#2\@undefined
+      \def#2{\relax}
+    \fi
+  \else
+    \def#2{#3}
+  \fi}
+
+% any distinguishing value would do...
+\let\inherit\XML at attrib
+
+
+\newtoks\XML at attribute@toks
+
+%%%%% namespace declarations
+
+\newcount\XML at ns@count
+
+% need to protect against active chars
+\def\XML at ns@decl{xmlns}
+\edef\XML at ns@decl{\expandafter\strip at prefix\meaning\XML at ns@decl}
+
+
+% #1 prefix (or empty)
+% #2 uri
+% globally allocate number to uri if new
+% locally alocate prefix to number
+% globally allocate number as a prefix (canonical form)
+\def\XML at ns@uri#1#2{
+  \utfeight at protect@chars
+  \XML at ns@alloc{#2}
+  \expandafter\edef\csname XMLNS@#1\endcsname
+                      {\csname XML:#2\endcsname}
+  \XML at trace@warn{xmlns:#1 = \csname XMLNS@#1\endcsname}
+  \unprotect at utfeight
+ }
+
+% and the same without any prefix
+% always use in scope of utfeight protect
+% #1 uri
+\def\XML at ns@alloc#1{
+  \expandafter\ifx\csname XML:#1\endcsname\relax
+    \global\advance\XML at ns@count\@ne
+    \expandafter\xdef\csname XML:#1\endcsname{\the\XML at ns@count}
+    \global\expandafter\let\csname A:\the\XML at ns@count\endcsname\@empty
+    \XML at trace@warnNI{URI: \csname XML:#1\endcsname\space = #1}
+    \expandafter\xdef\csname XMLNS@\the\XML at ns@count\endcsname
+                      {\the\XML at ns@count}
+  \fi}
+
+% and version for xmt files
+\let\DeclareNamespace\XML at ns@uri
+
+%% namespace support
+
+%% : is active in xml state but inactive in tex state, so need to do
+%% this twice, grrr...
+\begingroup
+\catcode`\:\active
+
+% #1 = qname to be split on :
+\gdef\XML at ns@xml#1{
+  \expandafter\XML at ns@a at xml#1:\@:\\}
+
+% #1 = prefix (or empty)
+% #2 = local name or \@ if no prefix
+\gdef\XML at ns@a at xml#1:#2:#3\\{
+  \ifx\@#2
+    \XML at ns@b{}{#1}
+  \else
+     \XML at ns@b{#1}{#2}
+  \fi}
+\endgroup
+
+% same with inactive :
+% #1 = qname to be split on :
+\def\XML at ns@tex#1{
+  \expandafter\XML at ns@a at tex#1:\@:\\}
+
+% #1 = prefix (or empty)
+% #2 = local name or \@ if no prefix
+\def\XML at ns@a at tex#1:#2:#3\\{
+  \ifx\@#2
+    \XML at ns@b{}{#1}
+  \else
+     \XML at ns@b{#1}{#2}
+  \fi}
+
+\let\XML at ns@a@\XML at ns@a at tex
+\let\XML at ns\XML at ns@tex
+
+%%%%%%%%%%%%%%%%%%%%
+
+% nullnamespace 
+\expandafter\def\csname XML:\endcsname{0}
+\expandafter\let\csname A:0\endcsname\@empty
+\def\XMLNS@{0}
+\expandafter\gdef\csname XMLNS at 0\endcsname{0}
+
+% xml namespace 
+\let\utfeightax\string
+\expandafter\def\csname XML:http://www.w3.org/1998/xml\endcsname{1}
+\expandafter\let\csname A:1\endcsname\@empty
+\def\XMLNS at xml{1}
+\expandafter\gdef\csname XMLNS at 1\endcsname{1}
+\XML at ns@count1
+
+% #1 = prefix or empty
+% #2 = local name
+\def\XML at ns@b#1#2{
+  \begingroup
+  \utfeight at protect@chars
+  \xdef\XML at tempa{#1}
+  \xdef\XML at tempb{#2}
+  \endgroup
+  \let\XML at this@prefix\XML at tempa
+  \let\XML at this@local\XML at tempb
+  }
+
+%%%%%
+% pi
+\begingroup
+\catcode`\?\active
+\catcode`\ \active
+\catcode`\^^M\active
+\catcode`\^^I\active
+
+\gdef\XML at getpi#1\@{
+\fi\fi\fi
+\begingroup
+\utfeight at protect@chars
+\catcode`\ \active
+\catcode`\^^M\active
+\catcode`\^^I\active
+\def?{\endcsname?}
+\let \endcsname
+\let^^M\endcsname
+\let^^I\endcsname
+\expandafter\XML at getpi@\csname
+Q:}
+
+\endgroup
+
+\def\XML at getpi@#1{
+  \endgroup
+  \catcode`\^^M\active
+  \catcode`\^^I\active
+  \catcode`\ \active
+  \ifx#1\@undefined
+    \expandafter\XML at getpi@x
+  \fi
+  #1}
+
+\def\XML at getpi@x#1#2?>{
+  \XML at dopi{Undefined}{}}
+
+% currently ? not reset by XML at reset
+\expandafter\def \csname Q:xmltex\endcsname{
+  \begingroup
+  \XML at reset
+  \catcode`\>\active
+  \XML at xmltexpi}
+
+
+\gdef\XML at xmltexpi#1?>{
+  \endgroup
+  \XML at dopi{xmltex}{#1}}
+
+
+
+% #1 = piname or `piname Undefined'
+\def\XML at dopi#1#2{
+  \XML at trace@warn{\string<?#1?>}
+  #2}
+
+\begingroup
+\catcode`\^^I\active
+
+\gdef\XML at grabpi#1#2{
+  \global\XMLgrabtoks\expandafter{
+  \the\XMLgrabtoks<?#1^^I#2?>}
+  \XMLgrab@}
+
+\endgroup
+
+ 
+
+%% XML and declarations
+% only care about encoding. Ignore version and standalone.
+
+% #1 content
+% #2 end of test code
+\begingroup
+\catcode`\=\active
+
+\expandafter\gdef \csname Q:xml\endcsname{
+  \catcode`\^^M10
+  \catcode`\^^I10
+  \catcode`\ 10 %
+  \XML at xmldecl}
+
+\gdef\XML at xmldecl#1?>{
+  \catcode`\^^M\active
+  \catcode`\^^I\active
+  \catcode`\ \active
+  \XML at encoding#1 e="utf-8"\relax}
+
+
+% actually encoding supposed to be after version if it comes at all
+% so I could simplify this and get rid of the loop.
+\gdef\XML at encoding#1 #2{
+  \if\noexpand#2e
+    \expandafter\XML at encoding@aux
+  \else
+    \expandafter\XML at encoding
+  \fi}
+
+\gdef\XML at encoding@aux#1={
+  \XML at quoted\XML at setenc}
+
+\endgroup
+
+% do nothing if newly specied encoding is same as old one
+% #1 is name of encoding (upper or lower case, and dubious catcodes
+% #2 is junk
+
+\def\XML at setenc#1#2\relax{
+  \lowercase{\gdef\XML at tempa{#1}}
+  \xdef\XML at tempa{\expandafter\strip at prefix\meaning\XML at tempa}
+  \ifx\XML at tempa\XML at thisencoding
+  \else
+    \ifx\XML at utfeight\XML at tempa
+      \XML at setutfeight
+    \else
+      \let\XML at thisencoding\XML at tempa
+      \XML at trace@warnNI{Encoding = \XML at thisencoding}
+      \begingroup
+      \XML at reset\input{\XML at thisencoding.xmt}
+      \endgroup
+    \fi
+  \fi}
+
+% public version of same
+\def\FileEncoding#1{
+  \XML at setenc{#1}\relax}
+
+% catcode neutral lowercase utf-8
+
+\def\XML at utfeight{utf-8}
+\edef\XML at utfeight{\expandafter\strip at prefix\meaning\XML at utfeight}
+
+%% internalise utf8 encoding as needed before every file include.
+\begingroup
+\catcode`\~13
+\catcode`\"12
+\catcode`\<12
+
+\gdef\utfeightloop{
+  \uccode`\~\count@
+  \expandafter\uppercase\XML at tempa
+  \advance\count@\@ne
+  \ifnum\count@<\@tempcnta
+  \expandafter\utfeightloop
+  \fi}
+
+\gdef\XML at setutfeight{
+  \ifx\XML at utfeight\XML at thisencoding
+  \else
+    \let\XML at thisencoding\XML at utfeight
+    \XML at trace@warnNI{Encoding = \XML at thisencoding}
+%
+    \begingroup
+%
+    \count@"C2
+    \@tempcnta"E0
+    \gdef\XML at tempa{{
+      \xdef~####1{\noexpand\utfeightb\string~####1}}}
+    \utfeightloop
+%
+    \count@"E0
+    \@tempcnta"F0
+    \gdef\XML at tempa{{
+      \xdef~####1####2{\noexpand\utfeightc\string~####1####2}}}
+    \utfeightloop
+%
+    \@tempcnta"F4
+    \gdef\XML at tempa{{
+      \xdef~####1####2####3{\noexpand\utfeightd\string~####1####2####3}}}
+    \utfeightloop
+%
+    \endgroup
+  \fi}
+
+\endgroup
+
+
+\def\xmlinput#1{
+ \IfFileExists{#1}
+  {\expandafter\XML at xmlinput\expandafter
+    \XML at setenc\expandafter{\XML at thisencoding}\relax
+  }{\XML at warn{No file: #1}}}
+
+\def\XML at xmlinput{
+  \def^^ff^^fe{\XML at setenc{utf-16}\relax}
+  \def^^fe^^ff{\XML at setenc{utf-16}\relax}
+% in principle a parsed entity might just be text with no markup
+% but the utf16 is so broken anyway don't worry about that.
+  \let<\XML at first@lt
+  \XML at setutfeight
+  \@@input\@filef at und\relax}
+
+%%%%%%%%%%%%%
+
+%% declarations
+% made safe against active chars.
+% #1 = rest of if test
+% #2#3 = first two characters after <!
+\def\XML at getdecl#1\@#2#3{
+\fi\fi
+  \if-\noexpand#2\XML at comment     %   --
+  \else\if N\noexpand#3\XML at entity%   EN TITY
+  \else\if L\noexpand#3\XML at dec@e%    EL EMENT
+  \else\if A\noexpand#2\XML at dec@a%    AT TLIST
+  \else\if D\noexpand#2\XML at doctype%  DO CTYPE
+  \else\if C\noexpand#3\XML at cdata%    [C DATA 
+  \else        \XML at dec@n%            NO TATION
+%                                      could also pick up [IGNORE/[INCLUDE
+%                                      but they not allowed in internal subset.
+@}
+
+%% Just skip element declarations
+% #1 = rest of \if
+% #2 ELEMENT declaration
+\def\XML at dec@e#1@#2>{
+  \fi\fi\fi
+  \XML at checkend@subset}
+
+
+% attribute declarations
+% #1 = rest of if test + TLIST
+% #2 = element name
+\def\XML at dec@a#1 #2 {
+  \fi\fi\fi\fi
+  \protected at xdef\XML at tempa{#2}
+  \XML at dec@a at x}
+
+\gdef\XML at dec@a at x#1 #2{
+  \protected at xdef\XML at tempb{#1}
+   \if(\noexpand#2
+     \begingroup
+     \catcode`\(\active
+     \expandafter\XML at dec@a at brack
+   \else
+      \expandafter\XML at dec@a at type
+   \fi}
+
+\begingroup
+\catcode`\(\active
+
+% #1 = enumerated attribute type tokens, up to )
+\gdef\XML at dec@a at brack#1){
+  \endgroup
+  \XML at dec@a at hash}
+
+\endgroup
+
+% #1 = junk up to next space token
+\def\XML at dec@a at type#1 {
+  \XML at dec@a at hash}
+
+\begingroup
+\catcode`\$=\catcode`\#
+\catcode`\#=12
+
+% #1 = nextchar after space, if it is # step to next space
+% otherwise look for possible " or ' or >
+\gdef\XML at dec@a at hash$1{
+  \if\noexpand$1#
+    \expandafter\XML at dec@a at type
+  \else
+    \ifx$1>
+      \let\ERROR\@undefined
+      \expandafter\expandafter\expandafter\XML at checkend@subset
+    \else
+      \let\ERROR\XML at dec@a at nodef
+      \XML at dec@a at def$1
+    \fi
+  \fi}
+
+
+\endgroup
+
+\gdef\XML at dec@a at nodef#1\fi\fi#2{
+  \fi\fi
+  \XML at dec@a at x#1}
+
+
+\def\XML at dec@a at def#1\fi\fi{
+ \fi\fi
+  \XML at quoted\XML at dec@a at default#1}
+
+\def\XML at dec@a at default#1#2{
+  \XML at warn{Default: \XML at tempa\space\XML at tempb="#1"}
+  \ifx\XML at default@attributes\relax
+    \let\XML at default@attributes\@empty
+  \fi
+  \toks@\expandafter{\XML at default@attributes}
+  \protected at xdef\XML at default@attributes{
+    \the\toks@\noexpand\XML at add@attrib{\XML at tempa}{\XML at tempb}{#1}}
+% reusing this wastes some tests but only done in local subset
+  \XML at dec@a at hash#2
+  }
+
+
+\let\XML at default@attributes\relax
+
+% this comparison is encoding normalised, but namespace unaware, grr.
+\def\XML at add@attrib#1#2#3{
+  \gdef\XML at tempa{#1}
+  \ifx\XML at tempa\begintag
+   \def\XML at this@attribute{#2}
+% stop  getattrib looking for nexted xml syntax attribute setting.
+    \let\XML at getattrib\relax
+    \XML at attribval{#3}
+    \let\XML at getattrib\XML@@getattrib
+  \fi}
+
+%% comment
+%  - is active
+% #1 = rest of if test
+% #2 = comment text
+\begingroup
+\catcode`\-\active
+\uppercase{\endgroup
+\def\XML at comment#1@#2-->}{
+  \fi
+  \catcode`\^^M\active
+  \catcode`\^^I\active
+  \catcode`\ \active
+  \XML at trace@warn{\string<!-- -->}
+  \XML at comment@}
+
+\def\XML at comment@{
+  \XML at checkend@subset}
+
+\def\XML at grabcomment@{
+  \XMLgrab@}
+
+%% entity defs
+
+% #1 = rest of \if test + TITY
+% #2 = % or entity name
+\begingroup
+\catcode`\&=12
+\catcode`\%=13
+
+\gdef\XML at entity#1 #2 {
+  \fi\fi
+  \ifx%#2
+  \def\XML at input{
+    \ifx\XML at use\XML at SYSTEM\expandafter\@gobble\else
+      \noexpand\inputonce\fi}
+  \expandafter\XML at p@ent
+  \else
+  \def\XML at input{\noexpand\xmlinput}
+  {\utfeight at protect@chars\xdef\XML at ename{&#2}}
+  \XML at trace@warn{\XML at ename; = }
+  \expandafter\XML at ent
+   \fi}
+
+\endgroup
+
+% input some file at most once (and ignore arguments that
+% expand to empty)
+% done in a local group
+\def\inputonce#1{
+  \expandafter\ifx\csname xmt:#1\endcsname\relax
+  \global\expandafter\let\csname xmt:#1\endcsname\@ne
+  \begingroup
+  \XML at reset
+% package files should have their own namespace declarations
+% don't want to inherit from some random point when file is loaded.
+% in principle should clear all prefix assignments in local scope
+% but I don't currently maintain a list of those, and not needed as long
+% as package files declare all prefixes used. But do set the default
+% namespace back to the null namespace.
+%
+% should force utf-8 as well.
+  \def\XMLNS@{0}
+  \input{#1}
+  \endgroup
+  \fi}
+
+% ignore include of empty filename
+\expandafter\let\csname xmt:\endcsname\@ne
+
+% \noexpand protect against active ascii
+\begingroup
+\catcode`\%12 
+\gdef\XML at p@ent#1 #2{
+  {\utfeight at protect@chars\xdef\XML at ename{%#1}}
+  \XML at trace@warn{\XML at ename; = }
+  \if\noexpand#2P\XML at E@public
+  \else\if\noexpand#2S\XML at E@system
+   \else\XML at E@internal#2}
+\endgroup
+
+% #1 = next char( P or S for external entities)
+\def\XML at ent#1{
+  \if\noexpand#1P\XML at E@public
+  \else\if\noexpand#1S\XML at E@system
+   \else\XML at E@internal#1}
+
+
+\begingroup
+\catcode`\:\active
+
+% special `prefix' that just removes following colon.
+\expandafter\gdef\csname XMLNS@*\endcsname#1{}
+
+\endgroup
+
+\begingroup
+\catcode`\:=12
+
+%#1 = " or '
+\gdef\XML at E@internal#1{
+  \fi\fi
+  \begingroup
+  \let\XML at trace@warn\@gobble
+  \let\XML at endgroup\endgroup
+  \let\XML at begingroup\begingroup
+% make " or ' close the grab `element'. the nameless close tag is completed
+% by the > coming from the ENTITY declaration syntax.
+% Using a mangled grab code is a bit complicated but it allows
+% catcode 10 simplification in the normal case of element handling
+% and allows characters to be correctly normalised to utf8.
+  \def#1{</}
+  \expandafter\def\csname
+      E\string/:\endcsname{
+    \afterassignment\XML at E@internal at x
+    \expandafter\gdef\csname+\XML at ename\endcsname}
+  \begingroup
+% stop xmlns `attribute' being recognised
+  \let\XML at ns@decl\relax
+  \let\XML at this@local\@empty
+% set up special prefix to gobble colon
+  \def\XML at this@prefix{*}
+% disable these as nothing will be known until namespaces reenabled
+  \let\XML at checkknown\relax
+  \let\XML at attrib@trace\relax
+% hobble namespace code to put all name in local part.
+  \def\XML at ns##1{
+    \protected at edef\XML at this@local{##1}
+    \def\XML at this@prefix{*}}
+  \xmlgrab}
+
+\endgroup
+
+% expandafter away an \else clause in grabelement then check for ]
+\def\XML at E@internal at x{
+   \endgroup
+    \aftergroup\XML at trace@warn
+    \expandafter\aftergroup\csname+\XML at ename\endcsname
+\aftergroup\fihack
+}
+
+% this hack has to undo the one above moarked by
+%   % \XMLstring usage means catcode restoring varies
+% must fix this as well one day
+\def\fihack#1\fi{\expandafter\XML at checkend@subset}
+
+% need to add (somewhere) a replacement of " to &quot; so that
+% xxx='a"b"c'  doesn't end up as xxx="a"b"c"
+% #1 replacement text
+% #2 white space and  >
+\begingroup
+\uccode`\~`\#
+\catcode`\~\active
+\uppercase{\endgroup
+\def\XML at E@internal@#1#2>{
+   \expandafter\protected at xdef\csname+\XML at ename\endcsname{#1}
+   \XML at trace@warn{\@spaces\string"#1\string"}
+  \XML at checkend@subset}}
+
+%% check for ]> that ends internal subset
+\begingroup
+\catcode`\]\active
+
+
+% #1 is next token in local subset (normally < or >)
+% after subset finishes % stops being markup, and the package
+% relating to any external entity in the doctype is loaded.
+\gdef\XML at checkend@subset{
+  \catcode`\^^M10
+  \catcode`\^^I10
+  \catcode`\ 10 %
+  \XML at checkend@subset@}
+
+% #1 = next character
+\catcode`\%\active
+\gdef\XML at checkend@subset@#1#2#3#4{
+  \ifx]#1
+  \let\XML at w@\@empty
+  \XML at trace@warn{]}
+  \gdef%{\utfeightay%}
+  \let\XML at checkend@subset\relax
+  \expandafter\XML at loaddoctype
+  \fi
+  #1#2#3#4}
+
+\endgroup
+
+%% #1#2 just gobble ]>
+\def\XML at loaddoctype#1#2{
+  \catcode`\^^M\active
+  \catcode`\^^I\active
+  \catcode`\ \active
+  \ifx\XML at D@dtd\relax\else 
+    \XML at trace@warn{Doctype Package: \XML at D@dtd}
+    \inputonce\XML at D@dtd
+  \fi}
+
+
+% #1 = rest of \if test + PUBLIC
+\def\XML at E@public#1 {
+   \fi
+   \XML at quoted\XML at E@pubid}
+
+% #1 = FPI
+\def\XML at E@pubid#1{
+  \def\XML at PUBLIC{#1}
+  \edef\XML at PUBLIC{\expandafter\strip at prefix\meaning\XML at PUBLIC}
+  \XML at quoted\XML at E@systemid}
+
+% #1 = rest of if test up to SYSTEM
+\def\XML at E@system#1 {
+   \fi\fi
+   \def\XML at PUBLIC{}
+   \XML at quoted\XML at E@systemid}
+
+
+% #1 URL
+% #2 next token, N or >
+\def\XML at E@systemid#1#2{
+  \def\XML at SYSTEM{#1}
+  \let\XML at use\XML at SYSTEM
+  \XML at trace@warn{\@spaces Public: \XML at PUBLIC}
+  \XML at trace@warn{\@spaces System: \XML at SYSTEM}
+  \the\XML at catalogue
+  \if\noexpand#2N
+   \expandafter\XML at E@ndata
+  \else
+    \afterfi
+    \XML at E@internal@{\XML at input{\XML at use}}#2
+  \fi}
+  
+
+% NDATA token terminated by > or white space
+% #1 = DATA
+% #2 ndata token with possible extra space
+\def\XML at E@ndata#1 #2>{\XML at ndata@#2 >}
+
+% #1 = ndata toke
+% #2 = junk
+\def\XML at ndata@#1 #2>{
+    \XML at E@internal@{{#1}{\XML at use}}>}
+
+
+%% DOCTYPE
+% #1 rest of \if test + OCTYPE
+% #2 document element name
+% #3 P or S or [ or >
+% noexpand for P and S, [ assumed active
+
+\begingroup
+\catcode`\[\active
+
+\gdef\XML at doctype#1 #2 #3{
+ \fi\fi\fi\fi\fi
+  \def\documentelement{#2}
+  \let\XML at D@dtd\relax
+  \XML at trace@warn{Document Element: \documentelement}
+  \if\noexpand#3P\XML at D@public
+  \else\if\noexpand#3S\XML at D@system
+  \else\ifx#3[\XML at D@internal
+  \else%must be > the end
+    \XML at D@empty
+  @}
+
+
+\gdef\XML at D@empty @{
+   \fi\fi\fi}
+
+% #1 = rest of \if test + UBLIC
+\gdef\XML at D@public#1 {
+   \fi
+   \XML at quoted\XML at pubid}
+
+% #1 = FPI
+\gdef\XML at pubid#1{
+  \def\XML at PUBLIC{#1}
+  \edef\XML at PUBLIC{\expandafter\strip at prefix\meaning\XML at PUBLIC}
+  \XML at quoted\XML at systemid}
+
+
+% #1 = rest of \if test + YSTEM
+\gdef\XML at D@system#1 {
+   \fi\fi
+   \def\XML at PUBLIC{}
+   \XML at quoted\XML at systemid}
+
+% #1 = URI
+\gdef\XML at systemid#1{
+  \protected at edef\XML at SYSTEM{#1}
+  \edef\XML at SYSTEM{\expandafter\strip at prefix\meaning\XML at SYSTEM}
+  \XML at trace@warn{Doctype Public: \XML at PUBLIC}
+  \XML at trace@warn{Doctype System: \XML at SYSTEM}
+  \let\XML at use\@empty
+  \the\XML at catalogue
+  \let\XML at D@dtd\XML at use
+  \XML at D@internal@}
+
+% #1 = rest of if test
+\gdef\XML at D@internal#1@{
+  \fi\fi\fi
+  \XML at D@internal@[}
+
+% #1 = [ for local subset or > for the end.
+\catcode`\%\active
+\gdef\XML at D@internal@#1{
+  \ifx[#1
+    \XML at trace@warn{Internal Subset[}
+    \let%\XML at pcent
+    \edef\XML at w@{ \XML at w@}
+     \expandafter\XML at checkend@subset
+  \else
+      | it had better be the closing >
+   \fi}
+
+\endgroup
+
+
+%%%%%%%%%%%%%%%
+%% catalogue support
+\newtoks\XML at catalogue
+
+%% should rationalise this code
+
+% #1 = FPI
+% #2 = xmltex package file
+\def\PUBLIC#1#2{
+ \xdef\XML at tempa{#1}
+ \xdef\XML at tempa{\noexpand\the\XML at catalogue\noexpand\XML@@PUBLIC
+             {\expandafter\strip at prefix\meaning\XML at tempa}}
+ \global\XML at catalogue\expandafter\expandafter\expandafter{
+   \XML at tempa{#2}}}
+
+
+% #1 = URI
+% #2 = xmltex package file
+\def\SYSTEM#1#2{
+ \xdef\XML at tempa{#1}
+ \xdef\XML at tempa{\noexpand\the\XML at catalogue\noexpand\XML@@SYSTEM
+             {\expandafter\strip at prefix\meaning\XML at tempa}}
+ \global\XML at catalogue\expandafter\expandafter\expandafter{
+   \XML at tempa{#2}}}
+
+% #1 = namespace URI
+% #2 = xmltex package file
+\def\NAMESPACE#1#2{
+  \utfeight at protect@chars
+  \XML at ns@alloc{#1}
+  \edef\@tempa{{\csname XML:#1\endcsname}}
+  \global\XML at catalogue\expandafter{\the\expandafter\XML at catalogue
+     \expandafter\XML@@NAMESPACE\@tempa{#2}}
+  \unprotect at utfeight}
+
+
+% #1 = unprefixed element name
+% #2 = xmltex package file
+\def\NAME#1#2{
+ \global\XML at catalogue\expandafter{\the\XML at catalogue\XML@@NAME{#1}{#2}}}
+
+% #1 = unprefixed element name
+% #2 = namespace URI
+\def\XMLNS#1#2{
+  \utfeight at protect@chars
+  \XML at ns@alloc{#2}
+  \edef\@tempa{{#1}{\csname XML:#2\endcsname}}
+  \global\XML at catalogue\expandafter{\the\expandafter\XML at catalogue
+     \expandafter\XML@@XMLNS\@tempa}
+  \unprotect at utfeight}
+
+
+
+\def\XML@@PUBLIC#1#2{
+ \gdef\XML at tempa{#1}
+  \ifx\XML at tempa\XML at PUBLIC
+    \def\XML at use{#2}
+  \fi}
+
+\def\XML@@SYSTEM#1#2{
+  \def\@tempa{#1}
+  \ifx\@tempa\XML at SYSTEM
+    \def\XML at use{#2}
+  \fi}
+
+\def\XML@@NAMESPACE#1#2{
+  \def\@tempa{#1}
+  \ifx\@tempa\XML at NAMESPACE
+    \def\XML at use{#2}
+  \fi}
+
+
+\def\XML@@NAME#1#2{
+  \def\@tempa{#1}
+  \ifx\@tempa\XML at NAME
+    \def\XML at use{#2}
+  \fi}
+
+
+
+\begingroup
+\catcode`\:\active
+
+\def\XML@@XMLNS#1#2{
+  \def\@tempa{#1}
+  \ifx\@tempa\XML at NAME
+    \edef\XMLNS@{#2}
+    \edef\XML at this@element{
+      \XMLNS@\noexpand:\XML at this@local}
+    \XML at trace@warn{ \XML at this@element}
+    \let\XML at NAMESPACE\XMLNS@
+  \fi}
+\endgroup
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% entity refs
+\begingroup
+\catcode`\$=\catcode`\#
+\catcode`\#=\active
+
+\gdef\XML at amp@markup$1$2;{
+  \ifx#$1\@empty
+   \XML at charref$2;
+   \XML at tempa
+  \else
+   \begingroup\utfeight at protect@chars
+   \expandafter\aftergroup
+   \csname+\string&$1$2\expandafter\endcsname
+   \endgroup
+  \fi}
+
+\endgroup
+
+\let&\XML at amp@markup
+
+\begingroup
+\catcode`\%=12
+\catcode`\&=12
+
+\gdef\XML at pcent#1;{
+  \csname+%#1\endcsname
+  \XML at checkend@subset}
+
+\gdef\XMLentity#1#2{
+  \expandafter\gdef\csname+&#1\endcsname{#2}}
+
+\endgroup
+
+% predefined definitions
+\begingroup
+\XMLentity{amp}{\utfeightaz&}
+\XMLentity{quot}{\utfeightax"}
+\XMLentity{apos}{\utfeightax'}
+\XMLentity{lt}{\utfeightaz<}
+\XMLentity{gt}{\utfeightax>}
+\endgroup
+
+%% character refs
+
+% longwinded way so can share code later, also need to do d case.
+% this does up to x1F FFFF which is higher than needed for XML
+% (x10 FFFF)
+\begingroup
+\catcode`\"=12
+\catcode`\<=12
+\catcode`\.=12
+\catcode`\,=12
+\catcode`\;=12
+\catcode`\!=12
+\catcode`\~=13
+
+% definition is of form 
+% \utfeightX <non active char>+
+% except for non active chars below 128 which are just def of catcode 12 version.
+\gdef\XML at charref#1#2;{
+  \begingroup
+  \uppercase{\count@\if x\noexpand#1"\else#1\fi#2}\relax
+  \ifnum\count@<"80\relax
+    \uccode`\~\count@
+    \uppercase{
+    \ifnum\catcode\count@=\active
+      \gdef\XML at tempa{\utfeightay~}
+    \else
+      \gdef\XML at tempa{~}
+    \fi}
+  \else\ifnum\count@<"800\relax
+     \XML at utfeight@a,
+     \XML at utfeight@b C\utfeightb.,
+  \else\ifnum\count@<"10000\relax
+     \XML at utfeight@a;
+     \XML at utfeight@a,
+     \XML at utfeight@b E\utfeightc.{,;}
+   \else
+     \XML at utfeight@a;
+     \XML at utfeight@a,
+     \XML at utfeight@a!
+     \XML at utfeight@b F\utfeightd.{!,;}
+    \fi
+    \fi
+  \fi
+  \endgroup}
+
+% while I support mixed tex/xml files I need to have a version
+% of &#123; that always fetches the definition even if
+% character is currently non active
+\global\let\XML@@charref\XML at charref
+
+
+\gdef\XML at charref@tex#1#2;{
+  \begingroup
+  \uppercase{\count@\if x\noexpand#1"\else#1\fi#2}\relax
+  \ifnum\count@<"80\relax
+    \uccode`\~\count@
+    \uppercase{
+      \gdef\XML at tempa{\utfeightay~}}
+  \else\ifnum\count@<"800\relax
+     \XML at utfeight@a,
+     \XML at utfeight@b C\utfeightb.,
+  \else\ifnum\count@<"10000\relax
+     \XML at utfeight@a;
+     \XML at utfeight@a,
+     \XML at utfeight@b E\utfeightc.{,;}
+   \else
+     \XML at utfeight@a;
+     \XML at utfeight@a,
+     \XML at utfeight@a!
+     \XML at utfeight@b F\utfeightd.{!,;}
+    \fi
+    \fi
+  \fi
+  \endgroup}
+
+\gdef\XML at utfeight@a#1{
+     \@tempcnta\count@
+     \divide\count at 64
+     \@tempcntb\count@
+     \multiply\count at 64
+     \advance\@tempcnta-\count@
+     \advance\@tempcnta"80
+     \uccode`#1\@tempcnta
+     \count@\@tempcntb}
+
+\gdef\XML at utfeight@b#1#2#3#4{
+     \advance\count@"#10\relax
+     \uccode`#3\count@
+     \uppercase{\gdef\XML at tempa{#2#3#4}}}
+
+
+%%%%%%%%%%%%%%%%
+
+% #1 unicode slot, either 123 decimal or xA23 hex
+% #2 tex definition of character when used as character data.
+% code for chars below 127 somewhat experimental
+\gdef\UnicodeCharacter#1#2{
+   \begingroup
+% suppress active test in charref
+   \def\active{\catcode\count@}
+   \XML at charref#1;
+   \expandafter\expandafter\expandafter
+   \expandafter\expandafter\expandafter
+   \expandafter
+    \gdef\XML at tempa{#2}
+  \endgroup}
+
+\endgroup
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newtoks\XMLgrabtoks
+
+\def\xmlgrab{
+  \begingroup
+  \global\XMLgrabtoks{}
+  \let\XML at this@level\XML at w@
+  \edef\XML at next@level{ \XML at w@}
+  \let\XML at doelement\XML at grabelement
+  \let\XML at doend\XML at grabend
+  \let\XML at docdata\XML at grabcdata
+  \let\XML at comment@\XML at grabcomment@
+  \let\XML at dopi\XML at grabpi
+  \XMLgrab@}
+
+\def\XMLgrab@{
+  \utfeight at protect@internal
+  \def<{\iffalse{\fi}\XMLgrab@@}
+  \xdef\XML at tempa{\iffalse}\fi}
+
+\def\XMLgrab@@{
+  \global\XMLgrabtoks\expandafter{\the\expandafter\XMLgrabtoks\XML at tempa}
+  \XML at lt@markup}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% cdata
+\begingroup
+\catcode`\[\active
+\catcode`\]\active
+
+% #1 = DATA
+\gdef\XML at cdata #1[{
+ \fi\fi\fi\fi\fi\fi
+  \catcode`\^^M\active
+  \catcode`\^^I\active
+  \catcode`\ \active
+  \XML at cdata@a}
+
+% #1 = CDADA section text
+\gdef\XML at cdata@a#1]]>{
+  \begingroup
+  \XML at trace@warn{CDATA}
+  \edef<{\noexpand\utfeightaz\string<}
+  \edef&{\noexpand\utfeightaz\string&}
+  \XML at docdata{#1}}
+
+\endgroup
+
+% #1 = CDADA section text
+\def\XML at docdata#1{#1\endgroup}
+
+% #1 = CDADA section text
+\def\XML at grabcdata#1{
+  \utfeight at protect@internal
+  \edef<{\noexpand\utfeightaz\string<}
+  \edef&{\noexpand\utfeightaz\string&}
+  \xdef\XML at tempa{#1}
+  \endgroup
+   \expandafter\XMLgrab@\XML at tempa}
+
+%%%%%%%%%%
+% notation
+
+% parse past the public and system ids
+% in case they contain a >.
+% unlike entities PUBLIC need not have a system id
+% #1 junk
+% #2 notation name
+% #3 PUBLIC or SYSTEM
+\def\XML at dec@n#1N #2 #3 {
+ \fi\fi\fi\fi\fi\fi
+  \XML at trace@warn{NOTATION #2}
+  \XML at quoted\XML at notation
+  }
+
+\def\XML at notation#1#2{
+  \ifx>#2
+   \expandafter\XML at checkend@subset
+  \else
+    \afterfi
+    \XML at quoted\XML at notation#2
+  \fi}
+
+%%%%%%%%
+%% xmt definitions
+
+%% #1 element, may use prefix : using prefixes in current scope
+%% #2 attlist
+%% #3 begin code
+%% #4 end code
+%% if #3 is \xmlgrab, #4 may access the content of the element as #1
+\long\def\XMLelement#1#2#3#4{
+  \XML at ns{#1}
+  \xdef\XML at tempc{:\csname
+    XMLNS@\XML at this@prefix\endcsname:\XML at this@local}
+% attlist
+  \toks@\expandafter{\csname A:\csname
+    XMLNS@\XML at this@prefix\endcsname\endcsname}
+  #2
+  \expandafter\gdef\csname E\XML at tempc\expandafter\endcsname
+  \expandafter{\expandafter\XML at setattributes\expandafter{\the\toks@}#3}
+  \gdef\XML at tempa{#3}
+  \ifx\XML at tempa\XML at xmlgrab
+    \expandafter\gdef\csname E\string/\XML at tempc\endcsname##1
+    {#4}
+  \else
+    \expandafter\gdef\csname E\string/\XML at tempc\endcsname
+    {#4}
+  \fi}
+
+\def\XML at xmlgrab{\xmlgrab}
+
+%% #1 attribute, may use prefix : using prefixes in current scope
+%% #2 macro to access attribute in begin or end code
+%% #3 default
+
+\long\def\XMLattribute#1#2#3{
+  {\def\XMLNS@{0}
+  \XML at ns{#1}
+  \xdef\XML at tempa{\noexpand\XML at attrib
+      \csname XMLNS@\XML at this@prefix\endcsname
+        :\XML at this@local\relax\noexpand#2}}
+  \toks@\expandafter{\the\expandafter\toks@\XML at tempa{#3}}}
+
+\long\def\XMLattributeX#1#2#3{
+  {\def\XMLNS@{0}
+  \XML at ns{#1}
+  \xdef\XML at tempa{\noexpand\XML at attrib
+      \csname XMLNS@\XML at this@prefix\endcsname
+        :\XML at this@local\relax\noexpand#2}}
+  \toks@\expandafter{\the\expandafter\toks@\XML at tempa{#3}\utfeight at chardef#2}}
+
+\def\utfeight at chardef#1{
+\begingroup
+\utfeight at protect@chars
+\xdef\x at temp{#1}
+\endgroup
+\let#1\x at temp}
+
+% version for namespace global attributes, used at top level.
+%% #1 prefix for namespace this is for.  using prefixes in current scope
+%% #2 attribute, may use prefix : using prefixes in current scope
+%% #3 macro to access attribute in begin or end code
+%% #4 default
+
+\long\def\XMLnamespaceattribute#1#2#3#4{
+   \toks@\expandafter\expandafter\expandafter{\csname A:\csname
+    XMLNS@#1\endcsname\endcsname}
+  \XMLattribute{#2}{#3}{#4}
+  \expandafter\xdef\csname A:\csname
+    XMLNS@#1\endcsname\endcsname{\the\toks@}}
+   
+\long\def\XMLnamespaceattributeX#1#2#3#4{
+   \toks@\expandafter\expandafter\expandafter{\csname A:\csname
+    XMLNS@#1\endcsname\endcsname}
+  \XMLattributeX{#2}{#3}{#4}
+  \expandafter\xdef\csname A:\csname
+    XMLNS@#1\endcsname\endcsname{\the\toks@}}
+   
+
+
+%% #1 QName, may use prefix : using prefixes in current scope
+%% #2 macro to access attribute in begin or end code
+\begingroup
+\catcode`\:\active
+
+\long\gdef\XMLname#1#2{{
+  \XML at ns{#1}
+  \xdef#2{
+      \csname XMLNS@\XML at this@prefix\endcsname
+        \noexpand:\XML at this@local}}}
+\endgroup
+
+\begingroup
+\catcode`\<=12
+\catcode`\>=12
+\catcode`\:=12
+\catcode`\/=12
+
+\gdef\XMLstring#1#2<>{
+  \begingroup
+  \let\XML at endgroup\endgroup
+  \let\XML at this@local\@empty
+  \let\XML at this@prefix\@empty
+  \expandafter\def\csname
+      E/:\XMLNS@:\endcsname{
+    \gdef#1}
+  \XML at catcodes
+  \xmlgrab}
+
+\gdef\XMLstringX#1#2<>{
+  \begingroup
+  \let\XML at endgroup\endgroup
+  \let\XML at this@local\@empty
+  \let\XML at this@prefix\@empty
+  \expandafter\def\csname
+      E/:\XMLNS@:\endcsname{
+    \xdef#1}
+  \XML at catcodes
+  \utfeight at protect@chars
+  \xmlgrab}
+
+\endgroup
+
+%% #1 name
+%% #2 code, gets data as #1
+\long\def\XMLProcessInstruction#1#2{
+  \expandafter\gdef\csname P:#1\endcsname##1{#2}}
+
+%%%%%%%%%%%
+%% xmltex format support
+\everyjob\expandafter{\the\everyjob
+  \immediate\write20{xmltex version: \xmltexversion:}
+\def^^ff^^fe{\XML at setenc{utf-16}\relax}
+\def^^fe^^ff{\XML at setenc{utf-16}\relax}
+\ActivateASCII{45}% -
+\UnicodeCharacter{45}{-\kern\z@}
+\let<\XML at first@lt
+  \IfFileExists{xmltex.cfg}
+  {\begingroup
+  \XML at reset
+  \@@input\@filef at und
+  \endgroup}{\XML at warn{No File: xmltex.cfg}}
+  \IfFileExists{\jobname.cfg}
+  {\begingroup
+  \XML at reset
+  \@@input\@filef at und
+  \endgroup}{\XML at warn{No File: \jobname.cfg}}
+}
+
+
+%%%%%%%%%%%
+%% not currently used
+%
+%\def\XML at setlatexcodes{
+%\ifnum\catcode`\&\active
+%  \let\XML at restore\XML at catcodes
+%  \let\XML at setlatexcodes\relax
+%\fi}
+%
+%\let\XML at restore\relax
+
+
+%% allow package and class loading with normal latex catcodes
+
+
+\def\@fileswith at pti@ns#1[#2]#3[#4]{
+  \XML at reset
+  \catcode`\^^M5 %
+  \let\@fileswith at pti@ns\@@fileswith at pti@ns
+  \@@fileswith at pti@ns{#1}[{#2}]{#3}[{#4}]
+  \XML at catcodes
+  \let\@fileswith at pti@ns\XML@@fileswith at pti@ns}
+
+\let\XML@@fileswith at pti@ns\@fileswith at pti@ns
+
+
+
+% and similar for input of aux files
+\def\@input#1{
+  \XML at reset
+  \catcode`\^^I\active
+  \catcode`\<\active
+  \catcode`\>\active
+  \catcode`\&\active
+  \catcode`\#\active
+  \catcode`\/\active
+  \catcode`\:\active
+  \catcode`\=\active
+  \let\XML at charref\XML at charref@tex
+  \IfFileExists{#1}{\@@input\@filef at und}{\typeout{No file #1.}}
+  \XML at catcodes
+  \let\XML at charref\XML@@charref
+}
+
+% and end doc
+\def\enddocument{
+   \@enddocumenthook
+   \@checkend{document}
+   \clearpage
+   \begingroup
+     \if at filesw
+       \immediate\closeout\@mainaux
+       \let\@setckpt\@gobbletwo
+       \let\@newl at bel\@testdef
+       \@tempswafalse
+\XML at reset
+  \catcode`\^^I\active
+  \catcode`\<\active
+  \catcode`\>\active
+  \catcode`\&\active
+  \catcode`\#\active
+  \catcode`\/\active
+  \catcode`\:\active
+  \catcode`\=\active
+  \let\XML at charref\XML at charref@tex
+       \makeatletter \input\jobname.aux
+     \fi
+     \@dofilelist
+     \ifdim \font at submax \string>\fontsubfuzz\relax
+       \@font at warning{Size substitutions with differences\MessageBreak
+                  up to \font at submax\space have occured.\@gobbletwo}
+     \fi
+     \@defaultsubs
+     \@refundefined
+     \if at filesw
+       \ifx \@multiplelabels \relax
+         \if at tempswa
+           \@latex at warning@no at line{Label(s) may have changed.
+               Rerun to get cross-references right}
+         \fi
+       \else
+         \@multiplelabels
+       \fi
+     \fi
+   \endgroup
+   \deadcycles\z@\@@end}
+
+
+%% protected write
+\long\def \protected at write#1#2#3{
+      \begingroup
+       \let\thepage\relax
+       #2
+       \utfeight at protect@external
+       \let\protect\@unexpandable at protect
+       \edef\reserved at a{\write#1{#3}}
+       \reserved at a
+      \endgroup
+      \if at nobreak\ifvmode\nobreak\fi\fi
+}
+
+
+%% typeout etc
+\def\set at display@protect{
+  \let\protect\string
+  \utfeight at protect@typeout}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% xmltex namespace 
+\expandafter\def\csname
+  XML:http://www.dcarlisle.demon.co.uk/xmltex\endcsname{2}
+\expandafter\let\csname A:2\endcsname\@empty
+\expandafter\gdef\csname XMLNS at 2\endcsname{2}
+\XML at ns@count2
+
+\iffalse
+% this is some currently used code aiming at having an aux file
+% in xml syntax using commands from the xmltex namespace.
+% this would avoid some of the problems involved in having
+% mixed xml/tex aux files.
+\def\addcontentsline#1#2#3{
+  \addtocontents{#1}{
+  <2:contentsline level="#2">
+   <2:toctitle>#3</2:toctitle>
+   <2:page>\thepage</2:page>
+  </2:contentsline>}}
+
+\long\def\addtocontents#1#2{
+  \protected at write\@auxout
+      {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}
+      {<2:@writefile ext="#1">#2</2:@writefile>}}
+
+\def\numberline#1{<2:numberline>#1</2:numberline>}
+
+\fi
+% end of xml-aux code.
+
+%%%%%%%%%%%%%%%%%%
+% tracing
+\long\def\@gobble#1{}
+\long\def\@gobbletwo#1#2{}
+\long\def\@gobblethree#1#2#3{}
+
+\def\xmltraceonly{
+  \global\hfuzz\maxdimen
+  \global\nullfont
+  \global\everypar{}
+  \global\let\XML at doelement\relax
+  \global\let\wrong at fontshape\relax
+  \global\let\selectfont\relax
+  \expandafter\gdef\expandafter\XML at catcodes\expandafter{\XML at catcodes
+ \gdef\unprotect at utfeight{
+  \let<\XML at lt@markup
+  \let&\XML at amp@markup
+  \global\let\utfeightax\@gobble
+  \global\let\utfeightay\@gobble
+  \global\let\utfeightaz\@gobble
+  \global\let\utfeightb\@gobbletwo
+  \global\let\utfeightc\@gobblethree
+  \global\let\utfeightd\@gobblefour}
+  \unprotect at utfeight}
+  \gdef\XML at doend{\XML at endgroup}
+  \gdef\XML at docdata##1{\endgroup}
+  \global\let\XML at dopi\@gobbletwo
+}
+
+\def\xmltraceoff{
+  \global\let\XML at trace@warn\@gobble
+  \global\let\XML at trace@warnNI\@gobble
+  \global\let\XML at trace@warnE\@gobble
+  \global\let\XML at attrib@trace\relax}
+
+
+%%%%%
+%% xmltex PI
+%% <?xmltex tracingall ?>
+%% <?xmltex typeout {hello world!} ?>
+%% content of pi may be a latex command.
+%% Arguments may be given in {} as usual
+%% Do not use \ . First `word' (ignoring white space) taken as a tex
+%% command name. May be a standard latex command, as here,
+%% or some special command defined in a cfg file or package.
+\begingroup
+\catcode`[=1
+\catcode`]=2
+\catcode`\{\active
+\catcode`\}\active
+\XMLProcessInstruction[xmltex][
+  \XML at pi#1{\relax}]
+
+\gdef\XML at pi#1{#2}[
+  \ifx\relax#2
+   \csname\zap at space#1 \@empty\expandafter\endcsname
+  \else
+   \afterfi
+   \expandafter
+      \XML at pi@b\csname\zap at space#1 \@empty\endcsname[#2]
+  \fi]
+
+\gdef\XML at pi@b#1{#2}[
+  \ifx\relax#2
+   #1
+  \else
+   \afterfi
+   \XML at pi@b#1[#2]
+  \fi]
+
+\endgroup
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%% unicode support
+
+% \utfeighta#1         1 byte utf8 char
+% \utfeightb#1#2       2 byte utf8 char
+% \utfeightc#1#2#3     3 byte utf8 char
+% \utfeightd#1#2#3#4   4 byte utf8 char
+
+\def\unprotect at utfeight{
+  \let<\XML at lt@markup
+  \let&\XML at amp@markup
+  \def\utfeightax##1{
+    \csname 8:\string##1\endcsname}
+  \let\utfeightay\utfeightax
+  \let\utfeightaz\utfeightax
+  \def\utfeightb##1##2{
+    \csname 8:##1\string##2\endcsname}
+  \def\utfeightc##1##2##3{
+    \csname 8:##1\string##2\string##3\endcsname}
+  \def\utfeightd##1##2##3##4{
+    \csname 8:##1\string##2\string##3\string##4\endcsname}}
+
+\unprotect at utfeight
+
+% do this also in everyjob
+\let<\XML at first@lt
+
+
+% for moving internal arguments  (not writes)
+\def\utfeight at protect@internal{
+  \let\utfeightax\noexpand
+  \let\utfeightay\noexpand
+  \def\utfeightaz{
+    \noexpand\utfeightaz\noexpand}
+  \let<\relax\let&\relax
+  \def\utfeightb##1##2{
+    \noexpand\utfeightb##1\string##2}
+  \def\utfeightc##1##2##3{
+    \noexpand\utfeightc##1\string##2\string##3}
+  \def\utfeightd##1##2##3##4{
+    \noexpand\utfeightd##1\string##2\string##3\string##4}}
+
+
+% for external files (expands one in an edef and once in a write
+\def\utfeight at protect@external{
+  \def\utfeightax{
+    \noexpand\noexpand\noexpand}
+  \let\utfeightay\utfeighta at ref
+  \let\utfeightaz\utfeighta at ref
+  \edef<{\string<}
+  \edef&{\string&}
+  \def\utfeightb##1##2{
+    ##1\string##2}
+  \def\utfeightc##1##2##3{
+    ##1\string##2\string##3}
+  \def\utfeightd##1##2##3##4{
+    ##1\string##2\string##3\string##4}}
+
+% for typeouts and immediate writes and messages
+%\def\utfeight at protect@typeout{
+%  \let\utfeightax\noexpand
+%  \let\utfeightay\noexpand
+%  \let\utfeightaz\utfeighta at ref
+%  \let<\relax\let&\relax
+%  \def\utfeightb##1##2{##1\string##2}
+%  \def\utfeightc##1##2##3{##1\string##2\string##3}
+%  \def\utfeightd##1##2##3##4{##1\string##2\string##3\string##4}}
+
+% plan b
+\def\utfeight at protect@typeout{
+  \utfeight at protect@chars
+  \let<\relax
+  \let&\relax}
+
+% for csname (will fall over < or & but they should not be there)
+\def\utfeight at protect@chars{
+  \let\utfeightax\string
+  \let\utfeightay\string
+  \let\utfeightaz\string
+  \def\utfeightb##1##2{
+    ##1\string##2}
+  \def\utfeightc##1##2##3{
+    ##1\string##2\string##3}
+  \def\utfeightd##1##2##3##4{
+    ##1\string##2\string##3\string##4}}
+
+
+\def\utfeighta at ref#1{
+  \string&\string##\number\expandafter`\string#1\string;}
+
+
+%%%%%%%%%%%%%%%%%%%%
+%% mapping input encodings to unicode.
+
+
+\begingroup
+\catcode`\"=12\relax
+\gdef\InputCharacter#1#2{
+  \begingroup
+   \XML at charref#2;
+   \count@"0\if\noexpand x#1\relax\else\count@#1\fi\relax
+   \uccode`\~\count@
+    \uppercase{
+     \global\let~\XML at tempa}
+  \endgroup}
+\endgroup
+
+%%%%%%%%%%%%%%%%%%%%%%%%
+% default encoding
+
+%% need to change this default if hit BOM or xml or text decl,
+\XML at setutfeight
+
+%%%%%%%%%%%%%%%%%%%%%
+% adding xmltex style protection to standard latex commands.
+% if xmltex being used with other formats this does no harm
+% except take up a bit of space.
+
+\begingroup
+\catcode`\:\active
+\catcode`\/\active
+
+\gdef\markboth#1#2{\gdef\@themark{{#1}{#2}}{
+     \utfeight at protect@internal
+     \let\protect\@unexpandable at protect
+     \let\label\relax \let\index\relax \let\glossary\relax
+     \mark{\@themark}}\if at nobreak\ifvmode\nobreak\fi\fi}
+\gdef\markright#1{{\let\protect\@unexpandable at protect
+     \utfeight at protect@internal
+     \let\label\relax \let\index\relax \let\glossary\relax
+     \expandafter\@markright\@themark
+     {#1}\mark{\@themark}}\if at nobreak\ifvmode\nobreak\fi\fi}
+
+\endgroup
+
+% this one not safe, restore not complete
+\def\protected at edef{
+   \let\@@protect\protect
+   \let\protect\@unexpandable at protect
+   \utfeight at protect@internal
+   \afterassignment\restore at protect
+   \edef
+}
+\def\protected at xdef{
+   \begingroup
+   \utfeight at protect@internal
+   \let\protect\@unexpandable at protect
+   \afterassignment\endgroup
+   \xdef
+}
+\def\unrestored at protected@xdef{
+   \utfeight at protect@internal
+   \let\protect\@unexpandable at protect
+   \xdef
+}
+
+% should really save and restore, not always back to markup
+\def\restore at protect{\let\protect\@@protect
+   \unprotect at utfeight
+}
+
+%%%%% stop this doing damage, also stops it working
+\def\MakeUppercase#1{#1}
+
+
+%%%%%%%%%%%%%%%%%%%%%
+
+% support for making 7bit characters active
+
+\begingroup
+\catcode`\"=12\relax
+\gdef\ActivateASCII#1{
+  \uppercase{\count@"0\if x\noexpand#1\relax\else\count@#1\fi\relax}
+  \toks@\expandafter{\nfss at catcodes}
+       \xdef\nfss at catcodes{
+       \catcode\the\count@=\the\catcode\the\count@\relax\the\toks@}
+  \toks@\expandafter{\XML at catcodes}
+     \xdef\XML at catcodes{
+       \catcode\the\count@\active\the\toks@}
+  \expandafter\ifx\csname8:"\endcsname\relax
+    \expandafter\gdef\csname8:"\endcsname{"}
+  \fi}
+\endgroup
+
+
+% some of these should not be active by default, but OK for now.
+% could use \ActivateASCII for most if not all of these now.
+% should probably use \UnicodeCharacter for these now
+\expandafter\def\csname8:\string<\endcsname{\ifmmode\langle\else\textless\fi}
+\expandafter\def\csname8:\string>\endcsname{\ifmmode\rangle\else\textgreater\fi}
+\expandafter\def\csname8:\string{\endcsname{\{}
+\expandafter\def\csname8:\string}\endcsname{\}}
+
+% activateacii would use ax code, want ay code so ^ not written to aux files
+% and clash with tex usage. so locally lie and make it a letter
+\ActivateASCII{94}% ^ for tex ^^ notation in aux files
+\UnicodeCharacter{94}{\textasciicircum}
+
+
+\ActivateASCII{x5C}% \
+\UnicodeCharacter{x5C}{\textbackslash}
+\ActivateASCII{x5F}% \
+\UnicodeCharacter{x5F}{\textunderscore}
+\ActivateASCII{123}% {
+\ActivateASCII{125}% {
+
+%%%%%%%%%%%%%%%%
+% white space
+
+\UnicodeCharacter{13}{ \ignorespaces}
+\UnicodeCharacter{32}{ \ignorespaces}
+\UnicodeCharacter{9}{ \ignorespaces}
+
+
+\expandafter\def\expandafter\obeylines\expandafter{
+\expandafter\def\csname 8:\string^^M\endcsname{\leavevmode\hfil \break\null}}
+
+\expandafter\def\expandafter\xmlnewlineaction\expandafter{
+\expandafter\def\csname 8:\string^^M\endcsname}
+
+\expandafter\def\expandafter\obeyspaces\expandafter{
+\expandafter\def\csname 8: \endcsname{\nobreakspace}}
+
+% tabs just do whatver the current space does.
+\catcode`\^^I\active
+\expandafter\def\csname 8:\string^^I\expandafter\endcsname
+       \expandafter{\csname 8: \endcsname}
+
+
+% tex conventions
+\XML at reset
+\IfFileExists{xmltex.cfg}
+  {
+  \@@input\expandafter\@filef at und\expandafter\relax
+   \expandafter\XML at setenc\expandafter{\XML at thisencoding}\relax
+  }{\XML at warn{No File: xmltex.cfg}}
+
+
+% get xmltex in catcode 12, for comparing with \jobname
+\gdef\XML at tempa#1>{}
+\gdef\XML at tempb{xmltex}
+\xdef\XML at tempb{\expandafter\XML at tempa\meaning\XML at tempb}
+%
+\gdef\XML at tempc{pdfxmltex}
+\xdef\XML at tempc{\expandafter\XML at tempa\meaning\XML at tempc}
+%
+\xdef\XML at tempa{\lowercase{\gdef\noexpand\XML at tempa{\jobname}}}
+\XML at tempa
+
+
+% if jobname is xmltex or pdfxmltex dump the format, otherwise
+% try to load \jobname.cfg  and input \xmlfile
+% put white space back so the filename can be read off the command line
+\ifx\XML at tempa\XML at tempc
+  \let\XML at tempb\XML at tempc
+\fi
+\ifx\XML at tempa\XML at tempb
+  \def\XML at tempa{
+\catcode`\ =10\relax
+\catcode`\^^M=10\relax
+\catcode`\^^I=10\relax
+\dump}
+\else
+\IfFileExists{\jobname.cfg}
+  {
+  \@@input\expandafter\@filef at und\expandafter\relax
+   \expandafter\XML at setenc\expandafter{\XML at thisencoding}\relax
+  }{\XML at warn{No File: \jobname.cfg}}
+
+
+\ifx\xmlfile\@undefined
+ \def\XML at tempa{\catcode`\-12\relax}
+\else
+  \def\XML at tempa{\catcode`\-12\relax\input\xmlfile\relax}
+\fi
+\fi
+
+\endlinechar`\^^M \expandafter\XML at catcodes\XML at tempa




More information about the debian-xml-sgml-commit mailing list