Starting doing some bulk testing and transformations:
authorDaniel Veillard <veillard@src.gnome.org>
Mon, 5 Feb 2001 18:29:06 +0000 (18:29 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Mon, 5 Feb 2001 18:29:06 +0000 (18:29 +0000)
- FEATURES: updated, added mode support for templates
- pattern.[ch] transform.c xslt.c xsltInternals.h: added mode
  support for templates
- templates.c variables.c: simple fixes
- xslt.c: added a separate DEBUG_BLANKS debug class disabled
- xsltproc.c: added option -timing
- xsltutils.c: seem I forgot to add encoding support in output...
- configure.in tests/Makefile.am tests/xmlspec/*: added a test
  consisting of reformatting the XML REC with the xmlspec XSLT,
  heavy !
Daniel

19 files changed:
ChangeLog
FEATURES
configure.in
libxslt/pattern.c
libxslt/pattern.h
libxslt/templates.c
libxslt/transform.c
libxslt/variables.c
libxslt/xslt.c
libxslt/xsltInternals.h
libxslt/xsltproc.c
libxslt/xsltutils.c
tests/Makefile.am
tests/xmlspec/Makefile.am [new file with mode: 0644]
tests/xmlspec/REC-xml-20001006.xml [new file with mode: 0644]
tests/xmlspec/W3C-REC.css [new file with mode: 0644]
tests/xmlspec/logo-REC [new file with mode: 0644]
tests/xmlspec/xmlspec-v21.dtd [new file with mode: 0644]
tests/xmlspec/xmlspec.xsl [new file with mode: 0644]

index adbec63..82be479 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Mon Feb  5 18:58:17 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * FEATURES: updated, added mode support for templates
+       * pattern.[ch] transform.c xslt.c xsltInternals.h: added mode
+         support for templates
+       * templates.c variables.c: simple fixes
+       * xslt.c: added a separate DEBUG_BLANKS debug class disabled
+       * xsltproc.c: added option -timing
+       * xsltutils.c: seem I forgot to add encoding support in output...
+       * configure.in tests/Makefile.am tests/xmlspec/*: added a test
+         consisting of reformatting the XML REC with the xmlspec XSLT,
+         heavy !
+
 Mon Feb  5 18:43:37 CET 2001 Bjorn Reese <breese@users.sourceforge.net>
 
        * FEATURES: updated
index d14ca3e..35551ad 100644 (file)
--- a/FEATURES
+++ b/FEATURES
@@ -43,7 +43,7 @@ YES                       xsl:template
 YES                            match = pattern 
 YES                            name = qname 
 YES                            priority = number 
-NO                             mode = qname
+YES                            mode = qname
 
 YES                        xsl:namespace-alias
 YES                            stylesheet-prefix = prefix | "#default"
@@ -85,7 +85,7 @@ Instructions:
 
 YES                        xsl:apply-templates
 YES                            select = node-set-expression 
-NO                             mode = qname
+YES                            mode = qname
 
 NO                         xsl:apply-imports
 
index 6ad93ac..3e5122f 100644 (file)
@@ -150,6 +150,7 @@ tests/REC2/Makefile
 tests/REC/Makefile
 tests/general/Makefile
 tests/numbers/Makefile
+tests/xmlspec/Makefile
 doc/Makefile
 xslt-config
 libxslt.spec
index f4203f7..0bf79be 100644 (file)
@@ -24,6 +24,7 @@
 #include "xsltutils.h"
 #include "imports.h"
 #include "templates.h"
+#include "pattern.h"
 
 /* #define DEBUG_PARSING */
 
@@ -63,7 +64,9 @@ typedef struct _xsltCompMatch xsltCompMatch;
 typedef xsltCompMatch *xsltCompMatchPtr;
 struct _xsltCompMatch {
     struct _xsltCompMatch *next; /* siblings in the name hash */
-    float priority;                /* the priority */
+    float priority;              /* the priority */
+    const xmlChar *mode;         /* the mode */
+    const xmlChar *modeURI;      /* the mode URI */
     xsltTemplatePtr template;    /* the associated template */
 
     /* TODO fix the statically allocated size steps[] */
@@ -89,13 +92,15 @@ struct _xsltParserContext {
 
 /**
  * xsltNewCompMatch:
+ * @mode:  the mode name or NULL
+ * @modeURI:  the mode URI or NULL
  *
  * Create a new XSLT CompMatch
  *
  * Returns the newly allocated xsltCompMatchPtr or NULL in case of error
  */
 xsltCompMatchPtr
-xsltNewCompMatch(void) {
+xsltNewCompMatch(const xmlChar *mode, const xmlChar *modeURI) {
     xsltCompMatchPtr cur;
 
     cur = (xsltCompMatchPtr) xmlMalloc(sizeof(xsltCompMatch));
@@ -106,6 +111,8 @@ xsltNewCompMatch(void) {
     }
     memset(cur, 0, sizeof(xsltCompMatch));
     cur->maxStep = 20;
+    cur->mode = xmlStrdup(mode);
+    cur->modeURI = xmlStrdup(modeURI);
     return(cur);
 }
 
@@ -122,6 +129,10 @@ xsltFreeCompMatch(xsltCompMatchPtr comp) {
 
     if (comp == NULL)
        return;
+    if (comp->mode != NULL)
+       xmlFree((xmlChar *)comp->mode);
+    if (comp->modeURI != NULL)
+       xmlFree((xmlChar *)comp->modeURI);
     for (i = 0;i < comp->nbStep;i++) {
        op = &comp->steps[i];
        if (op->value != NULL)
@@ -278,6 +289,8 @@ xsltReverseCompMatch(xsltCompMatchPtr comp) {
  * @ctxt:  a XSLT process context
  * @comp: the precompiled pattern
  * @node: a node
+ * @mode:  the mode name or NULL
+ * @modeURI:  the mode URI or NULL
  *
  * Test wether the node matches the pattern
  *
@@ -285,7 +298,8 @@ xsltReverseCompMatch(xsltCompMatchPtr comp) {
  */
 int
 xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
-                 xmlNodePtr node) {
+                 xmlNodePtr node, const xmlChar *mode,
+                 const xmlChar *modeURI) {
     int i;
     xsltStepOpPtr step, select = NULL;
 
@@ -294,6 +308,25 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
                "xsltTestCompMatch: null arg\n");
         return(-1);
     }
+    if (mode != NULL) {
+       if (comp->mode == NULL)
+           return(0);
+       if ((comp->mode != mode) && (!xmlStrEqual(comp->mode, mode)))
+           return(0);
+    } else {
+       if (comp->mode != NULL)
+           return(0);
+    }
+    if (modeURI != NULL) {
+       if (comp->modeURI == NULL)
+           return(0);
+       if ((comp->modeURI != modeURI) &&
+           (!xmlStrEqual(comp->modeURI, modeURI)))
+           return(0);
+    } else {
+       if (comp->modeURI != NULL)
+           return(0);
+    }
     for (i = 0;i < comp->nbStep;i++) {
        step = &comp->steps[i];
        if (step->op != XSLT_OP_PREDICATE)
@@ -442,6 +475,8 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
                 * Depending on the last selection, one may need to
                 * recompute contextSize and proximityPosition.
                 */
+               oldCS = ctxt->xpathCtxt->contextSize;
+               oldCP = ctxt->xpathCtxt->proximityPosition;
                if ((select != NULL) &&
                    (select->op == XSLT_OP_ELEM) &&
                    (select->value != NULL) &&
@@ -451,8 +486,6 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
                    /* TODO: cache those informations ?!? */
                    xmlNodePtr siblings = node->parent->children;
 
-                   oldCS = ctxt->xpathCtxt->contextSize;
-                   oldCP = ctxt->xpathCtxt->proximityPosition;
                    while (siblings != NULL) {
                        if (siblings->type == XML_ELEMENT_NODE) {
                            if (siblings == node) {
@@ -1046,6 +1079,8 @@ error:
 /**
  * xsltCompilePattern:
  * @pattern an XSLT pattern
+ * @mode:  the mode name or NULL
+ * @modeURI:  the mode URI or NULL
  *
  * Compile the XSLT pattern and generates a precompiled form suitable
  * for fast matching.
@@ -1058,7 +1093,8 @@ error:
  */
 
 xsltCompMatchPtr
-xsltCompilePattern(const xmlChar *pattern) {
+xsltCompilePattern(const xmlChar *pattern, const xmlChar *mode,
+                  const xmlChar *modeURI) {
     xsltParserContextPtr ctxt;
     xsltCompMatchPtr ret;
     const xmlChar *cur;
@@ -1084,7 +1120,7 @@ xsltCompilePattern(const xmlChar *pattern) {
     ctxt = xsltNewParserContext();
     if (ctxt == NULL)
        return(NULL);
-    ret = xsltNewCompMatch();
+    ret = xsltNewCompMatch(mode, modeURI);
     if (ret == NULL) {
        xsltFreeParserContext(ctxt);
        return(NULL);
@@ -1149,14 +1185,17 @@ error:
  * xsltAddTemplate:
  * @style: an XSLT stylesheet
  * @cur: an XSLT template
+ * @mode:  the mode name or NULL
+ * @modeURI:  the mode URI or NULL
  *
  * Register the XSLT pattern associated to @cur
  *
  * Returns -1 in case of error, 0 otherwise
  */
 int
-xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur) {
-    xsltCompMatchPtr pat, list, *top;
+xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
+               const xmlChar *mode, const xmlChar *modeURI) {
+    xsltCompMatchPtr pat, list, *top = NULL;
     const xmlChar *name = NULL;
     xmlChar *p, *pattern, tmp;
 
@@ -1181,7 +1220,7 @@ next_pattern:
 
     tmp = *p;
     *p = 0;
-    pat = xsltCompilePattern(pattern);
+    pat = xsltCompilePattern(pattern, mode, modeURI);
     *p = tmp;
     if (tmp != 0)
        p++;
@@ -1249,7 +1288,7 @@ next_pattern:
     }
     if (name != NULL) {
        if (style->templatesHash == NULL) {
-           style->templatesHash = xmlHashCreate(0);
+           style->templatesHash = xmlHashCreate(1024);
            if (style->templatesHash == NULL) {
                xsltFreeCompMatch(pat);
                return(-1);
@@ -1258,15 +1297,17 @@ next_pattern:
            xsltGenericDebug(xsltGenericDebugContext,
                    "xsltAddTemplate: created template hash\n");
 #endif
-           xmlHashAddEntry(style->templatesHash, name, pat);
+           xmlHashAddEntry3(style->templatesHash, name, mode, modeURI, pat);
 #ifdef DEBUG_PARSING
            xsltGenericDebug(xsltGenericDebugContext,
                    "xsltAddTemplate: added new hash %s\n", name);
 #endif
        } else {
-           list = (xsltCompMatchPtr) xmlHashLookup(style->templatesHash, name);
+           list = (xsltCompMatchPtr) xmlHashLookup3(style->templatesHash,
+                                     name, mode, modeURI);
            if (list == NULL) {
-               xmlHashAddEntry(style->templatesHash, name, pat);
+               xmlHashAddEntry3(style->templatesHash, name,
+                                mode, modeURI, pat);
 #ifdef DEBUG_PARSING
                xsltGenericDebug(xsltGenericDebugContext,
                        "xsltAddTemplate: added new hash %s\n", name);
@@ -1279,7 +1320,8 @@ next_pattern:
                 */
                if (list->priority <= pat->priority) {
                    pat->next = list;
-                   xmlHashUpdateEntry(style->templatesHash, name, pat, NULL);
+                   xmlHashUpdateEntry3(style->templatesHash, name,
+                                       mode, modeURI, pat, NULL);
 #ifdef DEBUG_PARSING
                    xsltGenericDebug(xsltGenericDebugContext,
                            "xsltAddTemplate: added head hash for %s\n", name);
@@ -1326,7 +1368,7 @@ next_pattern:
 /**
  * xsltGetTemplate:
  * @ctxt:  a XSLT process context
- * @node: an XML Node
+ * @mode:  the mode name or NULL
  *
  * Finds the template applying to this node
  *
@@ -1382,10 +1424,12 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node) {
            /*
             * find the list of appliable expressions based on the name
             */
-           list = (xsltCompMatchPtr) xmlHashLookup(style->templatesHash, name);
+           list = (xsltCompMatchPtr) xmlHashLookup3(style->templatesHash,
+                                            name, ctxt->mode, ctxt->modeURI);
        }
        while (list != NULL) {
-           if (xsltTestCompMatch(ctxt, list, node)) {
+           if (xsltTestCompMatch(ctxt, list, node,
+                                 ctxt->mode, ctxt->modeURI)) {
                ret = list->template;
                break;
            }
@@ -1436,7 +1480,8 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node) {
        }
        while ((list != NULL) &&
               ((ret == NULL)  || (list->priority > ret->priority))) {
-           if (xsltTestCompMatch(ctxt, list, node)) {
+           if (xsltTestCompMatch(ctxt, list, node,
+                                 ctxt->mode, ctxt->modeURI)) {
                ret = list->template;
                break;
            }
index 30f9daf..946ff30 100644 (file)
@@ -16,7 +16,9 @@ extern "C" {
 #endif
 
 int            xsltAddTemplate         (xsltStylesheetPtr style,
-                                        xsltTemplatePtr cur);
+                                        xsltTemplatePtr cur,
+                                        const xmlChar *mode,
+                                        const xmlChar *modeURI);
 xsltTemplatePtr        xsltGetTemplate         (xsltTransformContextPtr ctxt,
                                         xmlNodePtr node);
 void           xsltFreeTemplateHashes  (xsltStylesheetPtr style);
index e91bb10..9bc2095 100644 (file)
@@ -55,7 +55,7 @@ xsltEvalXPathPredicate(xsltTransformContextPtr ctxt, const xmlChar *expr) {
     xpathParserCtxt =
        xmlXPathNewParserContext(expr, ctxt->xpathCtxt);
     if (xpathParserCtxt == NULL)
-       return(NULL);
+       return(0);
     ctxt->xpathCtxt->node = ctxt->node;
     xmlXPathEvalExpr(xpathParserCtxt);
     res = valuePop(xpathParserCtxt);
index 73374d9..35ac406 100644 (file)
@@ -646,7 +646,6 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
     if (xpathParserCtxt == NULL)
        goto error;
     ctxt->xpathCtxt->node = node;
-    valuePush(xpathParserCtxt, xmlXPathNewNodeSet(node));
     xmlXPathEvalExpr(xpathParserCtxt);
     res = valuePop(xpathParserCtxt);
     do {
@@ -767,7 +766,6 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
     if (xpathParserCtxt == NULL)
        goto error;
     ctxt->xpathCtxt->node = node;
-    valuePush(xpathParserCtxt, xmlXPathNewNodeSet(node));
     xmlXPathEvalExpr(xpathParserCtxt);
     xmlXPathStringFunction(xpathParserCtxt, 1);
     res = valuePop(xpathParserCtxt);
@@ -906,7 +904,7 @@ xsltNumber(xsltTransformContextPtr ctxt,
     
     prop = xmlGetNsProp(cur, (const xmlChar *)"grouping-size", XSLT_NAMESPACE);
     if (prop != NULL) {
-       sscanf(prop, "%d", &numdata.digitsPerGroup);
+       sscanf((char *)prop, "%d", &numdata.digitsPerGroup);
        xmlFree(prop);
     } else {
        numdata.groupingCharacter = 0;
@@ -969,7 +967,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
                ctxt->node = node;
                xsltApplyOneTemplate(ctxt, node, template->content);
                ctxt->node = oldNode;
-           } else {
+           } else if (ctxt->mode == NULL) {
                copy = xmlCopyNode(node, 0);
                if (copy != NULL) {
                    xmlAddChild(ctxt->insert, copy);
@@ -990,7 +988,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
                    ctxt->node = node;
                    xsltApplyOneTemplate(ctxt, node, template->content);
                    ctxt->node = oldNode;
-               } else {
+               } else if (ctxt->mode == NULL) {
                    if (attr->ns != NULL) {
                        if ((!xmlStrEqual(attr->ns->href, XSLT_NAMESPACE)) &&
                            (xmlStrncasecmp(attr->ns->prefix,
@@ -1105,7 +1103,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
                    ctxt->xpathCtxt->proximityPosition = childno;
                    xsltApplyOneTemplate(ctxt, cur, template->content);
                    ctxt->node = oldNode;
-               } else {
+               } else if (ctxt->mode == NULL) {
                    copy = xmlCopyNode(cur, 0);
                    if (copy != NULL) {
                        xmlAddChild(ctxt->insert, copy);
@@ -1240,6 +1238,8 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
     xmlNodeSetPtr list = NULL, oldlist;
     xmlXPathParserContextPtr xpathParserCtxt = NULL;
     int i, oldProximityPosition, oldContextSize;
+    xmlChar *mode, *modeURI;
+    const xmlChar *oldmode, *oldmodeURI;
 
     if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
        return;
@@ -1248,6 +1248,52 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
     xsltGenericDebug(xsltGenericDebugContext,
         "xsltApplyTemplates: node: %s\n", node->name);
 #endif
+
+    /*
+     * Get mode if any
+     */
+    oldmode = ctxt->mode;
+    oldmodeURI = ctxt->modeURI;
+    prop = xmlGetNsProp(inst, (const xmlChar *)"mode", XSLT_NAMESPACE);
+    if (prop != NULL) {
+       xmlChar *prefix = NULL;
+
+       mode = xmlSplitQName2(prop, &prefix);
+       if (mode != NULL) {
+           if (prefix != NULL) {
+               xmlNsPtr ns;
+
+               ns = xmlSearchNs(inst->doc, inst, prefix);
+               if (ns == NULL) {
+                   xsltGenericError(xsltGenericErrorContext,
+                       "no namespace bound to prefix %s\n", prefix);
+                   xmlFree(prefix);
+                   xmlFree(mode);
+                   mode = prop;
+               } else {
+                   modeURI = xmlStrdup(ns->href);
+                   xmlFree(prefix);
+                   xmlFree(prop);
+               }
+           } else {
+               xmlFree(prop);
+               modeURI = NULL;
+           }
+       } else {
+           mode = prop;
+           modeURI = NULL;
+       }
+#ifdef DEBUG_PROCESS
+       xsltGenericDebug(xsltGenericDebugContext,
+            "xsltApplyTemplates: mode %s\n", mode);
+#endif
+    } else {
+       mode = NULL;
+       modeURI = NULL;
+    }
+    ctxt->mode = mode;
+    ctxt->modeURI = modeURI;
+
     prop = xmlGetNsProp(inst, (const xmlChar *)"select", XSLT_NAMESPACE);
     if (prop != NULL) {
 #ifdef DEBUG_PROCESS
@@ -1262,7 +1308,6 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
        if (xpathParserCtxt == NULL)
            goto error;
        ctxt->xpathCtxt->node = node;
-       valuePush(xpathParserCtxt, xmlXPathNewNodeSet(node));
        xmlXPathEvalExpr(xpathParserCtxt);
        res = valuePop(xpathParserCtxt);
        do {
@@ -1369,6 +1414,8 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
     ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
 
 error:
+    ctxt->mode = oldmode;
+    ctxt->modeURI = oldmodeURI;
     if (xpathParserCtxt != NULL)
        xmlXPathFreeParserContext(xpathParserCtxt);
     if (prop != NULL)
@@ -1377,6 +1424,10 @@ error:
        xmlXPathFreeObject(res);
     if (list != NULL)
        xmlXPathFreeNodeSet(list);
+    if (mode != NULL)
+       xmlFree(mode);
+    if (modeURI != NULL)
+       xmlFree(modeURI);
 }
 
 
@@ -1476,11 +1527,13 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
                }
                xsltParseStylesheetParam(ctxt, cur);
            } else if (IS_XSLT_NAME(cur, "call-template")) {
+               ctxt->insert = insert;
                if (has_variables == 0) {
                    xsltPushStack(ctxt);
                    has_variables = 1;
                }
                xsltCallTemplate(ctxt, node, cur);
+               ctxt->insert = oldInsert;
            } else if (IS_XSLT_NAME(cur, "message")) {
                xsltMessage(ctxt, node, cur);
            } else {
@@ -1621,7 +1674,6 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
        if (xpathParserCtxt == NULL)
            goto error;
        ctxt->xpathCtxt->node = node;
-       valuePush(xpathParserCtxt, xmlXPathNewNodeSet(node));
        xmlXPathEvalExpr(xpathParserCtxt);
        xmlXPathBooleanFunction(xpathParserCtxt, 1);
        res = valuePop(xpathParserCtxt);
@@ -1721,7 +1773,6 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node,
     if (xpathParserCtxt == NULL)
        goto error;
     ctxt->xpathCtxt->node = node;
-    valuePush(xpathParserCtxt, xmlXPathNewNodeSet(node));
     xmlXPathEvalExpr(xpathParserCtxt);
     xmlXPathBooleanFunction(xpathParserCtxt, 1);
     res = valuePop(xpathParserCtxt);
@@ -1749,7 +1800,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node,
        "xsltIf: test evaluate to %d\n", doit);
 #endif
     if (doit) {
-       xsltApplyOneTemplate(ctxt, ctxt->node, inst->children);
+       xsltApplyOneTemplate(ctxt, node, inst->children);
     }
 
 error:
@@ -1797,7 +1848,6 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
     if (xpathParserCtxt == NULL)
        goto error;
     ctxt->xpathCtxt->node = node;
-    valuePush(xpathParserCtxt, xmlXPathNewNodeSet(node));
     xmlXPathEvalExpr(xpathParserCtxt);
     res = valuePop(xpathParserCtxt);
     do {
index c3aab76..0b0024e 100644 (file)
@@ -501,7 +501,7 @@ xmlXPathObjectPtr
 xsltGlobalVariableLookup(xsltTransformContextPtr ctxt, const xmlChar *name,
                         const xmlChar *ns_uri) {
     xsltStylesheetPtr style;
-    xsltStackElemPtr elem;
+    xsltStackElemPtr elem = NULL;
 
     style = ctxt->style;
     /* TODO: handle the stylesheet cascade */
index a473e03..363a175 100644 (file)
@@ -31,6 +31,7 @@
 #include "imports.h"
 
 #define DEBUG_PARSING
+/* #define DEBUG_BLANKS */
 
 /*
  * Useful macros
@@ -694,7 +695,7 @@ xsltParseRemoveBlanks(xsltStylesheetPtr style) {
     delete = NULL;
     while (cur != NULL) {
        if (delete != NULL) {
-#ifdef DEBUG_PARSING
+#ifdef DEBUG_BLANKS
            xsltGenericDebug(xsltGenericDebugContext,
             "xsltParseRemoveBlanks: removing ignorable blank node\n");
 #endif
@@ -780,9 +781,9 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret,
     delete = NULL;
     while (cur != NULL) {
        if (delete != NULL) {
-#ifdef DEBUG_PARSING
+#ifdef DEBUG_BLANKS
            xsltGenericDebug(xsltGenericDebugContext,
-            "xsltParseStylesheetTemplate: removing text\n");
+            "xsltParseTemplateContent: removing text\n");
 #endif
            xmlUnlinkNode(delete);
            xmlFreeNode(delete);
@@ -803,6 +804,10 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret,
                                (const xmlChar *)"disable-output-escaping",
                                            XSLT_NAMESPACE);
                        if (prop != NULL) {
+#ifdef DEBUG_PARSING
+                           xsltGenericDebug(xsltGenericDebugContext,
+                                "Disable escaping: %s\n", text->content);
+#endif
                            if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
                                text->name = xmlStringTextNoenc;
                            } else if (!xmlStrEqual(prop,
@@ -904,6 +909,8 @@ void
 xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
     xsltTemplatePtr ret;
     xmlChar *prop;
+    xmlChar *mode;
+    xmlChar *modeURI;
 
     if (template == NULL)
        return;
@@ -920,6 +927,43 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
     /*
      * Get arguments
      */
+    prop = xmlGetNsProp(template, (const xmlChar *)"mode", XSLT_NAMESPACE);
+    if (prop != NULL) {
+       xmlChar *prefix = NULL;
+
+       mode = xmlSplitQName2(prop, &prefix);
+       if (mode != NULL) {
+           if (prefix != NULL) {
+               xmlNsPtr ns;
+
+               ns = xmlSearchNs(template->doc, template, prefix);
+               if (ns == NULL) {
+                   xsltGenericError(xsltGenericErrorContext,
+                       "no namespace bound to prefix %s\n", prefix);
+                   xmlFree(prefix);
+                   xmlFree(mode);
+                   mode = prop;
+               } else {
+                   modeURI = xmlStrdup(ns->href);
+                   xmlFree(prefix);
+                   xmlFree(prop);
+               }
+           } else {
+               xmlFree(prop);
+               modeURI = NULL;
+           }
+       } else {
+           mode = prop;
+           modeURI = NULL;
+       }
+#ifdef DEBUG_PARSING
+       xsltGenericDebug(xsltGenericDebugContext,
+            "xslt:template: mode %s\n", mode);
+#endif
+    } else {
+       mode = NULL;
+       modeURI = NULL;
+    }
     prop = xmlGetNsProp(template, (const xmlChar *)"match", XSLT_NAMESPACE);
     if (prop != NULL) {
        if (ret->match != NULL) xmlFree(ret->match);
@@ -967,7 +1011,12 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
      * parse the content and register the pattern
      */
     xsltParseTemplateContent(style, ret, template);
-    xsltAddTemplate(style, ret);
+    xsltAddTemplate(style, ret, mode, modeURI);
+
+    if (mode != NULL)
+       xmlFree(mode);
+    if (modeURI != NULL)
+       xmlFree(modeURI);
 }
 
 /**
@@ -1160,7 +1209,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
         * parse the content and register the pattern
         */
        xsltParseTemplateContent(ret, template, (xmlNodePtr) doc);
-       xsltAddTemplate(ret, template);
+       xsltAddTemplate(ret, template, NULL, NULL);
     }
 
     return(ret);
index 8228219..1cd6ce5 100644 (file)
@@ -173,6 +173,9 @@ struct _xsltTransformContext {
     xsltStylesheetPtr style;           /* the stylesheet used */
     xsltOutputType type;               /* the type of output */
 
+    const xmlChar *mode;               /* the current mode */
+    const xmlChar *modeURI;            /* the current mode URI */
+
     xmlDocPtr doc;                     /* the current doc */
     xmlNodePtr node;                   /* the current node */
     xmlNodeSetPtr nodeList;            /* the current node list */
index abd928e..a5b0aec 100644 (file)
@@ -7,6 +7,8 @@
  */
 
 #include <string.h>
+#include <sys/time.h>
+#include <unistd.h>
 #include <libxml/xmlversion.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/debugXML.h>
 #include <libxslt/transform.h>
 #include <libxslt/xsltutils.h>
 
+extern int xmlLoadExtDtdDefaultValue;
+
 static int debug = 0;
 static int repeat = 0;
+static int timing = 0;
 
 int
 main(int argc, char **argv) {
     int i;
     xsltStylesheetPtr cur = NULL;
     xmlDocPtr doc, res;
+    struct timeval begin, end;
 
     /* --repeat : repeat 100 times, for timing or profiling */
     LIBXML_TEST_VERSION
@@ -37,12 +43,27 @@ main(int argc, char **argv) {
        } else if ((!strcmp(argv[i], "-repeat")) ||
                   (!strcmp(argv[i], "--repeat"))) {
            repeat++;
+       } else if ((!strcmp(argv[i], "-timing")) ||
+                  (!strcmp(argv[i], "--timing"))) {
+           timing++;
        }
     }
     xmlSubstituteEntitiesDefault(1);
+    xmlLoadExtDtdDefaultValue = 1;
     for (i = 1; i < argc ; i++) {
        if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) {
+           if (timing)
+               gettimeofday(&begin, NULL);
            cur = xsltParseStylesheetFile((const xmlChar *)argv[i]);
+           if (timing) {
+               long msec;
+               gettimeofday(&end, NULL);
+               msec = end.tv_sec - begin.tv_sec;
+               msec *= 1000;
+               msec += (end.tv_usec - begin.tv_usec) / 1000;
+               fprintf(stderr, "Parsing stylesheet %s took %ld ms\n",
+                       argv[i], msec);
+           }
            if (cur != NULL) {
                if (cur->indent == 1)
                    xmlIndentTreeOutput = 1;
@@ -56,11 +77,22 @@ main(int argc, char **argv) {
     }
     if (cur != NULL) {
        for (;i < argc ; i++) {
+           if (timing)
+               gettimeofday(&begin, NULL);
            doc = xmlParseFile(argv[i]);
            if (doc == NULL) {
                fprintf(stderr, "unable to parse %s\n", argv[i]);
                continue;
            }
+           if (timing) {
+               long msec;
+               gettimeofday(&end, NULL);
+               msec = end.tv_sec - begin.tv_sec;
+               msec *= 1000;
+               msec += (end.tv_usec - begin.tv_usec) / 1000;
+               fprintf(stderr, "Parsing document %s took %ld ms\n",
+                       argv[i], msec);
+           }
            if (repeat) {
                int j;
                for (j = 0;j < 99; j++) {
@@ -70,19 +102,41 @@ main(int argc, char **argv) {
                    doc = xmlParseFile(argv[i]);
                }
            }
+           if (timing)
+               gettimeofday(&begin, NULL);
            res = xsltApplyStylesheet(cur, doc);
+           if (timing) {
+               long msec;
+               gettimeofday(&end, NULL);
+               msec = end.tv_sec - begin.tv_sec;
+               msec *= 1000;
+               msec += (end.tv_usec - begin.tv_usec) / 1000;
+               fprintf(stderr, "Applying stylesheet took %ld ms\n",
+                       msec);
+           }
            xmlFreeDoc(doc);
            if (res == NULL) {
                fprintf(stderr, "no result for %s\n", argv[i]);
                continue;
            }
            if (cur->methodURI == NULL) {
+               if (timing)
+                   gettimeofday(&begin, NULL);
 #ifdef LIBXML_DEBUG_ENABLED
                if (debug)
                    xmlDebugDumpDocument(stdout, res);
                else
 #endif
                    xsltSaveResultToFile(stdout, res, cur);
+               if (timing) {
+                   long msec;
+                   gettimeofday(&end, NULL);
+                   msec = end.tv_sec - begin.tv_sec;
+                   msec *= 1000;
+                   msec += (end.tv_usec - begin.tv_usec) / 1000;
+                   fprintf(stderr, "Saving result took %ld ms\n",
+                           msec);
+               }
            }
 
            xmlFreeDoc(res);
index f506071..0ae7caa 100644 (file)
@@ -375,7 +375,17 @@ xsltSaveResultToFilename(const char *URL, xmlDocPtr result,
     if ((URL == NULL) || (result == NULL) || (style == NULL))
        return(-1);
 
-    buf = xmlOutputBufferCreateFilename(URL, NULL, compression);
+    if (style->encoding != NULL) {
+       xmlCharEncodingHandlerPtr encoder;
+
+       encoder = xmlFindCharEncodingHandler((char *)style->encoding);
+       if ((encoder != NULL) &&
+           (xmlStrEqual(encoder->name, (const xmlChar *) "UTF-8")))
+           encoder = NULL;
+       buf = xmlOutputBufferCreateFilename(URL, encoder, compression);
+    } else {
+       buf = xmlOutputBufferCreateFilename(URL, NULL, compression);
+    }
     if (buf == NULL)
        return(-1);
     xsltSaveResultTo(buf, result, style);
@@ -403,7 +413,18 @@ xsltSaveResultToFile(FILE *file, xmlDocPtr result, xsltStylesheetPtr style) {
     if ((file == NULL) || (result == NULL) || (style == NULL))
        return(-1);
 
-    buf = xmlOutputBufferCreateFile(file, NULL);
+    if (style->encoding != NULL) {
+       xmlCharEncodingHandlerPtr encoder;
+
+       encoder = xmlFindCharEncodingHandler((char *)style->encoding);
+       if ((encoder != NULL) &&
+           (xmlStrEqual(encoder->name, (const xmlChar *) "UTF-8")))
+           encoder = NULL;
+       buf = xmlOutputBufferCreateFile(file, encoder);
+    } else {
+       buf = xmlOutputBufferCreateFile(file, NULL);
+    }
+
     if (buf == NULL)
        return(-1);
     xsltSaveResultTo(buf, result, style);
@@ -431,7 +452,17 @@ xsltSaveResultToFd(int fd, xmlDocPtr result, xsltStylesheetPtr style) {
     if ((fd < 0) || (result == NULL) || (style == NULL))
        return(-1);
 
-    buf = xmlOutputBufferCreateFd(fd, NULL);
+    if (style->encoding != NULL) {
+       xmlCharEncodingHandlerPtr encoder;
+
+       encoder = xmlFindCharEncodingHandler((char *)style->encoding);
+       if ((encoder != NULL) &&
+           (xmlStrEqual(encoder->name, (const xmlChar *) "UTF-8")))
+           encoder = NULL;
+       buf = xmlOutputBufferCreateFd(fd, encoder);
+    } else {
+       buf = xmlOutputBufferCreateFd(fd, NULL);
+    }
     if (buf == NULL)
        return(-1);
     xsltSaveResultTo(buf, result, style);
index 7ca514a..59bbcc6 100644 (file)
@@ -1,5 +1,5 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS=docs REC1 REC2 REC general numbers
+SUBDIRS=docs REC1 REC2 REC general numbers xmlspec
 
 test tests: all
diff --git a/tests/xmlspec/Makefile.am b/tests/xmlspec/Makefile.am
new file mode 100644 (file)
index 0000000..e3d10f1
--- /dev/null
@@ -0,0 +1,18 @@
+## Process this file with automake to produce Makefile.in
+
+$(top_builddir)/libxslt/xsltproc:
+       @(cd ../../libxslt ; make xsltproc)
+
+EXTRA_DIST = REC-xml-20001006.xml xmlspec-v21.dtd W3C-REC.css \
+             logo-REC xmlspec.xsl
+
+all: test
+
+test tests: $(top_builddir)/libxslt/xsltproc
+       @(rm -f .memdump ; touch .memdump)
+       @($(top_builddir)/libxslt/xsltproc -timing -v xmlspec.xsl REC-xml-20001006.xml > REC-xml-20001006.html 2> debug ; \
+       grep implemented debug | sort | uniq -c ; \
+       grep "ms$$" debug ; \
+       grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
+       rm -f doc.res)
+
diff --git a/tests/xmlspec/REC-xml-20001006.xml b/tests/xmlspec/REC-xml-20001006.xml
new file mode 100644 (file)
index 0000000..96a2ee8
--- /dev/null
@@ -0,0 +1,3277 @@
+<?xml version="1.0" encoding="iso-8859-1"?>\r
+<!DOCTYPE spec PUBLIC "-//W3C//DTD Specification V2.1//EN"\r
+ "xmlspec-v21.dtd" [\r
+<!--ArborText, Inc., 1988-2000, v.4002-->\r
+<!ENTITY http-ident "http://www.w3.org/TR/2000/REC-xml">\r
+<!ENTITY draft.month "October">\r
+<!ENTITY draft.day "6">\r
+<!ENTITY iso6.doc.date "20001006">\r
+<!ENTITY draft.year "2000">\r
+<!ENTITY versionOfXML "1.0">\r
+<!ENTITY pio "'&lt;?xml'">\r
+<!ENTITY doc.date "10 February 1998">\r
+<!ENTITY w3c.doc.date "02-Feb-1998">\r
+<!ENTITY WebSGML "WebSGML Adaptations Annex to ISO 8879">\r
+<!ENTITY pic "'?>'">\r
+<!ENTITY br "\n">\r
+<!ENTITY cellback "#c0d9c0">\r
+<!ENTITY mdash "--">\r
+<!ENTITY com "--">\r
+<!ENTITY como "--">\r
+<!ENTITY comc "--">\r
+<!ENTITY hcro "&amp;#x">\r
+<!ENTITY nbsp "&#160;">\r
+<!ENTITY magicents "<code>amp</code>,\r
+<code>lt</code>,\r
+<code>gt</code>,\r
+<code>apos</code>,\r
+<code>quot</code>">\r
+<!ENTITY doc.audience "public review and discussion">\r
+<!ENTITY doc.distribution "may be distributed freely, as long as\r
+all text and legal notices remain intact">\r
+]>\r
+<spec w3c-doctype="rec">\r
+<!--\r
+Notes on preparation of the Second Edition:\r
+\r
+- Worked from http://www.w3.org/XML/xml-19980210-errata.\r
+- Changed DTD reference to point to V2.1 of XMLspec.\r
+- Moved version number from <title> to <version> element and\r
+  added "second edition" wording.  Mentioned edition information\r
+  in status.\r
+- Removed bgcolor="&cellback;" attributes from all <td>\r
+  elements because that attribute is not in the current table model.\r
+- Reversed status and abstract, so that abstract is first, according\r
+  to W3C guidelines.\r
+- Changed some <emph>s to <titleref>s in bibliography.\r
+- Changed some <code>s to <at> etc. throughout; where used <attval>,\r
+  removed existing <quote>s because the stylesheet produces them.\r
+- Removed some spurious spaces.\r
+- Added affiliation markup to the original member list.\r
+- Added commas between individual <thisver> elements, because\r
+  whitespace is now significant there.\r
+- Moved <eg>s, <scrap>s, and lists outside of <p>s for cleaner HTML\r
+  conversion.\r
+- Revised Status section to reflect new status.\r
+- Fixed all titleref hrefs so they get transformed properly; at\r
+  next revision, these all probably need to be changed to some\r
+  other markup.\r
+- Incorporated all errata (barring obsoleted and invalid ones);\r
+  added links to the errata document with <loc role="erratumref">\r
+  elements; used diff="{add|chg|del}" attribute.  This version \r
+  expects that the official HTML output will have diff="del" \r
+  elements suppressed.\r
+-->\r
+<header>\r
+<title>Extensible Markup Language (XML)</title>\r
+<version>1.0 (Second Edition)</version>\r
+<w3c-designation>REC-xml-&iso6.doc.date;</w3c-designation>\r
+<w3c-doctype>W3C Recommendation</w3c-doctype>\r
+<pubdate><day>&draft.day;</day><month>&draft.month;</month><year>&draft.year;</year>\r
+</pubdate>\r
+<publoc><loc href="&http-ident;-&iso6.doc.date;">&http-ident;-&iso6.doc.date;</loc>\r
+(<loc href="&http-ident;-&iso6.doc.date;.html">XHTML</loc>, <loc href="&http-ident;-&iso6.doc.date;.xml">XML</loc>, <loc\r
+href="&http-ident;-&iso6.doc.date;.pdf">PDF</loc>, <loc href="&http-ident;-&iso6.doc.date;-review.html">XHTML\r
+review version</loc> with color-coded revision indicators)</publoc>\r
+<latestloc><loc href="http://www.w3.org/TR/REC-xml">http://www.w3.org/TR/REC-xml</loc></latestloc>\r
+<prevlocs><loc href="http://www.w3.org/TR/2000/WD-xml-2e-20000814"> http://www.w3.org/TR/2000/WD-xml-2e-20000814</loc>\r
+<loc href="http://www.w3.org/TR/1998/REC-xml-19980210"> http://www.w3.org/TR/1998/REC-xml-19980210</loc><!--\r
+<loc href='http://www.w3.org/TR/PR-xml-971208'>\r
+http://www.w3.org/TR/PR-xml-971208</loc>\r
+<loc href='http://www.w3.org/TR/WD-xml-961114'>\r
+http://www.w3.org/TR/WD-xml-961114</loc>\r
+<loc href='http://www.w3.org/TR/WD-xml-lang-970331'>\r
+http://www.w3.org/TR/WD-xml-lang-970331</loc>\r
+<loc href='http://www.w3.org/TR/WD-xml-lang-970630'>\r
+http://www.w3.org/TR/WD-xml-lang-970630</loc>\r
+<loc href='http://www.w3.org/TR/WD-xml-970807'>\r
+http://www.w3.org/TR/WD-xml-970807</loc>\r
+<loc href='http://www.w3.org/TR/WD-xml-971117'>\r
+http://www.w3.org/TR/WD-xml-971117</loc>--> </prevlocs>\r
+<authlist>\r
+<author role="1e"><name>Tim Bray</name><affiliation>Textuality and Netscape</affiliation>\r
+<email href="mailto:tbray@textuality.com">tbray@textuality.com</email></author>\r
+<author role="1e"><name>Jean Paoli</name><affiliation>Microsoft</affiliation>\r
+<email href="mailto:jeanpa@microsoft.com">jeanpa@microsoft.com</email></author>\r
+<author role="1e" diff="chg"><name>C. M. Sperberg-McQueen</name><affiliation>University\r
+of Illinois at Chicago and Text Encoding Initiative</affiliation><email href="mailto:cmsmcq@uic.edu">cmsmcq@uic.edu</email>\r
+</author>\r
+<author role="2e" diff="add"><name>Eve Maler</name><affiliation>Sun Microsystems,\r
+Inc.</affiliation><email href="mailto:elm@east.sun.com">eve.maler@east.sun.com</email>\r
+</author>\r
+</authlist>\r
+<abstract>\r
+<p>The Extensible Markup Language (XML) is a subset of SGML that is completely\r
+described in this document. Its goal is to enable generic SGML to be served,\r
+received, and processed on the Web in the way that is now possible with HTML.\r
+XML has been designed for ease of implementation and for interoperability\r
+with both SGML and HTML.</p>\r
+</abstract>\r
+<status>\r
+<p>This document has been reviewed by W3C Members and other interested parties\r
+and has been endorsed by the Director as a W3C Recommendation. It is a stable\r
+document and may be used as reference material or cited as a normative reference\r
+from another document. W3C's role in making the Recommendation is to draw\r
+attention to the specification and to promote its widespread deployment. This\r
+enhances the functionality and interoperability of the Web.</p>\r
+<p>This document specifies a syntax created by subsetting an existing, widely\r
+used international text processing standard (Standard Generalized Markup Language,\r
+ISO 8879:1986(E) as amended and corrected) for use on the World Wide Web.\r
+It is a product of the W3C XML Activity, details of which can be found at <loc\r
+href="http://www.w3.org/XML/">http://www.w3.org/XML</loc>. <phrase diff="add"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E100">[E100]</loc>\r
+The English version of this specification is the only normative version. However,\r
+for translations of this document, see <loc href="http://www.w3.org/XML/#trans">http://www.w3.org/XML/#trans</loc>. </phrase>A\r
+list of current W3C Recommendations and other technical documents can be found\r
+at <loc href="http://www.w3.org/TR/">http://www.w3.org/TR</loc>.</p>\r
+<p diff="del"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E66">[E66]</loc>This\r
+specification uses the term URI, which is defined by <bibref ref="Berners-Lee"/>,\r
+a work in progress expected to update <bibref ref="RFC1738"/> and <bibref\r
+ref="RFC1808"/>.</p>\r
+<p diff="add">This second edition is <emph>not</emph> a new version of XML (first published 10 February 1998);\r
+it merely incorporates the changes dictated by the first-edition errata (available\r
+at <loc href="http://www.w3.org/XML/xml-19980210-errata">http://www.w3.org/XML/xml-19980210-errata</loc>)\r
+as a convenience to readers. The errata list for this second edition is available\r
+at <loc href="http://www.w3.org/XML/xml-V10-2e-errata">http://www.w3.org/XML/xml-V10-2e-errata</loc>.</p>\r
+<p>Please report errors in this document to <loc href="mailto:xml-editor@w3.org">xml-editor@w3.org</loc><phrase\r
+diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E101">[E101]</loc>; <loc\r
+href="http://lists.w3.org/Archives/Public/xml-editor">archives</loc> are available</phrase>.</p>\r
+<note diff="add">\r
+<p>C. M. Sperberg-McQueen's affiliation has changed since the publication\r
+of the first edition. He is now at the World Wide Web Consortium, and can\r
+be contacted at <loc href="mailto:cmsmcq@w3.org">cmsmcq@w3.org</loc>.</p>\r
+</note>\r
+</status>\r
+<pubstmt>\r
+<p>Chicago, Vancouver, Mountain View, et al.: World-Wide Web Consortium, XML\r
+Working Group, 1996, 1997, 2000.</p>\r
+</pubstmt>\r
+<sourcedesc>\r
+<p>Created in electronic form.</p>\r
+</sourcedesc>\r
+<langusage>\r
+<language id="EN">English</language>\r
+<language id="ebnf">Extended Backus-Naur Form (formal grammar)</language>\r
+</langusage>\r
+<revisiondesc>\r
+<slist>\r
+<sitem>1997-12-03 : CMSMcQ : yet further changes</sitem>\r
+<sitem>1997-12-02 : TB : further changes (see TB to XML WG, 2 December 1997)</sitem>\r
+<sitem>1997-12-02 : CMSMcQ : deal with as many corrections and comments from\r
+the proofreaders as possible: entify hard-coded document date in pubdate element,\r
+change expansion of entity WebSGML, update status description as per Dan Connolly\r
+(am not sure about refernece to Berners-Lee et al.), add 'The' to abstract\r
+as per WG decision, move Relationship to Existing Standards to back matter\r
+and combine with References, re-order back matter so normative appendices\r
+come first, re-tag back matter so informative appendices are tagged informdiv1,\r
+remove XXX XXX from list of 'normative' specs in prose, move some references\r
+from Other References to Normative References, add RFC 1738, 1808, and 2141\r
+to Other References (they are not normative since we do not require the processor\r
+to enforce any rules based on them), add reference to 'Fielding draft' (Berners-Lee\r
+et al.), move notation section to end of body, drop URIchar non-terminal and\r
+use SkipLit instead, lose stray reference to defunct nonterminal 'markupdecls',\r
+move reference to Aho et al. into appendix (Tim's right), add prose note saying\r
+that hash marks and fragment identifiers are NOT part of the URI formally\r
+speaking, and are NOT legal in system identifiers (processor 'may' signal\r
+an error). Work through: Tim Bray reacting to James Clark, Tim Bray on his\r
+own, Eve Maler, NOT DONE YET: change binary / text to unparsed / parsed. handle\r
+James's suggestion about &lt; in attriubte values uppercase hex characters,\r
+namechar list, </sitem>\r
+<sitem>1997-12-01 : JB : add some column-width parameters</sitem>\r
+<sitem>1997-12-01 : CMSMcQ : begin round of changes to incorporate recent\r
+WG decisions and other corrections: binding sources of character encoding\r
+info (27 Aug / 3 Sept), correct wording of Faust quotation (restore dropped\r
+line), drop SDD from EncodingDecl, change text at version number 1.0, drop\r
+misleading (wrong!) sentence about ignorables and extenders, modify definition\r
+of PCData to make bar on msc grammatical, change grammar's handling of internal\r
+subset (drop non-terminal markupdecls), change definition of includeSect to\r
+allow conditional sections, add integral-declaration constraint on internal\r
+subset, drop misleading / dangerous sentence about relationship of entities\r
+with system storage objects, change table body tag to htbody as per EM change\r
+to DTD, add rule about space normalization in public identifiers, add description\r
+of how to generate our name-space rules from Unicode character database (needs\r
+further work!). </sitem>\r
+<sitem>1997-10-08 : TB : Removed %-constructs again, new rules for PE appearance.</sitem>\r
+<sitem>1997-10-01 : TB : Case-sensitive markup; cleaned up element-type defs,\r
+lotsa little edits for style</sitem>\r
+<sitem>1997-09-25 : TB : Change to elm's new DTD, with substantial detail\r
+cleanup as a side-effect</sitem>\r
+<sitem>1997-07-24 : CMSMcQ : correct error (lost *) in definition of ignoreSectContents\r
+(thanks to Makoto Murata)</sitem>\r
+<sitem>Allow all empty elements to have end-tags, consistent with SGML TC\r
+(as per JJC).</sitem>\r
+<sitem>1997-07-23 : CMSMcQ : pre-emptive strike on pending corrections: introduce\r
+the term 'empty-element tag', note that all empty elements may use it, and\r
+elements declared EMPTY must use it. Add WFC requiring encoding decl to come\r
+first in an entity. Redefine notations to point to PIs as well as binary entities.\r
+Change autodetection table by removing bytes 3 and 4 from examples with Byte\r
+Order Mark. Add content model as a term and clarify that it applies to both\r
+mixed and element content. </sitem>\r
+<sitem>1997-06-30 : CMSMcQ : change date, some cosmetic changes, changes to\r
+productions for choice, seq, Mixed, NotationType, Enumeration. Follow James\r
+Clark's suggestion and prohibit conditional sections in internal subset. TO\r
+DO: simplify production for ignored sections as a result, since we don't need\r
+to worry about parsers which don't expand PErefs finding a conditional section.</sitem>\r
+<sitem>1997-06-29 : TB : various edits</sitem>\r
+<sitem>1997-06-29 : CMSMcQ : further changes: Suppress old FINAL EDIT comments\r
+and some dead material. Revise occurrences of % in grammar to exploit Henry\r
+Thompson's pun, especially markupdecl and attdef. Remove RMD requirement relating\r
+to element content (?). </sitem>\r
+<sitem>1997-06-28 : CMSMcQ : Various changes for 1 July draft: Add text for\r
+draconian error handling (introduce the term Fatal Error). RE deleta est (changing\r
+wording from original announcement to restrict the requirement to validating\r
+parsers). Tag definition of validating processor and link to it. Add colon\r
+as name character. Change def of %operator. Change standard definitions of\r
+lt, gt, amp. Strip leading zeros from #x00nn forms.</sitem>\r
+<sitem>1997-04-02 : CMSMcQ : final corrections of editorial errors found in\r
+last night's proofreading. Reverse course once more on well-formed: Webster's\r
+Second hyphenates it, and that's enough for me.</sitem>\r
+<sitem>1997-04-01 : CMSMcQ : corrections from JJC, EM, HT, and self</sitem>\r
+<sitem>1997-03-31 : Tim Bray : many changes</sitem>\r
+<sitem>1997-03-29 : CMSMcQ : some Henry Thompson (on entity handling), some\r
+Charles Goldfarb, some ERB decisions (PE handling in miscellaneous declarations.\r
+Changed Ident element to accept def attribute. Allow normalization of Unicode\r
+characters. move def of systemliteral into section on literals.</sitem>\r
+<sitem>1997-03-28 : CMSMcQ : make as many corrections as possible, from Terry\r
+Allen, Norbert Mikula, James Clark, Jon Bosak, Henry Thompson, Paul Grosso,\r
+and self. Among other things: give in on "well formed" (Terry is right), tentatively\r
+rename QuotedCData as AttValue and Literal as EntityValue to be more informative,\r
+since attribute values are the <emph>only</emph> place QuotedCData was used,\r
+and vice versa for entity text and Literal. (I'd call it Entity Text, but\r
+8879 uses that name for both internal and external entities.)</sitem>\r
+<sitem>1997-03-26 : CMSMcQ : resynch the two forks of this draft, reapply\r
+my changes dated 03-20 and 03-21. Normalize old 'may not' to 'must not' except\r
+in the one case where it meant 'may or may not'.</sitem>\r
+<sitem>1997-03-21 : TB : massive changes on plane flight from Chicago to Vancouver</sitem>\r
+<sitem>1997-03-21 : CMSMcQ : correct as many reported errors as possible. </sitem>\r
+<sitem>1997-03-20 : CMSMcQ : correct typos listed in CMSMcQ hand copy of spec.</sitem>\r
+<sitem>1997-03-20 : CMSMcQ : cosmetic changes preparatory to revision for\r
+WWW conference April 1997: restore some of the internal entity references\r
+(e.g. to docdate, etc.), change character xA0 to &amp;nbsp; and define nbsp\r
+as &amp;#160;, and refill a lot of paragraphs for legibility.</sitem>\r
+<sitem>1996-11-12 : CMSMcQ : revise using Tim's edits: Add list type of NUMBERED\r
+and change most lists either to BULLETS or to NUMBERED. Suppress QuotedNames,\r
+Names (not used). Correct trivial-grammar doc type decl. Rename 'marked section'\r
+as 'CDATA section' passim. Also edits from James Clark: Define the set of\r
+characters from which [^abc] subtracts. Charref should use just [0-9] not\r
+Digit. Location info needs cleaner treatment: remove? (ERB question). One\r
+example of a PI has wrong pic. Clarify discussion of encoding names. Encoding\r
+failure should lead to unspecified results; don't prescribe error recovery.\r
+Don't require exposure of entity boundaries. Ignore white space in element\r
+content. Reserve entity names of the form u-NNNN. Clarify relative URLs. And\r
+some of my own: Correct productions for content model: model cannot consist\r
+of a name, so "elements ::= cp" is no good. </sitem>\r
+<sitem>1996-11-11 : CMSMcQ : revise for style. Add new rhs to entity declaration,\r
+for parameter entities.</sitem>\r
+<sitem>1996-11-10 : CMSMcQ : revise for style. Fix / complete section on names,\r
+characters. Add sections on parameter entities, conditional sections. Still\r
+to do: Add compatibility note on deterministic content models. Finish stylistic\r
+revision.</sitem>\r
+<sitem>1996-10-31 : TB : Add Entity Handling section</sitem>\r
+<sitem>1996-10-30 : TB : Clean up term &amp; termdef. Slip in ERB decision\r
+re EMPTY.</sitem>\r
+<sitem>1996-10-28 : TB : Change DTD. Implement some of Michael's suggestions.\r
+Change comments back to //. Introduce language for XML namespace reservation.\r
+Add section on white-space handling. Lots more cleanup.</sitem>\r
+<sitem>1996-10-24 : CMSMcQ : quick tweaks, implement some ERB decisions. Characters\r
+are not integers. Comments are /* */ not //. Add bibliographic refs to 10646,\r
+HyTime, Unicode. Rename old Cdata as MsData since it's <emph>only</emph> seen\r
+in marked sections. Call them attribute-value pairs not name-value pairs,\r
+except once. Internal subset is optional, needs '?'. Implied attributes should\r
+be signaled to the app, not have values supplied by processor.</sitem>\r
+<sitem>1996-10-16 : TB : track down &amp; excise all DSD references; introduce\r
+some EBNF for entity declarations.</sitem>\r
+<sitem>1996-10-?? : TB : consistency check, fix up scraps so they all parse,\r
+get formatter working, correct a few productions.</sitem>\r
+<sitem>1996-10-10/11 : CMSMcQ : various maintenance, stylistic, and organizational\r
+changes: Replace a few literals with xmlpio and pic entities, to make them\r
+consistent and ensure we can change pic reliably when the ERB votes. Drop\r
+paragraph on recognizers from notation section. Add match, exact match to\r
+terminology. Move old 2.2 XML Processors and Apps into intro. Mention comments,\r
+PIs, and marked sections in discussion of delimiter escaping. Streamline discussion\r
+of doctype decl syntax. Drop old section of 'PI syntax' for doctype decl,\r
+and add section on partial-DTD summary PIs to end of Logical Structures section.\r
+Revise DSD syntax section to use Tim's subset-in-a-PI mechanism.</sitem>\r
+<sitem>1996-10-10 : TB : eliminate name recognizers (and more?)</sitem>\r
+<sitem>1996-10-09 : CMSMcQ : revise for style, consistency through 2.3 (Characters)</sitem>\r
+<sitem>1996-10-09 : CMSMcQ : re-unite everything for convenience, at least\r
+temporarily, and revise quickly</sitem>\r
+<sitem>1996-10-08 : TB : first major homogenization pass</sitem>\r
+<sitem>1996-10-08 : TB : turn "current" attribute on div type into CDATA</sitem>\r
+<sitem>1996-10-02 : TB : remould into skeleton + entities</sitem>\r
+<sitem>1996-09-30 : CMSMcQ : add a few more sections prior to exchange with\r
+Tim.</sitem>\r
+<sitem>1996-09-20 : CMSMcQ : finish transcribing notes.</sitem>\r
+<sitem>1996-09-19 : CMSMcQ : begin transcribing notes for draft.</sitem>\r
+<sitem>1996-09-13 : CMSMcQ : made outline from notes of 09-06, do some housekeeping</sitem>\r
+</slist>\r
+</revisiondesc>\r
+</header>\r
+<body>\r
+<div1 id="sec-intro">\r
+<head>Introduction</head>\r
+<p>Extensible Markup Language, abbreviated XML, describes a class of data\r
+objects called <termref def="dt-xml-doc">XML documents</termref> and partially\r
+describes the behavior of computer programs which process them. XML is an\r
+application profile or restricted form of SGML, the Standard Generalized Markup\r
+Language <bibref ref="ISO8879"/>. By construction, XML documents are conforming\r
+SGML documents.</p>\r
+<p>XML documents are made up of storage units called <termref def="dt-entity">entities</termref>,\r
+which contain either parsed or unparsed data. Parsed data is made up of <termref\r
+def="dt-character">characters</termref>, some of which form <termref def="dt-chardata">character\r
+data</termref>, and some of which form <termref def="dt-markup">markup</termref>.\r
+Markup encodes a description of the document's storage layout and logical\r
+structure. XML provides a mechanism to impose constraints on the storage layout\r
+and logical structure.</p>\r
+<p><termdef id="dt-xml-proc" term="XML Processor">A software module called\r
+an <term>XML processor</term> is used to read XML documents and provide access\r
+to their content and structure.</termdef> <termdef id="dt-app" term="Application">It\r
+is assumed that an XML processor is doing its work on behalf of another module,\r
+called the <term>application</term>.</termdef> This specification describes\r
+the required behavior of an XML processor in terms of how it must read XML\r
+data and the information it must provide to the application.</p>\r
+<div2 id="sec-origin-goals">\r
+<head>Origin and Goals</head>\r
+<p>XML was developed by an XML Working Group (originally known as the SGML\r
+Editorial Review Board) formed under the auspices of the World Wide Web Consortium\r
+(W3C) in 1996. It was chaired by Jon Bosak of Sun Microsystems with the active\r
+participation of an XML Special Interest Group (previously known as the SGML\r
+Working Group) also organized by the W3C. The membership of the XML Working\r
+Group is given in an appendix. Dan Connolly served as the WG's contact with\r
+the W3C.</p>\r
+<p>The design goals for XML are:</p>\r
+<olist>\r
+<item><p>XML shall be straightforwardly usable over the Internet.</p></item>\r
+<item><p>XML shall support a wide variety of applications.</p></item>\r
+<item><p>XML shall be compatible with SGML.</p></item>\r
+<item><p>It shall be easy to write programs which process XML documents.</p>\r
+</item>\r
+<item><p>The number of optional features in XML is to be kept to the absolute\r
+minimum, ideally zero.</p></item>\r
+<item><p>XML documents should be human-legible and reasonably clear.</p></item>\r
+<item><p>The XML design should be prepared quickly.</p></item>\r
+<item><p>The design of XML shall be formal and concise.</p></item>\r
+<item><p>XML documents shall be easy to create.</p></item>\r
+<item><p>Terseness in XML markup is of minimal importance.</p></item>\r
+</olist>\r
+<p>This specification, together with associated standards (Unicode and ISO/IEC\r
+10646 for characters, Internet RFC 1766 for language identification tags,\r
+ISO 639 for language name codes, and ISO 3166 for country name codes), provides\r
+all the information necessary to understand XML Version &versionOfXML; and\r
+construct computer programs to process it.</p>\r
+<p>This version of the XML specification <!-- is for &doc.audience;.--> &doc.distribution;.</p>\r
+</div2>\r
+<div2 id="sec-terminology">\r
+<head>Terminology</head>\r
+<p>The terminology used to describe XML documents is defined in the body of\r
+this specification. The terms defined in the following list are used in building\r
+those definitions and in describing the actions of an XML processor: <glist>\r
+<gitem><label>may</label>\r
+<def>\r
+<p><termdef id="dt-may" term="May">Conforming documents and XML processors\r
+are permitted to but need not behave as described.</termdef></p>\r
+</def></gitem>\r
+<gitem><label>must</label>\r
+<def>\r
+<p><termdef id="dt-must" term="Must">Conforming documents and XML processors\r
+are required to behave as described; otherwise they are in error. <!-- do NOT change this! this is what defines a violation of\r
+a 'must' clause as 'an error'. -MSM --></termdef></p>\r
+</def></gitem>\r
+<gitem><label>error</label>\r
+<def>\r
+<p><termdef id="dt-error" term="Error">A violation of the rules of this specification;\r
+results are undefined. Conforming software may detect and report an error\r
+and may recover from it.</termdef></p>\r
+</def></gitem>\r
+<gitem><label>fatal error</label>\r
+<def>\r
+<p><termdef id="dt-fatal" term="Fatal Error">An error which a conforming <termref\r
+def="dt-xml-proc">XML processor</termref> must detect and report to the application.\r
+After encountering a fatal error, the processor may continue processing the\r
+data to search for further errors and may report such errors to the application.\r
+In order to support correction of errors, the processor may make unprocessed\r
+data from the document (with intermingled character data and markup) available\r
+to the application. Once a fatal error is detected, however, the processor\r
+must not continue normal processing (i.e., it must not continue to pass character\r
+data and information about the document's logical structure to the application\r
+in the normal way).</termdef></p>\r
+</def></gitem>\r
+<gitem><label>at user option</label>\r
+<def>\r
+<p><termdef id="dt-atuseroption" term="At user option">Conforming software\r
+may or must (depending on the modal verb in the sentence) behave as described;\r
+if it does, it must provide users a means to enable or disable the behavior\r
+described.</termdef></p>\r
+</def></gitem>\r
+<gitem><label>validity constraint</label>\r
+<def>\r
+<p><termdef id="dt-vc" term="Validity constraint">A rule which applies to\r
+all <termref def="dt-valid">valid</termref> XML documents. Violations of validity\r
+constraints are errors; they must, at user option, be reported by <termref\r
+def="dt-validating">validating XML processors</termref>.</termdef></p>\r
+</def></gitem>\r
+<gitem><label>well-formedness constraint</label>\r
+<def>\r
+<p><termdef id="dt-wfc" term="Well-formedness constraint">A rule which applies\r
+to all <termref def="dt-wellformed">well-formed</termref> XML documents. Violations\r
+of well-formedness constraints are <termref def="dt-fatal">fatal errors</termref>.</termdef></p>\r
+</def></gitem>\r
+<gitem><label>match</label>\r
+<def>\r
+<p><termdef id="dt-match" term="match">(Of strings or names:) Two strings\r
+or names being compared must be identical. Characters with multiple possible\r
+representations in ISO/IEC 10646 (e.g. characters with both precomposed and\r
+base+diacritic forms) match only if they have the same representation in both\r
+strings. <phrase diff="del"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E85">[E85]</loc>At\r
+user option, processors may normalize such characters to some canonical form. </phrase>No\r
+case folding is performed. (Of strings and rules in the grammar:) A string\r
+matches a grammatical production if it belongs to the language generated by\r
+that production. (Of content and content models:) An element matches its declaration\r
+when it conforms in the fashion described in the constraint <specref ref="elementvalid"/>.</termdef></p>\r
+</def></gitem>\r
+<gitem><label>for compatibility</label>\r
+<def>\r
+<p><termdef id="dt-compat" term="For Compatibility"><phrase diff="add"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E87">[E87]</loc>Marks\r
+a sentence describing</phrase> a feature of XML included solely to ensure\r
+that XML remains compatible with SGML.</termdef></p>\r
+</def></gitem>\r
+<gitem><label>for interoperability</label>\r
+<def>\r
+<p><termdef id="dt-interop" term="For interoperability"><phrase diff="add"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E87">[E87]</loc>Marks\r
+a sentence describing</phrase> a non-binding recommendation included to increase\r
+the chances that XML documents can be processed by the existing installed\r
+base of SGML processors which predate the &WebSGML;.</termdef></p>\r
+</def></gitem>\r
+</glist></p>\r
+</div2>\r
+</div1>\r
+<!-- &Docs; -->\r
+<div1 id="sec-documents">\r
+<head>Documents</head>\r
+<p><termdef id="dt-xml-doc" term="XML Document"> A data object is an <term>XML\r
+document</term> if it is <termref def="dt-wellformed">well-formed</termref>,\r
+as defined in this specification. A well-formed XML document may in addition\r
+be <termref def="dt-valid">valid</termref> if it meets certain further constraints.</termdef></p>\r
+<p>Each XML document has both a logical and a physical structure. Physically,\r
+the document is composed of units called <termref def="dt-entity">entities</termref>.\r
+An entity may <termref def="dt-entref">refer</termref> to other entities to\r
+cause their inclusion in the document. A document begins in a <quote>root</quote>\r
+or <termref def="dt-docent">document entity</termref>. Logically, the document\r
+is composed of declarations, elements, comments, character references, and\r
+processing instructions, all of which are indicated in the document by explicit\r
+markup. The logical and physical structures must nest properly, as described\r
+in <specref ref="wf-entities"/>.</p>\r
+<div2 id="sec-well-formed">\r
+<head>Well-Formed XML Documents</head>\r
+<p><termdef id="dt-wellformed" term="Well-Formed"> A textual object is a <term>well-formed</term>\r
+XML document if:</termdef></p>\r
+<olist>\r
+<item><p>Taken as a whole, it matches the production labeled <nt def="NT-document">document</nt>.</p>\r
+</item>\r
+<item><p>It meets all the well-formedness constraints given in this specification.</p>\r
+</item>\r
+<item><p>Each of the <termref def="dt-parsedent">parsed entities</termref>\r
+which is referenced directly or indirectly within the document is <termref\r
+def="dt-wellformed">well-formed</termref>.</p></item>\r
+</olist>\r
+<scrap id="document" lang="ebnf">\r
+<head>Document</head>\r
+<prod id="NT-document">\r
+<lhs>document</lhs><rhs><nt def="NT-prolog">prolog</nt> <nt def="NT-element">element</nt> <nt\r
+def="NT-Misc">Misc</nt>*</rhs>\r
+</prod>\r
+</scrap>\r
+<p>Matching the <nt def="NT-document">document</nt> production implies that:</p>\r
+<olist>\r
+<item><p>It contains one or more <termref def="dt-element">elements</termref>.</p>\r
+</item>\r
+<!--* N.B. some readers (notably JC) find the following\r
+paragraph awkward and redundant. I agree it's logically redundant:\r
+it *says* it is summarizing the logical implications of\r
+matching the grammar, and that means by definition it's\r
+logically redundant. I don't think it's rhetorically\r
+redundant or unnecessary, though, so I'm keeping it. It\r
+could however use some recasting when the editors are feeling\r
+stronger. -MSM *-->\r
+<item><p><termdef id="dt-root" term="Root Element">There is exactly one element,\r
+called the <term>root</term>, or document element, no part of which appears\r
+in the <termref def="dt-content">content</termref> of any other element.</termdef> <phrase\r
+diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E17">[E17]</loc>For\r
+all other elements, if the <termref def="dt-stag">start-tag</termref> is in\r
+the content of another element, the <termref def="dt-etag">end-tag</termref>\r
+is in the content of the same element.</phrase> More simply stated, the elements,\r
+delimited by start- and end-tags, nest properly within each other.</p></item>\r
+</olist>\r
+<p><termdef id="dt-parentchild" term="Parent/Child">As a consequence of this,\r
+for each non-root element <el>C</el> in the document, there is one other element <el>P</el>\r
+in the document such that <el>C</el> is in the content of <el>P</el>, but\r
+is not in the content of any other element that is in the content of <el>P</el>. <el>P</el>\r
+is referred to as the <term>parent</term> of <el>C</el>, and <el>C</el> as\r
+a <term>child</term> of <el>P</el>.</termdef></p>\r
+</div2>\r
+<div2 id="charsets">\r
+<head>Characters</head>\r
+<p><termdef id="dt-text" term="Text">A parsed entity contains <term>text</term>,\r
+a sequence of <termref def="dt-character">characters</termref>, which may\r
+represent markup or character data.</termdef> <termdef id="dt-character" term="Character">A <term>character</term>\r
+is an atomic unit of text as specified by ISO/IEC 10646 <bibref ref="ISO10646"/> <phrase\r
+diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</loc>(see\r
+also <bibref ref="ISO10646-2000"/>)</phrase>. Legal characters are tab, carriage\r
+return, line feed, and the legal <phrase diff="del"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E35">[E35]</loc>graphic </phrase>characters\r
+of Unicode and ISO/IEC 10646. <phrase diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E69">[E69]</loc>The\r
+versions of these standards cited in <specref ref="sec-existing-stds"/> were\r
+current at the time this document was prepared. New characters may be added\r
+to these standards by amendments or new editions. Consequently, XML processors\r
+must accept any character in the range specified for <nt def="NT-Char">Char</nt>.</phrase>\r
+The use of <quote>compatibility characters</quote>, as defined in section\r
+6.8 of <bibref ref="Unicode"/> <phrase diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</loc>(see\r
+also D21 in section 3.6 of <bibref ref="Unicode3"/>)</phrase>, is discouraged.</termdef></p>\r
+<scrap id="char32" lang="ebnf">\r
+<head>Character Range</head>\r
+<prodgroup pcw2="4" pcw4="17.5" pcw5="11">\r
+<prod id="NT-Char">\r
+<lhs>Char</lhs><rhs>#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]</rhs>\r
+<com>any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.</com>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>The mechanism for encoding character code points into bit patterns may\r
+vary from entity to entity. All XML processors must accept the UTF-8 and UTF-16\r
+encodings of 10646; the mechanisms for signaling which of the two is in use,\r
+or for bringing other encodings into play, are discussed later, in <specref\r
+ref="charencoding"/>.</p>\r
+<!--\r
+<p>Regardless of the specific encoding used, any character in\r
+the ISO/IEC 10646 character set may be referred to by the decimal\r
+or hexadecimal equivalent of its UCS-4 code value.\r
+</p>-->\r
+</div2>\r
+<div2 id="sec-common-syn">\r
+<head>Common Syntactic Constructs</head>\r
+<p>This section defines some symbols used widely in the grammar.</p>\r
+<p><nt def="NT-S">S</nt> (white space) consists of one or more space (#x20)\r
+characters, carriage returns, line feeds, or tabs.</p>\r
+<scrap id="white" lang="ebnf">\r
+<head>White Space</head>\r
+<prodgroup pcw2="4" pcw4="17.5" pcw5="11">\r
+<prod id="NT-S">\r
+<lhs>S</lhs><rhs>(#x20 | #x9 | #xD | #xA)+</rhs>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>Characters are classified for convenience as letters, digits, or other\r
+characters. <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E30">[E30]</loc>A\r
+letter consists of an alphabetic or syllabic base character or an ideographic\r
+character.</phrase> Full definitions of the specific characters in each class\r
+are given in <specref ref="CharClasses"/>.</p>\r
+<p><termdef id="dt-name" term="Name">A <term>Name</term> is a token beginning\r
+with a letter or one of a few punctuation characters, and continuing with\r
+letters, digits, hyphens, underscores, colons, or full stops, together known\r
+as name characters.</termdef> Names beginning with the string <quote><code>xml</code></quote>,\r
+or any string which would match <code>(('X'|'x') ('M'|'m') ('L'|'l'))</code>,\r
+are reserved for standardization in this or future versions of this specification.</p>\r
+<note>\r
+<p diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E98">[E98]</loc>The\r
+Namespaces in XML Recommendation <bibref ref="xml-names"/> assigns a meaning\r
+to names containing colon characters. Therefore, authors should not use the\r
+colon in XML names except for namespace purposes, but XML processors must\r
+accept the colon as a name character.</p>\r
+</note>\r
+<p>An <nt def="NT-Nmtoken">Nmtoken</nt> (name token) is any mixture of name\r
+characters.</p>\r
+<scrap lang="ebnf">\r
+<head>Names and Tokens</head>\r
+<prod id="NT-NameChar">\r
+<lhs>NameChar</lhs><rhs><nt def="NT-Letter">Letter</nt> | <nt def="NT-Digit">Digit</nt>\r
+| '.' | '-' | '_' | ':' | <nt def="NT-CombiningChar">CombiningChar</nt> | <nt\r
+def="NT-Extender">Extender</nt></rhs>\r
+</prod>\r
+<prod id="NT-Name">\r
+<lhs>Name</lhs><rhs>(<nt def="NT-Letter">Letter</nt> | '_' | ':') (<nt def="NT-NameChar">NameChar</nt>)*</rhs>\r
+</prod>\r
+<prod id="NT-Names">\r
+<lhs>Names</lhs><rhs><nt def="NT-Name">Name</nt> (<nt def="NT-S">S</nt> <nt\r
+def="NT-Name">Name</nt>)*</rhs>\r
+</prod>\r
+<prod id="NT-Nmtoken">\r
+<lhs>Nmtoken</lhs><rhs>(<nt def="NT-NameChar">NameChar</nt>)+</rhs>\r
+</prod>\r
+<prod id="NT-Nmtokens">\r
+<lhs>Nmtokens</lhs><rhs><nt def="NT-Nmtoken">Nmtoken</nt> (<nt def="NT-S">S</nt> <nt\r
+def="NT-Nmtoken">Nmtoken</nt>)*</rhs>\r
+</prod>\r
+</scrap>\r
+<p>Literal data is any quoted string not containing the quotation mark used\r
+as a delimiter for that string. Literals are used for specifying the content\r
+of internal entities (<nt def="NT-EntityValue">EntityValue</nt>), the values\r
+of attributes (<nt def="NT-AttValue">AttValue</nt>), and external identifiers\r
+(<nt def="NT-SystemLiteral">SystemLiteral</nt>). Note that a <nt def="NT-SystemLiteral">SystemLiteral</nt>\r
+can be parsed without scanning for markup.</p>\r
+<scrap lang="ebnf">\r
+<head>Literals</head>\r
+<prod id="NT-EntityValue">\r
+<lhs>EntityValue</lhs><rhs>'"' ([^%&amp;"] | <nt def="NT-PEReference">PEReference</nt>\r
+| <nt def="NT-Reference">Reference</nt>)* '"' </rhs>\r
+<rhs>|&nbsp; "'" ([^%&amp;'] | <nt def="NT-PEReference">PEReference</nt> | <nt\r
+def="NT-Reference">Reference</nt>)* "'"</rhs>\r
+</prod>\r
+<prod id="NT-AttValue">\r
+<lhs>AttValue</lhs><rhs>'"' ([^&lt;&amp;"] | <nt def="NT-Reference">Reference</nt>)*\r
+'"' </rhs>\r
+<rhs>|&nbsp; "'" ([^&lt;&amp;'] | <nt def="NT-Reference">Reference</nt>)*\r
+"'"</rhs>\r
+</prod>\r
+<prod id="NT-SystemLiteral">\r
+<lhs>SystemLiteral</lhs><rhs>('"' [^"]* '"') |&nbsp;("'" [^']* "'") </rhs>\r
+</prod>\r
+<prod id="NT-PubidLiteral">\r
+<lhs>PubidLiteral</lhs><rhs>'"' <nt def="NT-PubidChar">PubidChar</nt>* '"'\r
+| "'" (<nt def="NT-PubidChar">PubidChar</nt> - "'")* "'"</rhs>\r
+</prod>\r
+<prod id="NT-PubidChar">\r
+<lhs>PubidChar</lhs><rhs>#x20 | #xD | #xA |&nbsp;[a-zA-Z0-9] |&nbsp;[-'()+,./:=?;!*#@$_%]</rhs>\r
+</prod>\r
+</scrap>\r
+<note diff="add">\r
+<p><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E72">[E72]</loc>Although\r
+the <nt def="NT-EntityValue">EntityValue</nt> production allows the definition\r
+of an entity consisting of a single explicit <code>&lt;</code> in the literal\r
+(e.g., <code>&lt;!ENTITY mylt "&lt;"></code>), it is strongly advised to avoid\r
+this practice since any reference to that entity will cause a well-formedness\r
+error.</p>\r
+</note>\r
+</div2>\r
+<div2 id="syntax">\r
+<head>Character Data and Markup</head>\r
+<p><termref def="dt-text">Text</termref> consists of intermingled <termref\r
+def="dt-chardata">character data</termref> and markup. <termdef id="dt-markup"\r
+term="Markup"><term>Markup</term> takes the form of <termref def="dt-stag">start-tags</termref>, <termref\r
+def="dt-etag">end-tags</termref>, <termref def="dt-empty">empty-element tags</termref>, <termref\r
+def="dt-entref">entity references</termref>, <termref def="dt-charref">character\r
+references</termref>, <termref def="dt-comment">comments</termref>, <termref\r
+def="dt-cdsection">CDATA section</termref> delimiters, <termref def="dt-doctype">document\r
+type declarations</termref>, <termref def="dt-pi">processing instructions</termref>, <phrase\r
+diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E89">[E89]</loc><nt\r
+def="NT-XMLDecl">XML declarations</nt>, <nt def="NT-TextDecl">text declarations</nt>,\r
+and any white space that is at the top level of the document entity (that\r
+is, outside the document element and not inside any other markup).</phrase></termdef></p>\r
+<p><termdef id="dt-chardata" term="Character Data">All text that is not markup\r
+constitutes the <term>character data</term> of the document.</termdef></p>\r
+<p>The ampersand character (&amp;) and the left angle bracket (&lt;) may appear\r
+in their literal form <emph>only</emph> when used as markup delimiters, or\r
+within a <termref def="dt-comment">comment</termref>, a <termref def="dt-pi">processing\r
+instruction</termref>, or a <termref def="dt-cdsection">CDATA section</termref>.<phrase\r
+diff="del"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E18">[E18]</loc>They\r
+are also legal within the <termref def="dt-litentval">literal entity value</termref>\r
+of an internal entity declaration; see <specref ref="wf-entities"/>.</phrase> <!-- FINAL EDIT: restore internal entity decl or leave it out. -->\r
+If they are needed elsewhere, they must be <termref def="dt-escape">escaped</termref>\r
+using either <termref def="dt-charref">numeric character references</termref>\r
+or the strings <quote><code>&amp;amp;</code></quote> and <quote><code>&amp;lt;</code></quote>\r
+respectively. The right angle bracket (>) may be represented using the string <quote><code>&amp;gt;</code></quote>,\r
+and must, <termref def="dt-compat">for compatibility</termref>, be escaped\r
+using <quote><code>&amp;gt;</code></quote> or a character reference when it\r
+appears in the string <quote><code>]]&gt;</code></quote> in content, when\r
+that string is not marking the end of a <termref def="dt-cdsection">CDATA\r
+section</termref>.</p>\r
+<p>In the content of elements, character data is any string of characters\r
+which does not contain the start-delimiter of any markup. In a CDATA section,\r
+character data is any string of characters not including the CDATA-section-close\r
+delimiter, <quote><code>]]&gt;</code></quote>.</p>\r
+<p>To allow attribute values to contain both single and double quotes, the\r
+apostrophe or single-quote character (') may be represented as <quote><code>&amp;apos;</code></quote>,\r
+and the double-quote character (") as <quote><code>&amp;quot;</code></quote>.</p>\r
+<scrap lang="ebnf">\r
+<head>Character Data</head>\r
+<prod id="NT-CharData">\r
+<lhs>CharData</lhs><rhs>[^&lt;&amp;]* - ([^&lt;&amp;]* ']]&gt;' [^&lt;&amp;]*)</rhs>\r
+</prod>\r
+</scrap>\r
+</div2>\r
+<div2 id="sec-comments">\r
+<head>Comments</head>\r
+<p><termdef id="dt-comment" term="Comment"><term>Comments</term> may appear\r
+anywhere in a document outside other <termref def="dt-markup">markup</termref>;\r
+in addition, they may appear within the document type declaration at places\r
+allowed by the grammar. They are not part of the document's <termref def="dt-chardata">character\r
+data</termref>; an XML processor may, but need not, make it possible for an\r
+application to retrieve the text of comments. <termref def="dt-compat">For\r
+compatibility</termref>, the string <quote><code>--</code></quote> (double-hyphen)\r
+must not occur within comments.</termdef> <phrase diff="add"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E63">[E63]</loc>Parameter\r
+entity references are not recognized within comments.</phrase></p>\r
+<scrap lang="ebnf">\r
+<head>Comments</head>\r
+<prod id="NT-Comment">\r
+<lhs>Comment</lhs><rhs>'&lt;!--' ((<nt def="NT-Char">Char</nt> - '-') | ('-'\r
+(<nt def="NT-Char">Char</nt> - '-')))* '-->'</rhs>\r
+</prod>\r
+</scrap>\r
+<p>An example of a comment:</p>\r
+<eg>&lt;!&como; declarations for &lt;head> &amp; &lt;body> &comc;></eg>\r
+<p diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E27">[E27]</loc>Note\r
+that the grammar does not allow a comment ending in <code>---></code>. The\r
+following example is <emph>not</emph> well-formed.</p>\r
+<eg diff="add">&lt;!-- B+, B, or B---></eg>\r
+</div2>\r
+<div2 id="sec-pi">\r
+<head>Processing Instructions</head>\r
+<p><termdef id="dt-pi" term="Processing instruction"><term>Processing instructions</term>\r
+(PIs) allow documents to contain instructions for applications.</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>Processing Instructions</head>\r
+<prod id="NT-PI">\r
+<lhs>PI</lhs><rhs>'&lt;?' <nt def="NT-PITarget">PITarget</nt> (<nt def="NT-S">S</nt>\r
+(<nt def="NT-Char">Char</nt>* - (<nt def="NT-Char">Char</nt>* &pic; <nt def="NT-Char">Char</nt>*)))? &pic;</rhs>\r
+</prod>\r
+<prod id="NT-PITarget">\r
+<lhs>PITarget</lhs><rhs><nt def="NT-Name">Name</nt> - (('X' | 'x') ('M' |\r
+'m') ('L' | 'l'))</rhs>\r
+</prod>\r
+</scrap>\r
+<p>PIs are not part of the document's <termref def="dt-chardata">character\r
+data</termref>, but must be passed through to the application. The PI begins\r
+with a target (<nt def="NT-PITarget">PITarget</nt>) used to identify the application\r
+to which the instruction is directed. The target names <quote><code>XML</code></quote>, <quote><code>xml</code></quote>,\r
+and so on are reserved for standardization in this or future versions of this\r
+specification. The XML <termref def="dt-notation">Notation</termref> mechanism\r
+may be used for formal declaration of PI targets. <phrase diff="add"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E63">[E63]</loc>Parameter\r
+entity references are not recognized within processing instructions.</phrase></p>\r
+</div2>\r
+<div2 id="sec-cdata-sect">\r
+<head>CDATA Sections</head>\r
+<p><termdef id="dt-cdsection" term="CDATA Section"><term>CDATA sections</term>\r
+may occur anywhere character data may occur; they are used to escape blocks\r
+of text containing characters which would otherwise be recognized as markup.\r
+CDATA sections begin with the string <quote><code>&lt;![CDATA[</code></quote>\r
+and end with the string <quote><code>]]&gt;</code></quote>:</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>CDATA Sections</head>\r
+<prod id="NT-CDSect">\r
+<lhs>CDSect</lhs><rhs><nt def="NT-CDStart">CDStart</nt> <nt def="NT-CData">CData</nt> <nt\r
+def="NT-CDEnd">CDEnd</nt></rhs>\r
+</prod>\r
+<prod id="NT-CDStart">\r
+<lhs>CDStart</lhs><rhs>'&lt;![CDATA['</rhs>\r
+</prod>\r
+<prod id="NT-CData">\r
+<lhs>CData</lhs><rhs>(<nt def="NT-Char">Char</nt>* - (<nt def="NT-Char">Char</nt>*\r
+']]&gt;' <nt def="NT-Char">Char</nt>*)) </rhs>\r
+</prod>\r
+<prod id="NT-CDEnd">\r
+<lhs>CDEnd</lhs><rhs>']]&gt;'</rhs>\r
+</prod>\r
+</scrap>\r
+<p>Within a CDATA section, only the <nt def="NT-CDEnd">CDEnd</nt> string is\r
+recognized as markup, so that left angle brackets and ampersands may occur\r
+in their literal form; they need not (and cannot) be escaped using <quote><code>&amp;lt;</code></quote>\r
+and <quote><code>&amp;amp;</code></quote>. CDATA sections cannot nest.</p>\r
+<p>An example of a CDATA section, in which <quote><code>&lt;greeting></code></quote>\r
+and <quote><code>&lt;/greeting></code></quote> are recognized as <termref\r
+def="dt-chardata">character data</termref>, not <termref def="dt-markup">markup</termref>:</p>\r
+<eg>&lt;![CDATA[&lt;greeting>Hello, world!&lt;/greeting>]]&gt; </eg>\r
+</div2>\r
+<div2 id="sec-prolog-dtd">\r
+<head>Prolog and Document Type Declaration</head>\r
+<p><termdef id="dt-xmldecl" term="XML Declaration">XML documents <phrase diff="chg"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E107">[E107]</loc>should</phrase>\r
+begin with an <term>XML declaration</term> which specifies the version of\r
+XML being used.</termdef> For example, the following is a complete XML document, <termref\r
+def="dt-wellformed">well-formed</termref> but not <termref def="dt-valid">valid</termref>:</p>\r
+<eg><![CDATA[<?xml version="1.0"?> <greeting>Hello, world!</greeting> ]]></eg>\r
+<p>and so is this:</p>\r
+<eg><![CDATA[<greeting>Hello, world!</greeting>]]></eg>\r
+<p>The version number <quote><code>1.0</code></quote> should be used to indicate\r
+conformance to this version of this specification; it is an error for a document\r
+to use the value <quote><code>1.0</code></quote> if it does not conform to\r
+this version of this specification. It is the intent of the XML working group\r
+to give later versions of this specification numbers other than <quote><code>1.0</code></quote>,\r
+but this intent does not indicate a commitment to produce any future versions\r
+of XML, nor if any are produced, to use any particular numbering scheme. Since\r
+future versions are not ruled out, this construct is provided as a means to\r
+allow the possibility of automatic version recognition, should it become necessary.\r
+Processors may signal an error if they receive documents labeled with versions\r
+they do not support.</p>\r
+<p>The function of the markup in an XML document is to describe its storage\r
+and logical structure and to associate attribute-value pairs with its logical\r
+structures. XML provides a mechanism, the <termref def="dt-doctype">document\r
+type declaration</termref>, to define constraints on the logical structure\r
+and to support the use of predefined storage units. <termdef id="dt-valid"\r
+term="Validity">An XML document is <term>valid</term> if it has an associated\r
+document type declaration and if the document complies with the constraints\r
+expressed in it.</termdef></p>\r
+<p>The document type declaration must appear before the first <termref def="dt-element">element</termref>\r
+in the document.</p>\r
+<scrap id="xmldoc" lang="ebnf">\r
+<head>Prolog</head>\r
+<prodgroup pcw2="6" pcw4="17.5" pcw5="9">\r
+<prod id="NT-prolog">\r
+<lhs>prolog</lhs><rhs><nt def="NT-XMLDecl">XMLDecl</nt>? <nt def="NT-Misc">Misc</nt>*\r
+(<nt def="NT-doctypedecl">doctypedecl</nt> <nt def="NT-Misc">Misc</nt>*)?</rhs>\r
+</prod>\r
+<prod id="NT-XMLDecl">\r
+<lhs>XMLDecl</lhs><rhs>&pio; <nt def="NT-VersionInfo">VersionInfo</nt> <nt\r
+def="NT-EncodingDecl">EncodingDecl</nt>? <nt def="NT-SDDecl">SDDecl</nt>? <nt\r
+def="NT-S">S</nt>? &pic;</rhs>\r
+</prod>\r
+<prod id="NT-VersionInfo" diff="chg">\r
+<lhs>VersionInfo</lhs><rhs><nt def="NT-S">S</nt> 'version' <nt def="NT-Eq">Eq</nt>\r
+("'" <nt def="NT-VersionNum">VersionNum</nt> "'" | '"' <nt def="NT-VersionNum">VersionNum</nt>\r
+'"')<com><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E15">[E15]</loc></com></rhs>\r
+</prod>\r
+<prod id="NT-Eq">\r
+<lhs>Eq</lhs><rhs><nt def="NT-S">S</nt>? '=' <nt def="NT-S">S</nt>?</rhs>\r
+</prod>\r
+<prod id="NT-VersionNum">\r
+<lhs>VersionNum</lhs><rhs>([a-zA-Z0-9_.:] | '-')+</rhs>\r
+</prod>\r
+<prod id="NT-Misc">\r
+<lhs>Misc</lhs><rhs><nt def="NT-Comment">Comment</nt> | <nt def="NT-PI">PI</nt>\r
+| <nt def="NT-S">S</nt></rhs>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p><termdef id="dt-doctype" term="Document Type Declaration">The XML <term>document\r
+type declaration</term> contains or points to <termref def="dt-markupdecl">markup\r
+declarations</termref> that provide a grammar for a class of documents. This\r
+grammar is known as a document type definition, or <term>DTD</term>. The document\r
+type declaration can point to an external subset (a special kind of <termref\r
+def="dt-extent">external entity</termref>) containing markup declarations,\r
+or can contain the markup declarations directly in an internal subset, or\r
+can do both. The DTD for a document consists of both subsets taken together.</termdef></p>\r
+<p><termdef id="dt-markupdecl" term="markup declaration"> A <term>markup declaration</term>\r
+is an <termref def="dt-eldecl">element type declaration</termref>, an <termref\r
+def="dt-attdecl">attribute-list declaration</termref>, an <termref def="dt-entdecl">entity\r
+declaration</termref>, or a <termref def="dt-notdecl">notation declaration</termref>.</termdef>\r
+These declarations may be contained in whole or in part within <termref def="dt-PE">parameter\r
+entities</termref>, as described in the well-formedness and validity constraints\r
+below. For <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E14">[E14]</loc>further</phrase>\r
+information, see <specref ref="sec-physical-struct"/>.</p>\r
+<scrap id="dtd" lang="ebnf">\r
+<head>Document Type Definition</head>\r
+<prodgroup pcw2="6" pcw4="17.5" pcw5="9">\r
+<prod id="NT-doctypedecl" diff="chg">\r
+<lhs>doctypedecl</lhs><rhs>'&lt;!DOCTYPE' <nt def="NT-S">S</nt> <nt def="NT-Name">Name</nt>\r
+(<nt def="NT-S">S</nt> <nt def="NT-ExternalID">ExternalID</nt>)? <nt def="NT-S">S</nt>?\r
+('[' (<nt def="NT-markupdecl">markupdecl</nt> | <nt diff="chg" def="NT-DeclSep">DeclSep</nt>)*\r
+']' <nt def="NT-S">S</nt>?)? '>'</rhs><vc def="vc-roottype"/><wfc def="ExtSubset"\r
+diff="add"/><com><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</loc></com>\r
+</prod>\r
+<prod id="NT-DeclSep" diff="add">\r
+<lhs>DeclSep</lhs><rhs><nt def="NT-PEReference">PEReference</nt> | <nt def="NT-S">S</nt></rhs>\r
+<wfc def="PE-between-Decls" diff="add"/><com><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</loc></com>\r
+</prod>\r
+<prod id="NT-markupdecl">\r
+<lhs>markupdecl</lhs><rhs><nt def="NT-elementdecl">elementdecl</nt> | <nt\r
+def="NT-AttlistDecl">AttlistDecl</nt> | <nt def="NT-EntityDecl">EntityDecl</nt>\r
+| <nt def="NT-NotationDecl">NotationDecl</nt> | <nt def="NT-PI">PI</nt> | <nt\r
+def="NT-Comment">Comment</nt> </rhs><vc def="vc-PEinMarkupDecl"/><wfc def="wfc-PEinInternalSubset"/>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E82">[E82]</loc>Note\r
+that it is possible to construct a well-formed document containing a <nt def="NT-doctypedecl">doctypedecl</nt>\r
+that neither points to an external subset nor contains an internal subset.</p>\r
+<p>The markup declarations may be made up in whole or in part of the <termref\r
+def="dt-repltext">replacement text</termref> of <termref def="dt-PE">parameter\r
+entities</termref>. The productions later in this specification for individual\r
+nonterminals (<nt def="NT-elementdecl">elementdecl</nt>, <nt def="NT-AttlistDecl">AttlistDecl</nt>,\r
+and so on) describe the declarations <emph>after</emph> all the parameter\r
+entities have been <termref def="dt-include">included</termref>.</p>\r
+<p diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E75">[E75]</loc>Parameter\r
+entity references are recognized anywhere in the DTD (internal and external\r
+subsets and external parameter entities), except in literals, processing instructions,\r
+comments, and the contents of ignored conditional sections (see <specref ref="sec-condition-sect"/>).\r
+They are also recognized in entity value literals. The use of parameter entities\r
+in the internal subset is restricted as described below.</p>\r
+<vcnote id="vc-roottype"><head>Root Element Type</head><p>The <nt def="NT-Name">Name</nt>\r
+in the document type declaration must match the element type of the <termref\r
+def="dt-root">root element</termref>.</p>\r
+</vcnote>\r
+<vcnote id="vc-PEinMarkupDecl"><head>Proper Declaration/PE Nesting</head>\r
+<p>Parameter-entity <termref def="dt-repltext">replacement text</termref>\r
+must be properly nested with markup declarations. That is to say, if either\r
+the first character or the last character of a markup declaration (<nt def="NT-markupdecl">markupdecl</nt>\r
+above) is contained in the replacement text for a <termref def="dt-PERef">parameter-entity\r
+reference</termref>, both must be contained in the same replacement text.</p>\r
+</vcnote>\r
+<wfcnote id="wfc-PEinInternalSubset"><head>PEs in Internal Subset</head><p>In\r
+the internal DTD subset, <termref def="dt-PERef">parameter-entity references</termref>\r
+can occur only where markup declarations can occur, not within markup declarations.\r
+(This does not apply to references that occur in external parameter entities\r
+or to the external subset.)</p>\r
+</wfcnote>\r
+<wfcnote id="ExtSubset" diff="add"><head><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</loc>External\r
+Subset</head><p>The external subset, if any, must match the production for <nt\r
+def="NT-extSubset">extSubset</nt>.</p>\r
+</wfcnote>\r
+<wfcnote id="PE-between-Decls" diff="add"><head><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</loc>PE\r
+Between Declarations</head><p>The replacement text of a parameter entity reference\r
+in a <nt def="NT-DeclSep">DeclSep</nt> must match the production <nt def="NT-extSubsetDecl">extSubsetDecl</nt>.</p>\r
+</wfcnote>\r
+<p>Like the internal subset, the external subset and any external parameter\r
+entities <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</loc>referenced\r
+in a <nt def="NT-DeclSep">DeclSep</nt></phrase> must consist of a series of\r
+complete markup declarations of the types allowed by the non-terminal symbol <nt\r
+def="NT-markupdecl">markupdecl</nt>, interspersed with white space or <termref\r
+def="dt-PERef">parameter-entity references</termref>. However, portions of\r
+the contents of the external subset or of <phrase diff="add"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</loc>these </phrase>\r
+external parameter entities may conditionally be ignored by using the <termref\r
+def="dt-cond-section">conditional section</termref> construct; this is not\r
+allowed in the internal subset.</p>\r
+<scrap id="ext-Subset">\r
+<head>External Subset</head>\r
+<prodgroup pcw2="6" pcw4="17.5" pcw5="9">\r
+<prod id="NT-extSubset">\r
+<lhs>extSubset</lhs><rhs><nt def="NT-TextDecl">TextDecl</nt>? <nt def="NT-extSubsetDecl">extSubsetDecl</nt></rhs>\r
+</prod>\r
+<prod id="NT-extSubsetDecl" diff="chg">\r
+<lhs>extSubsetDecl</lhs><rhs>( <nt def="NT-markupdecl">markupdecl</nt> | <nt\r
+def="NT-conditionalSect">conditionalSect</nt> | <nt diff="chg" def="NT-DeclSep">DeclSep</nt>)*</rhs>\r
+<com><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</loc></com>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>The external subset and external parameter entities also differ from the\r
+internal subset in that in them, <termref def="dt-PERef">parameter-entity\r
+references</termref> are permitted <emph>within</emph> markup declarations,\r
+not only <emph>between</emph> markup declarations.</p>\r
+<p>An example of an XML document with a document type declaration:</p>\r
+<eg><![CDATA[<?xml version="1.0"?> <!DOCTYPE greeting SYSTEM "hello.dtd"> <greeting>Hello, world!</greeting> ]]></eg>\r
+<p>The <termref def="dt-sysid">system identifier</termref> <quote><code>hello.dtd</code></quote>\r
+gives the <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E78">[E78]</loc>address\r
+(a URI reference)</phrase> of a DTD for the document.</p>\r
+<p>The declarations can also be given locally, as in this example:</p>\r
+<eg><![CDATA[<?xml version="1.0" encoding="UTF-8" ?>\r
+<!DOCTYPE greeting [\r
+  <!ELEMENT greeting (#PCDATA)>\r
+]>\r
+<greeting>Hello, world!</greeting>]]></eg>\r
+<p>If both the external and internal subsets are used, the internal subset\r
+is considered to occur before the external subset. <!-- 'is considered to'? boo. whazzat mean? -->\r
+This has the effect that entity and attribute-list declarations in the internal\r
+subset take precedence over those in the external subset.</p>\r
+</div2>\r
+<div2 id="sec-rmd">\r
+<head>Standalone Document Declaration</head>\r
+<p>Markup declarations can affect the content of the document, as passed from\r
+an <termref def="dt-xml-proc">XML processor</termref> to an application; examples\r
+are attribute defaults and entity declarations. The standalone document declaration,\r
+which may appear as a component of the XML declaration, signals whether or\r
+not there are such declarations which appear external to the <termref def="dt-docent">document\r
+entity</termref><phrase diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E64">[E64]</loc>\r
+or in parameter entities. <termdef id="dt-extmkpdecl" term="External Markup Declaration">An <term>external\r
+markup declaration</term> is defined as a markup declaration occurring in\r
+the external subset or in a parameter entity (external or internal, the latter\r
+being included because non-validating processors are not required to read\r
+them).</termdef></phrase></p>\r
+<scrap id="fulldtd" lang="ebnf">\r
+<head>Standalone Document Declaration</head>\r
+<prodgroup pcw2="4" pcw4="19.5" pcw5="9">\r
+<prod id="NT-SDDecl">\r
+<lhs>SDDecl</lhs><rhs> <nt def="NT-S">S</nt> 'standalone' <nt def="NT-Eq">Eq</nt>\r
+(("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"')) </rhs><vc def="vc-check-rmd"/>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>In a standalone document declaration, the value <attval>yes</attval> indicates\r
+that there are no <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E64">[E64]</loc><termref\r
+def="dt-extmkpdecl">external markup declarations</termref></phrase> which\r
+affect the information passed from the XML processor to the application. The\r
+value <attval>no</attval> indicates that there are or may be such external\r
+markup declarations. Note that the standalone document declaration only denotes\r
+the presence of external <emph>declarations</emph>; the presence, in a document,\r
+of references to external <emph>entities</emph>, when those entities are internally\r
+declared, does not change its standalone status.</p>\r
+<p>If there are no external markup declarations, the standalone document declaration\r
+has no meaning. If there are external markup declarations but there is no\r
+standalone document declaration, the value <attval>no</attval> is assumed.</p>\r
+<p>Any XML document for which <code>standalone="no"</code> holds can be converted\r
+algorithmically to a standalone document, which may be desirable for some\r
+network delivery applications.</p>\r
+<vcnote id="vc-check-rmd"><head>Standalone Document Declaration</head><p>The\r
+standalone document declaration must have the value <attval>no</attval> if\r
+any external markup declarations contain declarations of:</p>\r
+<ulist>\r
+<item><p>attributes with <termref def="dt-default">default</termref> values,\r
+if elements to which these attributes apply appear in the document without\r
+specifications of values for these attributes, or</p></item>\r
+<item><p>entities (other than &magicents;), if <termref def="dt-entref">references</termref>\r
+to those entities appear in the document, or</p></item>\r
+<item><p>attributes with values subject to <titleref href="#AVNormalize">normalization</titleref>,\r
+where the attribute appears in the document with a value which will change\r
+as a result of normalization, or</p></item>\r
+<item><p>element types with <termref def="dt-elemcontent">element content</termref>,\r
+if white space occurs directly within any instance of those types.</p></item>\r
+</ulist>\r
+</vcnote>\r
+<p>An example XML declaration with a standalone document declaration:</p>\r
+<eg>&lt;?xml version="&versionOfXML;" standalone='yes'?></eg>\r
+</div2>\r
+<div2 id="sec-white-space">\r
+<head>White Space Handling</head>\r
+<p>In editing XML documents, it is often convenient to use <quote>white space</quote>\r
+(spaces, tabs, and blank lines<phrase diff="del"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E39">[E39]</loc>,\r
+denoted by the nonterminal <nt def="NT-S">S</nt> in this specification</phrase>)\r
+to set apart the markup for greater readability. Such white space is typically\r
+not intended for inclusion in the delivered version of the document. On the\r
+other hand, <quote>significant</quote> white space that should be preserved\r
+in the delivered version is common, for example in poetry and source code.</p>\r
+<p>An <termref def="dt-xml-proc">XML processor</termref> must always pass\r
+all characters in a document that are not markup through to the application.\r
+A <termref def="dt-validating"> validating XML processor</termref> must also\r
+inform the application which of these characters constitute white space appearing\r
+in <termref def="dt-elemcontent">element content</termref>.</p>\r
+<p>A special <termref def="dt-attr">attribute</termref> named <att>xml:space</att>\r
+may be attached to an element to signal an intention that in that element,\r
+white space should be preserved by applications. In valid documents, this\r
+attribute, like any other, must be <termref def="dt-attdecl">declared</termref>\r
+if it is used. When declared, it must be given as an <termref def="dt-enumerated">enumerated\r
+type</termref> whose <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E81">[E81]</loc>values\r
+are one or both of</phrase> <attval>default</attval> and <attval>preserve</attval>.\r
+For example:</p>\r
+<eg diff="chg"><![CDATA[<!ATTLIST poem  xml:space (default|preserve) 'preserve'>]]>\r
+\r
+&lt;!-- <loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E81">[E81]</loc>-->\r
+&lt;!ATTLIST pre xml:space (preserve) #FIXED 'preserve'></eg>\r
+<p>The value <attval>default</attval> signals that applications' default white-space\r
+processing modes are acceptable for this element; the value <attval>preserve</attval>\r
+indicates the intent that applications preserve all the white space. This\r
+declared intent is considered to apply to all elements within the content\r
+of the element where it is specified, unless overriden with another instance\r
+of the <att>xml:space</att> attribute.</p>\r
+<p>The <termref def="dt-root">root element</termref> of any document is considered\r
+to have signaled no intentions as regards application space handling, unless\r
+it provides a value for this attribute or the attribute is declared with a\r
+default value.</p>\r
+</div2>\r
+<div2 id="sec-line-ends">\r
+<head>End-of-Line Handling</head>\r
+<p>XML <termref def="dt-parsedent">parsed entities</termref> are often stored\r
+in computer files which, for editing convenience, are organized into lines.\r
+These lines are typically separated by some combination of the characters\r
+carriage-return (#xD) and line-feed (#xA).</p>\r
+<p diff="del">To simplify the tasks of <termref def="dt-app">applications</termref>,\r
+wherever an external parsed entity or the literal entity value of an internal\r
+parsed entity contains either the literal two-character sequence <quote>#xD#xA</quote>\r
+or a standalone literal #xD, an <termref def="dt-xml-proc">XML processor</termref>\r
+must pass to the application the single character #xA. (This behavior can\r
+conveniently be produced by normalizing all line breaks to #xA on input, before\r
+parsing.)</p>\r
+<p diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E104">[E104]</loc>To\r
+simplify the tasks of <termref def="dt-app">applications</termref>, the characters\r
+passed to an application by the <termref def="dt-xml-proc">XML processor</termref>\r
+must be as if the XML processor normalized all line breaks in external parsed\r
+entities (including the document entity) on input, before parsing, by translating\r
+both the two-character sequence #xD #xA and any #xD that is not followed by\r
+#xA to a single #xA character.</p>\r
+</div2>\r
+<div2 id="sec-lang-tag">\r
+<head>Language Identification</head>\r
+<p>In document processing, it is often useful to identify the natural or formal\r
+language in which the content is written. A special <termref def="dt-attr">attribute</termref>\r
+named <att>xml:lang</att> may be inserted in documents to specify the language\r
+used in the contents and attribute values of any element in an XML document.\r
+In valid documents, this attribute, like any other, must be <termref def="dt-attdecl">declared</termref>\r
+if it is used. <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E73">[E73]</loc>The\r
+values of the attribute are language identifiers as defined by <bibref ref="RFC1766"/>, <titleref>Tags\r
+for the Identification of Languages</titleref>, or its successor on the IETF\r
+Standards Track.</phrase></p>\r
+<note diff="add">\r
+<p><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E73">[E73]</loc><bibref\r
+ref="RFC1766"/> tags are constructed from two-letter language codes as defined\r
+by <bibref ref="ISO639"/>, from two-letter country codes as defined by <bibref\r
+ref="ISO3166"/>, or from language identifiers registered with the Internet\r
+Assigned Numbers Authority <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E58">[E58]</loc><bibref\r
+diff="chg" ref="IANA-LANGCODES"/></phrase>. It is expected that the successor\r
+to <bibref ref="RFC1766"/> will introduce three-letter language codes for\r
+languages not presently covered by <bibref ref="ISO639"/>.</p>\r
+</note>\r
+<p diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E73">[E73]</loc>(Productions\r
+33 through 38 have been removed.)</p>\r
+<scrap diff="del" lang="ebnf">\r
+<head>Language Identification</head>\r
+<prod id="NT-LanguageID">\r
+<lhs>LanguageID</lhs><rhs><nt def="NT-Langcode">Langcode</nt> ('-' <nt def="NT-Subcode">Subcode</nt>)*</rhs>\r
+</prod>\r
+<prod id="NT-Langcode">\r
+<lhs>Langcode</lhs><rhs><nt def="NT-ISO639Code">ISO639Code</nt> | <nt def="NT-IanaCode">IanaCode</nt>\r
+| <nt def="NT-UserCode">UserCode</nt></rhs>\r
+</prod>\r
+<prod id="NT-ISO639Code">\r
+<lhs>ISO639Code</lhs><rhs>([a-z] | [A-Z]) ([a-z] | [A-Z])</rhs>\r
+</prod>\r
+<prod id="NT-IanaCode">\r
+<lhs>IanaCode</lhs><rhs>('i' | 'I') '-' ([a-z] | [A-Z])+</rhs>\r
+</prod>\r
+<prod id="NT-UserCode">\r
+<lhs>UserCode</lhs><rhs>('x' | 'X') '-' ([a-z] | [A-Z])+</rhs>\r
+</prod>\r
+<prod id="NT-Subcode">\r
+<lhs>Subcode</lhs><rhs>([a-z] | [A-Z])+</rhs>\r
+</prod>\r
+</scrap>\r
+<p diff="del">The <nt def="NT-Langcode">Langcode</nt> may be any of the following:</p>\r
+<ulist diff="del">\r
+<item><p>a two-letter language code as defined by <bibref ref="ISO639"/>, <titleref>Codes\r
+for the representation of names of languages</titleref></p></item>\r
+<item><p>a language identifier registered with the Internet Assigned Numbers\r
+Authority <bibref diff="chg" ref="IANA-LANGCODES"/>; these begin with the\r
+prefix <quote><code>i-</code></quote> (or <quote><code>I-</code></quote>)</p>\r
+</item>\r
+<item><p>a language identifier assigned by the user, or agreed on between\r
+parties in private use; these must begin with the prefix <quote><code>x-</code></quote>\r
+or <quote><code>X-</code></quote> in order to ensure that they do not conflict\r
+with names later standardized or registered with IANA</p></item>\r
+</ulist>\r
+<p diff="del">There may be any number of <nt def="NT-Subcode">Subcode</nt>\r
+segments; if the first subcode segment exists and the Subcode consists of\r
+two letters, then it must be a country code from <bibref ref="ISO3166"/>,\r
+"Codes for the representation of names of countries." If the first subcode\r
+consists of more than two letters, it must be a subcode for the language in\r
+question registered with IANA, unless the <nt def="NT-Langcode">Langcode</nt>\r
+begins with the prefix "<code>x-</code>" or "<code>X-</code>". </p>\r
+<p diff="del">It is customary to give the language code in lower case, and\r
+the country code (if any) in upper case. Note that these values, unlike other\r
+names in XML documents, are case insensitive.</p>\r
+<p>For example:</p>\r
+<eg><![CDATA[<p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>\r
+<p xml:lang="en-GB">What colour is it?</p>\r
+<p xml:lang="en-US">What color is it?</p>\r
+<sp who="Faust" desc='leise' xml:lang="de">\r
+  <l>Habe nun, ach! Philosophie,</l>\r
+  <l>Juristerei, und Medizin</l>\r
+  <l>und leider auch Theologie</l>\r
+  <l>durchaus studiert mit heißem Bemüh'n.</l>\r
+</sp>]]></eg>\r
+<!--<p>The xml:lang value is considered to apply both to the contents of an\r
+element and\r
+(unless otherwise via attribute default values) to the\r
+values of all of its attributes with free-text (CDATA) values. -->\r
+<p>The intent declared with <att>xml:lang</att> is considered to apply to\r
+all attributes and content of the element where it is specified, unless overridden\r
+with an instance of <att>xml:lang</att> on another element within that content.</p>\r
+<!--\r
+If no\r
+value is specified for xml:lang on an element, and no default value is\r
+defined for it in the DTD, then the xml:lang attribute of any element\r
+takes the same value it has in the parent element, if any. The two\r
+technical terms in the following example both have the same effective\r
+value for xml:lang:\r
+\r
+  <p xml:lang="en">Here the keywords are\r
+  <term xml:lang="en">shift</term> and\r
+  <term>reduce</term>. ...</p>\r
+\r
+The application, not the XML processor, is responsible for this '\r
+inheritance' of attribute values.\r
+-->\r
+<p>A simple declaration for <att>xml:lang</att> might take the form</p>\r
+<eg>xml:lang NMTOKEN #IMPLIED</eg>\r
+<p>but specific default values may also be given, if appropriate. In a collection\r
+of French poems for English students, with glosses and notes in English, the <att>xml:lang</att>\r
+attribute might be declared this way:</p>\r
+<eg><![CDATA[<!ATTLIST poem   xml:lang NMTOKEN 'fr'>\r
+<!ATTLIST gloss  xml:lang NMTOKEN 'en'>\r
+<!ATTLIST note   xml:lang NMTOKEN 'en'>]]></eg>\r
+</div2>\r
+</div1>\r
+<!-- &Elements; -->\r
+<div1 id="sec-logical-struct">\r
+<head>Logical Structures</head>\r
+<p><termdef id="dt-element" term="Element">Each <termref def="dt-xml-doc">XML\r
+document</termref> contains one or more <term>elements</term>, the boundaries\r
+of which are either delimited by <termref def="dt-stag">start-tags</termref>\r
+and <termref def="dt-etag">end-tags</termref>, or, for <termref def="dt-empty">empty</termref>\r
+elements, by an <termref def="dt-eetag">empty-element tag</termref>. Each\r
+element has a type, identified by name, sometimes called its <quote>generic\r
+identifier</quote> (GI), and may have a set of attribute specifications.</termdef>\r
+Each attribute specification has a <termref def="dt-attrname">name</termref>\r
+and a <termref def="dt-attrval">value</termref>.</p>\r
+<scrap lang="ebnf">\r
+<head>Element</head>\r
+<prod id="NT-element">\r
+<lhs>element</lhs><rhs><nt def="NT-EmptyElemTag">EmptyElemTag</nt></rhs>\r
+<rhs>| <nt def="NT-STag">STag</nt> <nt def="NT-content">content</nt> <nt def="NT-ETag">ETag</nt></rhs>\r
+<wfc def="GIMatch"/><vc def="elementvalid"/>\r
+</prod>\r
+</scrap>\r
+<p>This specification does not constrain the semantics, use, or (beyond syntax)\r
+names of the element types and attributes, except that names beginning with\r
+a match to <code>(('X'|'x')('M'|'m')('L'|'l'))</code> are reserved for standardization\r
+in this or future versions of this specification.</p>\r
+<wfcnote id="GIMatch"><head>Element Type Match</head><p>The <nt def="NT-Name">Name</nt>\r
+in an element's end-tag must match the element type in the start-tag.</p>\r
+</wfcnote>\r
+<vcnote id="elementvalid"><head>Element Valid</head><p>An element is valid\r
+if there is a declaration matching <nt def="NT-elementdecl">elementdecl</nt>\r
+where the <nt def="NT-Name">Name</nt> matches the element type, and one of\r
+the following holds:</p>\r
+<olist>\r
+<item><p>The declaration matches <kw>EMPTY</kw> and the element has no <termref\r
+def="dt-content">content</termref>.</p></item>\r
+<item><p>The declaration matches <nt def="NT-children">children</nt> and the\r
+sequence of <termref def="dt-parentchild">child elements</termref> belongs\r
+to the language generated by the regular expression in the content model,\r
+with optional white space (characters matching the nonterminal <nt def="NT-S">S</nt>)\r
+between <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E59">[E59]</loc>the\r
+start-tag and the first child element, between child elements, or between\r
+the last child element and the end-tag. Note that a CDATA section containing\r
+only white space does not match the nonterminal <nt def="NT-S">S</nt>, and\r
+hence cannot appear in these positions.</phrase></p></item>\r
+<item><p>The declaration matches <nt def="NT-Mixed">Mixed</nt> and the content\r
+consists of <termref def="dt-chardata">character data</termref> and <termref\r
+def="dt-parentchild">child elements</termref> whose types match names in the\r
+content model.</p></item>\r
+<item><p>The declaration matches <kw>ANY</kw>, and the types of any <termref\r
+def="dt-parentchild">child elements</termref> have been declared.</p></item>\r
+</olist>\r
+</vcnote>\r
+<div2 id="sec-starttags">\r
+<head>Start-Tags, End-Tags, and Empty-Element Tags</head>\r
+<p><termdef id="dt-stag" term="Start-Tag">The beginning of every non-empty\r
+XML element is marked by a <term>start-tag</term>.</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>Start-tag</head>\r
+<prodgroup pcw2="6" pcw4="15" pcw5="11.5">\r
+<prod id="NT-STag">\r
+<lhs>STag</lhs><rhs>'&lt;' <nt def="NT-Name">Name</nt> (<nt def="NT-S">S</nt> <nt\r
+def="NT-Attribute">Attribute</nt>)* <nt def="NT-S">S</nt>? '>'</rhs><wfc def="uniqattspec"/>\r
+</prod>\r
+<prod id="NT-Attribute">\r
+<lhs>Attribute</lhs><rhs><nt def="NT-Name">Name</nt> <nt def="NT-Eq">Eq</nt> <nt\r
+def="NT-AttValue">AttValue</nt></rhs><vc def="ValueType"/><wfc def="NoExternalRefs"/>\r
+<wfc def="CleanAttrVals"/>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>The <nt def="NT-Name">Name</nt> in the start- and end-tags gives the element's <term>type</term>. <termdef\r
+id="dt-attr" term="Attribute"> The <nt def="NT-Name">Name</nt>-<nt def="NT-AttValue">AttValue</nt>\r
+pairs are referred to as the <term>attribute specifications</term> of the\r
+element</termdef>, <termdef id="dt-attrname" term="Attribute Name">with the <nt\r
+def="NT-Name">Name</nt> in each pair referred to as the <term>attribute name</term></termdef>\r
+and <termdef id="dt-attrval" term="Attribute Value">the content of the <nt\r
+def="NT-AttValue">AttValue</nt> (the text between the <code>'</code> or <code>"</code>\r
+delimiters) as the <term>attribute value</term>.</termdef><phrase diff="add"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E46">[E46]</loc>Note\r
+that the order of attribute specifications in a start-tag or empty-element\r
+tag is not significant.</phrase></p>\r
+<wfcnote id="uniqattspec"><head>Unique Att Spec</head><p>No attribute name\r
+may appear more than once in the same start-tag or empty-element tag.</p>\r
+</wfcnote>\r
+<vcnote id="ValueType"><head>Attribute Value Type</head><p>The attribute must\r
+have been declared; the value must be of the type declared for it. (For attribute\r
+types, see <specref ref="attdecls"/>.)</p>\r
+</vcnote>\r
+<wfcnote id="NoExternalRefs"><head>No External Entity References</head><p>Attribute\r
+values cannot contain direct or indirect entity references to external entities.</p>\r
+</wfcnote>\r
+<wfcnote id="CleanAttrVals"><head>No <code>&lt;</code> in Attribute Values</head>\r
+<p>The <termref def="dt-repltext">replacement text</termref> of any entity\r
+referred to directly or indirectly in an attribute value <phrase diff="del"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E83">[E83]</loc>(other\r
+than <quote><code>&amp;lt;</code></quote>) </phrase>must not contain a <code>&lt;</code>.</p>\r
+</wfcnote>\r
+<p>An example of a start-tag:</p>\r
+<eg>&lt;termdef id="dt-dog" term="dog"></eg>\r
+<p><termdef id="dt-etag" term="End Tag">The end of every element that begins\r
+with a start-tag must be marked by an <term>end-tag</term> containing a name\r
+that echoes the element's type as given in the start-tag:</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>End-tag</head>\r
+<prodgroup pcw2="6" pcw4="15" pcw5="11.5">\r
+<prod id="NT-ETag">\r
+<lhs>ETag</lhs><rhs>'&lt;/' <nt def="NT-Name">Name</nt> <nt def="NT-S">S</nt>?\r
+'>'</rhs>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>An example of an end-tag:</p>\r
+<eg>&lt;/termdef></eg>\r
+<p><termdef id="dt-content" term="Content">The <termref def="dt-text">text</termref>\r
+between the start-tag and end-tag is called the element's <term>content</term>:</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>Content of Elements</head>\r
+<prodgroup pcw2="6" pcw4="15" pcw5="11.5">\r
+<prod id="NT-content" diff="chg">\r
+<lhs>content</lhs><rhs><nt def="NT-CharData">CharData</nt>? ((<nt def="NT-element">element</nt>\r
+| <nt def="NT-Reference">Reference</nt> | <nt def="NT-CDSect">CDSect</nt>\r
+| <nt def="NT-PI">PI</nt> | <nt def="NT-Comment">Comment</nt>) <nt def="NT-CharData">CharData</nt>?)*</rhs>\r
+<com><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E71">[E71]</loc></com>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p><phrase diff="chg"><termdef id="dt-empty" term="Empty"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E97">[E97]</loc>An element\r
+with no content is said to be <term>empty</term>.</termdef> The representation\r
+of an empty element is either a start-tag immediately followed by an end-tag,\r
+or an empty-element tag.</phrase> <termdef id="dt-eetag" term="empty-element tag">An <term>empty-element\r
+tag</term> takes a special form:</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>Tags for Empty Elements</head>\r
+<prodgroup pcw2="6" pcw4="15" pcw5="11.5">\r
+<prod id="NT-EmptyElemTag">\r
+<lhs>EmptyElemTag</lhs><rhs>'&lt;' <nt def="NT-Name">Name</nt> (<nt def="NT-S">S</nt> <nt\r
+def="NT-Attribute">Attribute</nt>)* <nt def="NT-S">S</nt>? '/>'</rhs><wfc\r
+def="uniqattspec"/>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>Empty-element tags may be used for any element which has no content, whether\r
+or not it is declared using the keyword <kw>EMPTY</kw>. <termref def="dt-interop">For\r
+interoperability</termref>, the empty-element tag <phrase diff="chg"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E45">[E45]</loc>should\r
+be used, and should only be used,</phrase> for elements which are declared\r
+EMPTY.</p>\r
+<p>Examples of empty elements:</p>\r
+<eg>&lt;IMG align="left"\r
+ src="http://www.w3.org/Icons/WWW/w3c_home" />\r
+&lt;br>&lt;/br>\r
+&lt;br/></eg>\r
+</div2>\r
+<div2 id="elemdecls">\r
+<head>Element Type Declarations</head>\r
+<p>The <termref def="dt-element">element</termref> structure of an <termref\r
+def="dt-xml-doc">XML document</termref> may, for <termref def="dt-valid">validation</termref>\r
+purposes, be constrained using element type and attribute-list declarations.\r
+An element type declaration constrains the element's <termref def="dt-content">content</termref>.</p>\r
+<p>Element type declarations often constrain which element types can appear\r
+as <termref def="dt-parentchild">children</termref> of the element. At user\r
+option, an XML processor may issue a warning when a declaration mentions an\r
+element type for which no declaration is provided, but this is not an error.</p>\r
+<p><termdef id="dt-eldecl" term="Element Type declaration">An <term>element\r
+type declaration</term> takes the form:</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>Element Type Declaration</head>\r
+<prodgroup pcw2="5.5" pcw4="18" pcw5="9">\r
+<prod id="NT-elementdecl">\r
+<lhs>elementdecl</lhs><rhs>'&lt;!ELEMENT' <nt def="NT-S">S</nt> <nt def="NT-Name">Name</nt> <nt\r
+def="NT-S">S</nt> <nt def="NT-contentspec">contentspec</nt> <nt def="NT-S">S</nt>?\r
+'>'</rhs><vc def="EDUnique"/>\r
+</prod>\r
+<prod id="NT-contentspec">\r
+<lhs>contentspec</lhs><rhs>'EMPTY' | 'ANY' | <nt def="NT-Mixed">Mixed</nt>\r
+| <nt def="NT-children">children</nt> </rhs>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>where the <nt def="NT-Name">Name</nt> gives the element type being declared.</p>\r
+<vcnote id="EDUnique"><head>Unique Element Type Declaration</head><p>No element\r
+type may be declared more than once.</p>\r
+</vcnote>\r
+<p>Examples of element type declarations:</p>\r
+<eg>&lt;!ELEMENT br EMPTY>\r
+&lt;!ELEMENT p (#PCDATA|emph)* >\r
+&lt;!ELEMENT %name.para; %content.para; >\r
+&lt;!ELEMENT container ANY></eg>\r
+<div3 id="sec-element-content">\r
+<head>Element Content</head>\r
+<p><termdef id="dt-elemcontent" term="Element content">An element <termref\r
+def="dt-stag">type</termref> has <term>element content</term> when elements\r
+of that type must contain only <termref def="dt-parentchild">child</termref>\r
+elements (no character data), optionally separated by white space (characters\r
+matching the nonterminal <nt def="NT-S">S</nt>).</termdef><termdef id="dt-content-model"\r
+term="Content model">In this case, the constraint includes a <phrase diff="chg"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E55">[E55]</loc><term>content\r
+model</term></phrase>, a simple grammar governing the allowed types of the\r
+child elements and the order in which they are allowed to appear.</termdef>\r
+The grammar is built on content particles (<nt def="NT-cp">cp</nt>s), which\r
+consist of names, choice lists of content particles, or sequence lists of\r
+content particles:</p>\r
+<scrap lang="ebnf">\r
+<head>Element-content Models</head>\r
+<prodgroup pcw2="5.5" pcw4="16" pcw5="11">\r
+<prod id="NT-children">\r
+<lhs>children</lhs><rhs>(<nt def="NT-choice">choice</nt> | <nt def="NT-seq">seq</nt>)\r
+('?' | '*' | '+')?</rhs>\r
+</prod>\r
+<prod id="NT-cp">\r
+<lhs>cp</lhs><rhs>(<nt def="NT-Name">Name</nt> | <nt def="NT-choice">choice</nt>\r
+| <nt def="NT-seq">seq</nt>) ('?' | '*' | '+')?</rhs>\r
+</prod>\r
+<prod id="NT-choice" diff="chg">\r
+<lhs>choice</lhs><rhs>'(' <nt def="NT-S">S</nt>? <nt def="NT-cp">cp</nt> ( <nt\r
+def="NT-S">S</nt>? '|' <nt def="NT-S">S</nt>? <nt def="NT-cp">cp</nt> )+ <nt\r
+def="NT-S">S</nt>? ')'</rhs><com><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E50">[E50]</loc></com>\r
+<com><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E52">[E52]</loc></com>\r
+<vc def="vc-PEinGroup"/>\r
+</prod>\r
+<prod id="NT-seq" diff="chg">\r
+<lhs>seq</lhs><rhs>'(' <nt def="NT-S">S</nt>? <nt def="NT-cp">cp</nt> ( <nt\r
+def="NT-S">S</nt>? ',' <nt def="NT-S">S</nt>? <nt def="NT-cp">cp</nt> )* <nt\r
+def="NT-S">S</nt>? ')'</rhs><com><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E52">[E52]</loc></com>\r
+<vc def="vc-PEinGroup"/>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>where each <nt def="NT-Name">Name</nt> is the type of an element which\r
+may appear as a <termref def="dt-parentchild">child</termref>. Any content\r
+particle in a choice list may appear in the <termref def="dt-elemcontent">element\r
+content</termref> at the location where the choice list appears in the grammar;\r
+content particles occurring in a sequence list must each appear in the <termref\r
+def="dt-elemcontent">element content</termref> in the order given in the list.\r
+The optional character following a name or list governs whether the element\r
+or the content particles in the list may occur one or more (<code>+</code>),\r
+zero or more (<code>*</code>), or zero or one times (<code>?</code>). The\r
+absence of such an operator means that the element or content particle must\r
+appear exactly once. This syntax and meaning are identical to those used in\r
+the productions in this specification.</p>\r
+<p>The content of an element matches a content model if and only if it is\r
+possible to trace out a path through the content model, obeying the sequence,\r
+choice, and repetition operators and matching each element in the content\r
+against an element type in the content model. <termref def="dt-compat">For\r
+compatibility</termref>, it is an error if an element in the document can\r
+match more than one occurrence of an element type in the content model. For\r
+more information, see <specref ref="determinism"/>.</p>\r
+<!--appendix <specref ref="determinism"/>.-->\r
+<!-- appendix on deterministic content models. -->\r
+<vcnote id="vc-PEinGroup"><head>Proper Group/PE Nesting</head><p>Parameter-entity <termref\r
+def="dt-repltext">replacement text</termref> must be properly nested with <phrase\r
+diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E11">[E11]</loc>parenthesized</phrase>\r
+groups. That is to say, if either of the opening or closing parentheses in\r
+a <nt def="NT-choice">choice</nt>, <nt def="NT-seq">seq</nt>, or <nt def="NT-Mixed">Mixed</nt>\r
+construct is contained in the replacement text for a <termref def="dt-PERef">parameter\r
+entity</termref>, both must be contained in the same replacement text.</p>\r
+<p diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E19">[E19]</loc><termref\r
+def="dt-interop">For interoperability</termref>, if a parameter-entity reference\r
+appears in a <nt def="NT-choice">choice</nt>, <nt def="NT-seq">seq</nt>, or <nt\r
+def="NT-Mixed">Mixed</nt> construct, its replacement text should contain at\r
+least one non-blank character, and neither the first nor last non-blank character\r
+of the replacement text should be a connector (<code>|</code> or <code>,</code>).</p>\r
+</vcnote>\r
+<p>Examples of element-content models:</p>\r
+<eg>&lt;!ELEMENT spec (front, body, back?)>\r
+&lt;!ELEMENT div1 (head, (p | list | note)*, div2*)>\r
+&lt;!ELEMENT dictionary-body (%div.mix; | %dict.mix;)*></eg>\r
+</div3>\r
+<div3 id="sec-mixed-content">\r
+<head>Mixed Content</head>\r
+<p><termdef id="dt-mixed" term="Mixed Content">An element <termref def="dt-stag">type</termref>\r
+has <term>mixed content</term> when elements of that type may contain character\r
+data, optionally interspersed with <termref def="dt-parentchild">child</termref>\r
+elements.</termdef> In this case, the types of the child elements may be constrained,\r
+but not their order or their number of occurrences:</p>\r
+<scrap lang="ebnf">\r
+<head>Mixed-content Declaration</head>\r
+<prodgroup pcw2="5.5" pcw4="16" pcw5="11">\r
+<prod id="NT-Mixed">\r
+<lhs>Mixed</lhs><rhs>'(' <nt def="NT-S">S</nt>? '#PCDATA' (<nt def="NT-S">S</nt>?\r
+'|' <nt def="NT-S">S</nt>? <nt def="NT-Name">Name</nt>)* <nt def="NT-S">S</nt>?\r
+')*' </rhs>\r
+<rhs>| '(' <nt def="NT-S">S</nt>? '#PCDATA' <nt def="NT-S">S</nt>? ')' </rhs>\r
+<vc def="vc-PEinGroup"/><vc def="vc-MixedChildrenUnique"/>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>where the <nt def="NT-Name">Name</nt>s give the types of elements that\r
+may appear as children. <phrase diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E10">[E10]</loc>The\r
+keyword <kw>#PCDATA</kw> derives historically from the term <quote>parsed\r
+character data.</quote></phrase></p>\r
+<vcnote id="vc-MixedChildrenUnique"><head>No Duplicate Types</head><p>The\r
+same name must not appear more than once in a single mixed-content declaration.</p>\r
+</vcnote>\r
+<p>Examples of mixed content declarations:</p>\r
+<eg>&lt;!ELEMENT p (#PCDATA|a|ul|b|i|em)*>\r
+&lt;!ELEMENT p (#PCDATA | %font; | %phrase; | %special; | %form;)* >\r
+&lt;!ELEMENT b (#PCDATA)></eg>\r
+</div3>\r
+</div2>\r
+<div2 id="attdecls">\r
+<head>Attribute-List Declarations</head>\r
+<p><termref def="dt-attr">Attributes</termref> are used to associate name-value\r
+pairs with <termref def="dt-element">elements</termref>. Attribute specifications\r
+may appear only within <termref def="dt-stag">start-tags</termref> and <termref\r
+def="dt-eetag">empty-element tags</termref>; thus, the productions used to\r
+recognize them appear in <specref ref="sec-starttags"/>. Attribute-list declarations\r
+may be used:</p>\r
+<ulist>\r
+<item><p>To define the set of attributes pertaining to a given element type.</p>\r
+</item>\r
+<item><p>To establish type constraints for these attributes.</p></item>\r
+<item><p>To provide <termref def="dt-default">default values</termref> for\r
+attributes.</p></item>\r
+</ulist>\r
+<p><termdef id="dt-attdecl" term="Attribute-List Declaration"> <term>Attribute-list\r
+declarations</term> specify the name, data type, and default value (if any)\r
+of each attribute associated with a given element type:</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>Attribute-list Declaration</head>\r
+<prod id="NT-AttlistDecl">\r
+<lhs>AttlistDecl</lhs><rhs>'&lt;!ATTLIST' <nt def="NT-S">S</nt> <nt def="NT-Name">Name</nt> <nt\r
+def="NT-AttDef">AttDef</nt>* <nt def="NT-S">S</nt>? '>'</rhs>\r
+</prod>\r
+<prod id="NT-AttDef">\r
+<lhs>AttDef</lhs><rhs><nt def="NT-S">S</nt> <nt def="NT-Name">Name</nt> <nt\r
+def="NT-S">S</nt> <nt def="NT-AttType">AttType</nt> <nt def="NT-S">S</nt> <nt\r
+def="NT-DefaultDecl">DefaultDecl</nt></rhs>\r
+</prod>\r
+</scrap>\r
+<p>The <nt def="NT-Name">Name</nt> in the <nt def="NT-AttlistDecl">AttlistDecl</nt>\r
+rule is the type of an element. At user option, an XML processor may issue\r
+a warning if attributes are declared for an element type not itself declared,\r
+but this is not an error. The <nt def="NT-Name">Name</nt> in the <nt def="NT-AttDef">AttDef</nt>\r
+rule is the name of the attribute.</p>\r
+<p>When more than one <nt def="NT-AttlistDecl">AttlistDecl</nt> is provided\r
+for a given element type, the contents of all those provided are merged. When\r
+more than one definition is provided for the same attribute of a given element\r
+type, the first declaration is binding and later declarations are ignored. <phrase\r
+diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E9">[E9]</loc><termref\r
+def="dt-interop">For interoperability,</termref> writers of DTDs may choose\r
+to provide at most one attribute-list declaration for a given element type,\r
+at most one attribute definition for a given attribute name in an attribute-list\r
+declaration, and at least one attribute definition in each attribute-list\r
+declaration.</phrase> For interoperability, an XML processor may at user option\r
+issue a warning when more than one attribute-list declaration is provided\r
+for a given element type, or more than one attribute definition is provided\r
+for a given attribute, but this is not an error.</p>\r
+<div3 id="sec-attribute-types">\r
+<head>Attribute Types</head>\r
+<p>XML attribute types are of three kinds: a string type, a set of tokenized\r
+types, and enumerated types. The string type may take any literal string as\r
+a value; the tokenized types have varying lexical and semantic constraints<phrase\r
+diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E8">[E8]</loc>.\r
+The validity constraints noted in the grammar are applied after the attribute\r
+value has been normalized as described in <specref ref="attdecls"/>.</phrase></p>\r
+<scrap lang="ebnf">\r
+<head>Attribute Types</head>\r
+<prodgroup pcw4="14" pcw5="11.5">\r
+<prod id="NT-AttType">\r
+<lhs>AttType</lhs><rhs><nt def="NT-StringType">StringType</nt> | <nt def="NT-TokenizedType">TokenizedType</nt>\r
+| <nt def="NT-EnumeratedType">EnumeratedType</nt> </rhs>\r
+</prod>\r
+<prod id="NT-StringType">\r
+<lhs>StringType</lhs><rhs>'CDATA'</rhs>\r
+</prod>\r
+<prod id="NT-TokenizedType">\r
+<lhs>TokenizedType</lhs><rhs>'ID'</rhs><vc def="id"/><vc def="one-id-per-el"/>\r
+<vc def="id-default"/>\r
+<rhs>| 'IDREF'</rhs><vc def="idref"/>\r
+<rhs>| 'IDREFS'</rhs><vc def="idref"/>\r
+<rhs>| 'ENTITY'</rhs><vc def="entname"/>\r
+<rhs>| 'ENTITIES'</rhs><vc def="entname"/>\r
+<rhs>| 'NMTOKEN'</rhs><vc def="nmtok"/>\r
+<rhs>| 'NMTOKENS'</rhs><vc def="nmtok"/>\r
+</prod>\r
+</prodgroup></scrap>\r
+<vcnote id="id"><head>ID</head><p>Values of type <kw>ID</kw> must match the <nt\r
+def="NT-Name">Name</nt> production. A name must not appear more than once\r
+in an XML document as a value of this type; i.e., ID values must uniquely\r
+identify the elements which bear them.</p>\r
+</vcnote>\r
+<vcnote id="one-id-per-el"><head>One ID per Element Type</head><p>No element\r
+type may have more than one ID attribute specified.</p>\r
+</vcnote>\r
+<vcnote id="id-default"><head>ID Attribute Default</head><p>An ID attribute\r
+must have a declared default of <kw>#IMPLIED</kw> or <kw>#REQUIRED</kw>.</p>\r
+</vcnote>\r
+<vcnote id="idref"><head>IDREF</head><p>Values of type <kw>IDREF</kw> must\r
+match the <nt def="NT-Name">Name</nt> production, and values of type <kw>IDREFS</kw>\r
+must match <nt def="NT-Names">Names</nt>; each <nt def="NT-Name">Name</nt>\r
+must match the value of an ID attribute on some element in the XML document;\r
+i.e. <kw>IDREF</kw> values must match the value of some ID attribute.</p>\r
+</vcnote>\r
+<vcnote id="entname"><head>Entity Name</head><p>Values of type <kw>ENTITY</kw>\r
+must match the <nt def="NT-Name">Name</nt> production, values of type <kw>ENTITIES</kw>\r
+must match <nt def="NT-Names">Names</nt>; each <nt def="NT-Name">Name</nt>\r
+must match the name of an <termref def="dt-unparsed">unparsed entity</termref>\r
+declared in the <termref def="dt-doctype">DTD</termref>.</p>\r
+</vcnote>\r
+<vcnote id="nmtok"><head>Name Token</head><p>Values of type <kw>NMTOKEN</kw>\r
+must match the <nt def="NT-Nmtoken">Nmtoken</nt> production; values of type <kw>NMTOKENS</kw>\r
+must match <termref def="NT-Nmtokens">Nmtokens</termref>.</p>\r
+</vcnote>\r
+<!-- why?\r
+<p>The XML processor must normalize attribute values before\r
+passing them to the application, as described in\r
+<specref ref="AVNormalize"/>.</p>-->\r
+<p><termdef id="dt-enumerated" term="Enumerated Attribute\r
+Values"><term>Enumerated attributes</term> can take one of a list of values\r
+provided in the declaration</termdef>. There are two kinds of enumerated types:</p>\r
+<scrap lang="ebnf">\r
+<head>Enumerated Attribute Types</head>\r
+<prod id="NT-EnumeratedType">\r
+<lhs>EnumeratedType</lhs><rhs><nt def="NT-NotationType">NotationType</nt>\r
+| <nt def="NT-Enumeration">Enumeration</nt> </rhs>\r
+</prod>\r
+<prod id="NT-NotationType">\r
+<lhs>NotationType</lhs><rhs>'NOTATION' <nt def="NT-S">S</nt> '(' <nt def="NT-S">S</nt>? <nt\r
+def="NT-Name">Name</nt> (<nt def="NT-S">S</nt>? '|' <nt def="NT-S">S</nt>? <nt\r
+def="NT-Name">Name</nt>)* <nt def="NT-S">S</nt>? ')' </rhs><vc def="notatn"/>\r
+<vc def="OneNotationPer" diff="add"/><vc def="NoNotationEmpty" diff="add"/>\r
+</prod>\r
+<prod id="NT-Enumeration">\r
+<lhs>Enumeration</lhs><rhs>'(' <nt def="NT-S">S</nt>? <nt def="NT-Nmtoken">Nmtoken</nt>\r
+(<nt def="NT-S">S</nt>? '|' <nt def="NT-S">S</nt>? <nt def="NT-Nmtoken">Nmtoken</nt>)* <nt\r
+def="NT-S">S</nt>? ')'</rhs><vc def="enum"/>\r
+</prod>\r
+</scrap>\r
+<p>A <kw>NOTATION</kw> attribute identifies a <termref def="dt-notation">notation</termref>,\r
+declared in the DTD with associated system and/or public identifiers, to be\r
+used in interpreting the element to which the attribute is attached.</p>\r
+<vcnote id="notatn"><head>Notation Attributes</head><p>Values of this type\r
+must match one of the <titleref href="#Notations">notation</titleref> names\r
+included in the declaration; all notation names in the declaration must be\r
+declared.</p>\r
+</vcnote>\r
+<vcnote id="OneNotationPer" diff="add"><head><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E7">[E7]</loc>One\r
+Notation Per Element Type</head><p>No element type may have more than one <kw>NOTATION</kw>\r
+attribute specified.</p>\r
+</vcnote>\r
+<vcnote id="NoNotationEmpty" diff="add"><head><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E68">[E68]</loc>No\r
+Notation on Empty Element</head><p><termref def="dt-compat">For compatibility</termref>,\r
+an attribute of type <kw>NOTATION</kw> must not be declared on an element\r
+declared <kw>EMPTY</kw>.</p>\r
+</vcnote>\r
+<vcnote id="enum"><head>Enumeration</head><p>Values of this type must match\r
+one of the <nt def="NT-Nmtoken">Nmtoken</nt> tokens in the declaration.</p>\r
+</vcnote>\r
+<p><termref def="dt-interop">For interoperability,</termref> the same <nt\r
+def="NT-Nmtoken">Nmtoken</nt> should not occur more than once in the enumerated\r
+attribute types of a single element type.</p>\r
+</div3>\r
+<div3 id="sec-attr-defaults">\r
+<head>Attribute Defaults</head>\r
+<p>An <termref def="dt-attdecl">attribute declaration</termref> provides information\r
+on whether the attribute's presence is required, and if not, how an XML processor\r
+should react if a declared attribute is absent in a document.</p>\r
+<scrap lang="ebnf">\r
+<head>Attribute Defaults</head>\r
+<prodgroup pcw4="14" pcw5="11.5">\r
+<prod id="NT-DefaultDecl">\r
+<lhs>DefaultDecl</lhs><rhs>'#REQUIRED' |&nbsp;'#IMPLIED' </rhs>\r
+<rhs>| (('#FIXED' S)? <nt def="NT-AttValue">AttValue</nt>)</rhs><vc def="RequiredAttr"/>\r
+<vc def="defattrvalid"/><wfc def="CleanAttrVals"/><vc def="FixedAttr"/>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>In an attribute declaration, <kw>#REQUIRED</kw> means that the attribute\r
+must always be provided, <kw>#IMPLIED</kw> that no default value is provided. <!-- not any more!!\r
+<kw>#IMPLIED</kw> means that if the attribute is omitted\r
+from an element of this type,\r
+the XML processor must inform the application\r
+that no value was specified; no constraint is placed on the behavior\r
+of the application. --> <termdef id="dt-default" term="Attribute Default">If\r
+the declaration is neither <kw>#REQUIRED</kw> nor <kw>#IMPLIED</kw>, then\r
+the <nt def="NT-AttValue">AttValue</nt> value contains the declared <term>default</term>\r
+value; the <kw>#FIXED</kw> keyword states that the attribute must always have\r
+the default value. If a default value is declared, when an XML processor encounters\r
+an omitted attribute, it is to behave as though the attribute were present\r
+with the declared default value.</termdef></p>\r
+<vcnote id="RequiredAttr"><head>Required Attribute</head><p>If the default\r
+declaration is the keyword <kw>#REQUIRED</kw>, then the attribute must be\r
+specified for all elements of the type in the attribute-list declaration.</p>\r
+</vcnote>\r
+<vcnote id="defattrvalid"><head>Attribute Default Legal</head><p>The declared\r
+default value must meet the lexical constraints of the declared attribute\r
+type.</p>\r
+</vcnote>\r
+<vcnote id="FixedAttr"><head>Fixed Attribute Default</head><p>If an attribute\r
+has a default value declared with the <kw>#FIXED</kw> keyword, instances of\r
+that attribute must match the default value.</p>\r
+</vcnote>\r
+<p>Examples of attribute-list declarations:</p>\r
+<eg>&lt;!ATTLIST termdef\r
+          id      ID      #REQUIRED\r
+          name    CDATA   #IMPLIED>\r
+&lt;!ATTLIST list\r
+          type    (bullets|ordered|glossary)  "ordered">\r
+&lt;!ATTLIST form\r
+          method  CDATA   #FIXED "POST"></eg>\r
+</div3>\r
+<div3 id="AVNormalize" diff="chg">\r
+<head><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E70">[E70]</loc>Attribute-Value\r
+Normalization</head>\r
+<p>Before the value of an attribute is passed to the application or checked\r
+for validity, the XML processor must normalize the attribute value by applying\r
+the algorithm below, or by using some other method such that the value passed\r
+to the application is the same as that produced by the algorithm.</p>\r
+<olist>\r
+<item><p>All line breaks must have been normalized on input to #xA as described\r
+in <specref ref="sec-line-ends"/>, so the rest of this algorithm operates\r
+on text normalized in this way.</p></item>\r
+<item><p>Begin with a normalized value consisting of the empty string.</p>\r
+</item>\r
+<item><p>For each character, entity reference, or character reference in the\r
+unnormalized attribute value, beginning with the first and continuing to the\r
+last, do the following:</p>\r
+<ulist>\r
+<item><p>For a character reference, append the referenced character to the\r
+normalized value.</p></item>\r
+<item><p>For an entity reference, recursively apply step 3 of this algorithm\r
+to the replacement text of the entity.</p></item>\r
+<item><p>For a white space character (#x20, #xD, #xA, #x9), append a space\r
+character (#x20) to the normalized value.</p></item>\r
+<item><p>For another character, append the character to the normalized value.</p>\r
+</item>\r
+</ulist>\r
+</item>\r
+</olist>\r
+<p>If the attribute type is not CDATA, then the XML processor must further\r
+process the normalized attribute value by discarding any leading and trailing\r
+space (#x20) characters, and by replacing sequences of space (#x20) characters\r
+by a single space (#x20) character.</p>\r
+<p>Note that if the unnormalized attribute value contains a character reference\r
+to a white space character other than space (#x20), the normalized value contains\r
+the referenced character itself (#xD, #xA or #x9). This contrasts with the\r
+case where the unnormalized value contains a white space character (not a\r
+reference), which is replaced with a space character (#x20) in the normalized\r
+value and also contrasts with the case where the unnormalized value contains\r
+an entity reference whose replacement text contains a white space character;\r
+being recursively processed, the white space character is replaced with a\r
+space character (#x20) in the normalized value.</p>\r
+<p>All attributes for which no declaration has been read should be treated\r
+by a non-validating <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E95">[E95]</loc>processor</phrase>\r
+as if declared <kw>CDATA</kw>.</p>\r
+<p>Following are examples of attribute normalization. Given the following\r
+declarations:</p>\r
+<eg>&lt;!ENTITY d "&amp;#xD;">\r
+&lt;!ENTITY a "&amp;#xA;">\r
+&lt;!ENTITY da "&amp;#xD;&amp;#xA;"></eg>\r
+<p>the attribute specifications in the left column below would be normalized\r
+to the character sequences of the middle column if the attribute <att>a</att>\r
+is declared <kw>NMTOKENS</kw> and to those of the right columns if <att>a</att>\r
+is declared <kw>CDATA</kw>.</p>\r
+<table border="1" frame="border"><thead><tr><th>Attribute specification</th>\r
+<th>a is NMTOKENS</th><th>a is CDATA</th></tr></thead><tbody><tr><td><eg>a="\r
+\r
+xyz"</eg></td><td><code>x y z</code></td><td><code>#x20 #x20 x y z</code></td>\r
+</tr><tr><td><eg>a="&amp;d;&amp;d;A&amp;a;&amp;a;B&amp;da;"</eg></td><td><code>A\r
+#x20 B</code></td><td><code>#x20 #x20 A #x20 #x20 B #x20 #x20</code></td>\r
+</tr><tr><td><eg>a=\r
+"&amp;#xd;&amp;#xd;A&amp;#xa;&amp;#xa;B&amp;#xd;&amp;#xa;"</eg></td><td><code>#xD\r
+#xD A #xA #xA B #xD #xA</code></td><td><code>#xD #xD A #xA #xA B #xD #xD</code></td>\r
+</tr></tbody></table>\r
+<p>Note that the last example is invalid (but well-formed) if <att>a</att>\r
+is declared to be of type <kw>NMTOKENS</kw>.</p>\r
+</div3>\r
+</div2>\r
+<div2 id="sec-condition-sect">\r
+<head>Conditional Sections</head>\r
+<p><termdef id="dt-cond-section" term="conditional section"> <term>Conditional\r
+sections</term> are portions of the <termref def="dt-doctype">document type\r
+declaration external subset</termref> which are included in, or excluded from,\r
+the logical structure of the DTD based on the keyword which governs them.</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>Conditional Section</head>\r
+<prodgroup pcw2="9" pcw4="14.5">\r
+<prod id="NT-conditionalSect">\r
+<lhs>conditionalSect</lhs><rhs><nt def="NT-includeSect">includeSect</nt> | <nt\r
+def="NT-ignoreSect">ignoreSect</nt> </rhs>\r
+</prod>\r
+<prod id="NT-includeSect">\r
+<lhs>includeSect</lhs><rhs>'&lt;![' S? 'INCLUDE' S? '[' <nt def="NT-extSubsetDecl">extSubsetDecl</nt>\r
+']]&gt;' </rhs><com><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</loc></com>\r
+<vc def="condsec-nesting" diff="add"/>\r
+</prod>\r
+<prod id="NT-ignoreSect">\r
+<lhs>ignoreSect</lhs><rhs>'&lt;![' S? 'IGNORE' S? '[' <nt def="NT-ignoreSectContents">ignoreSectContents</nt>*\r
+']]&gt;'</rhs><com><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</loc></com>\r
+<vc def="condsec-nesting" diff="add"/>\r
+</prod>\r
+<prod id="NT-ignoreSectContents">\r
+<lhs>ignoreSectContents</lhs><rhs><nt def="NT-Ignore">Ignore</nt> ('&lt;![' <nt\r
+def="NT-ignoreSectContents">ignoreSectContents</nt> ']]&gt;' <nt def="NT-Ignore">Ignore</nt>)*</rhs>\r
+</prod>\r
+<prod id="NT-Ignore">\r
+<lhs>Ignore</lhs><rhs><nt def="NT-Char">Char</nt>* - (<nt def="NT-Char">Char</nt>*\r
+('&lt;![' | ']]&gt;') <nt def="NT-Char">Char</nt>*) </rhs>\r
+</prod>\r
+</prodgroup></scrap>\r
+<vcnote id="condsec-nesting" diff="add"><head><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</loc>Proper\r
+Conditional Section/PE Nesting</head><p>If any of the "<code>&lt;![</code>",\r
+"<code>[</code>", or "<code>]]&gt;</code>" of a conditional section is contained\r
+in the replacement text for a parameter-entity reference, all of them must\r
+be contained in the same replacement text.</p>\r
+</vcnote>\r
+<p>Like the internal and external DTD subsets, a conditional section may contain\r
+one or more complete declarations, comments, processing instructions, or nested\r
+conditional sections, intermingled with white space.</p>\r
+<p>If the keyword of the conditional section is <kw>INCLUDE</kw>, then the\r
+contents of the conditional section are part of the DTD. If the keyword of\r
+the conditional section is <kw>IGNORE</kw>, then the contents of the conditional\r
+section are not logically part of the DTD. <phrase diff="del"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</loc>Note that\r
+for reliable parsing, the contents of even ignored conditional sections must\r
+be read in order to detect nested conditional sections and ensure that the\r
+end of the outermost (ignored) conditional section is properly detected.</phrase>\r
+If a conditional section with a keyword of <kw>INCLUDE</kw> occurs within\r
+a larger conditional section with a keyword of <kw>IGNORE</kw>, both the outer\r
+and the inner conditional sections are ignored.<phrase diff="add"> <loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</loc>The contents\r
+of an ignored conditional section are parsed by ignoring all characters after\r
+the "<code>[</code>" following the keyword, except conditional section starts\r
+"<code>&lt;![</code>" and ends "<code>]]&gt;</code>", until the matching conditional\r
+section end is found. Parameter entity references are not recognized in this\r
+process.</phrase></p>\r
+<p>If the keyword of the conditional section is a parameter-entity reference,\r
+the parameter entity must be replaced by its content before the processor\r
+decides whether to include or ignore the conditional section.</p>\r
+<p>An example:</p>\r
+<eg>&lt;!ENTITY % draft 'INCLUDE' >\r
+&lt;!ENTITY % final 'IGNORE' >\r
+\r
+&lt;![%draft;[\r
+&lt;!ELEMENT book (comments*, title, body, supplements?)>\r
+]]&gt;\r
+&lt;![%final;[\r
+&lt;!ELEMENT book (title, body, supplements?)>\r
+]]&gt;</eg>\r
+</div2>\r
+<!--\r
+<div2 id='sec-pass-to-app'>\r
+<head>XML Processor Treatment of Logical Structure</head>\r
+<p>When an XML processor encounters a start-tag, it must make\r
+at least the following information available to the application:\r
+<ulist>\r
+<item>\r
+<p>the element type's generic identifier</p>\r
+</item>\r
+<item>\r
+<p>the names of attributes known to apply to this element type\r
+(validating processors must make available names of all attributes\r
+declared for the element type; non-validating processors must\r
+make available at least the names of the attributes for which\r
+values are specified.\r
+</p>\r
+</item>\r
+</ulist>\r
+</p>\r
+</div2>\r
+-->\r
+</div1>\r
+<!-- &Entities; -->\r
+<div1 id="sec-physical-struct">\r
+<head>Physical Structures</head>\r
+<p><termdef id="dt-entity" term="Entity">An XML document may consist of one\r
+or many storage units. <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E6">[E6]</loc>These\r
+are called <term>entities</term>; they all have <term>content</term> and are\r
+all (except for the <termref def="dt-docent">document entity</termref> and\r
+the <termref def="dt-doctype">external DTD subset</termref>) identified by\r
+entity <term>name</term></phrase>.</termdef> Each XML document has one entity\r
+called the <termref def="dt-docent">document entity</termref>, which serves\r
+as the starting point for the <termref def="dt-xml-proc">XML processor</termref>\r
+and may contain the whole document.</p>\r
+<p>Entities may be either parsed or unparsed. <termdef id="dt-parsedent" term="Text Entity">A <term>parsed\r
+entity's</term> contents are referred to as its <termref def="dt-repltext">replacement\r
+text</termref>; this <termref def="dt-text">text</termref> is considered an\r
+integral part of the document.</termdef></p>\r
+<p><termdef id="dt-unparsed" term="Unparsed Entity">An <term>unparsed entity</term>\r
+is a resource whose contents may or may not be <termref def="dt-text">text</termref>,\r
+and if text, <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E25">[E25]</loc>may\r
+be other than</phrase> XML. Each unparsed entity has an associated <termref\r
+def="dt-notation">notation</termref>, identified by name. Beyond a requirement\r
+that an XML processor make the identifiers for the entity and notation available\r
+to the application, XML places no constraints on the contents of unparsed\r
+entities.</termdef></p>\r
+<p>Parsed entities are invoked by name using entity references; unparsed entities\r
+by name, given in the value of <kw>ENTITY</kw> or <kw>ENTITIES</kw> attributes.</p>\r
+<p><termdef id="gen-entity" term="general entity"><term>General entities</term>\r
+are entities for use within the document content. In this specification, general\r
+entities are sometimes referred to with the unqualified term <emph>entity</emph>\r
+when this leads to no ambiguity.</termdef> <termdef id="dt-PE" term="Parameter entity"><phrase\r
+diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E53">[E53]</loc><term>Parameter\r
+entities</term></phrase> are parsed entities for use within the DTD.</termdef>\r
+These two types of entities use different forms of reference and are recognized\r
+in different contexts. Furthermore, they occupy different namespaces; a parameter\r
+entity and a general entity with the same name are two distinct entities.</p>\r
+<div2 id="sec-references">\r
+<head>Character and Entity References</head>\r
+<p><termdef id="dt-charref" term="Character Reference"> A <term>character\r
+reference</term> refers to a specific character in the ISO/IEC 10646 character\r
+set, for example one not directly accessible from available input devices.</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>Character Reference</head>\r
+<prod id="NT-CharRef">\r
+<lhs>CharRef</lhs><rhs>'&amp;#' [0-9]+ ';' </rhs>\r
+<rhs>| '&hcro;' [0-9a-fA-F]+ ';'</rhs><wfc def="wf-Legalchar"/>\r
+</prod>\r
+</scrap>\r
+<wfcnote id="wf-Legalchar"><head>Legal Character</head><p>Characters referred\r
+to using character references must match the production for <termref def="NT-Char">Char</termref>.</p>\r
+</wfcnote>\r
+<p>If the character reference begins with <quote><code>&amp;#x</code></quote>,\r
+the digits and letters up to the terminating <code>;</code> provide a hexadecimal\r
+representation of the character's code point in ISO/IEC 10646. If it begins\r
+just with <quote><code>&amp;#</code></quote>, the digits up to the terminating <code>;</code>\r
+provide a decimal representation of the character's code point.</p>\r
+<p><termdef id="dt-entref" term="Entity Reference">An <term>entity reference</term>\r
+refers to the content of a named entity.</termdef> <termdef id="dt-GERef"\r
+term="General Entity Reference">References to parsed general entities use\r
+ampersand (<code>&amp;</code>) and semicolon (<code>;</code>) as delimiters.</termdef> <termdef\r
+id="dt-PERef" term="Parameter-entity reference"> <term>Parameter-entity references</term>\r
+use percent-sign (<code>%</code>) and semicolon (<code>;</code>) as delimiters.</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>Entity Reference</head>\r
+<prod id="NT-Reference">\r
+<lhs>Reference</lhs><rhs><nt def="NT-EntityRef">EntityRef</nt> | <nt def="NT-CharRef">CharRef</nt></rhs>\r
+</prod>\r
+<prod id="NT-EntityRef">\r
+<lhs>EntityRef</lhs><rhs>'&amp;' <nt def="NT-Name">Name</nt> ';'</rhs><wfc\r
+def="wf-entdeclared"/><vc def="vc-entdeclared"/><wfc def="textent"/><wfc def="norecursion"/>\r
+</prod>\r
+<prod id="NT-PEReference">\r
+<lhs>PEReference</lhs><rhs>'%' <nt def="NT-Name">Name</nt> ';'</rhs><vc def="vc-entdeclared"/>\r
+<wfc def="norecursion"/><wfc def="indtd"/>\r
+</prod>\r
+</scrap>\r
+<wfcnote id="wf-entdeclared"><head>Entity Declared</head><p>In a document\r
+without any DTD, a document with only an internal DTD subset which contains\r
+no parameter entity references, or a document with <quote><code>standalone='yes'</code></quote>, <phrase\r
+diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E34">[E34]</loc>for\r
+an entity reference that does not occur within the external subset or a parameter\r
+entity, the <nt def="NT-Name">Name</nt> given in the entity reference must <termref\r
+def="dt-match">match</termref> that in an <titleref href="#sec-entity-decl">entity\r
+declaration</titleref> that does not occur within the external subset or a\r
+parameter entity</phrase>, except that well-formed documents need not declare\r
+any of the following entities: &magicents;. <phrase diff="del"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E29">[E29]</loc>The declaration\r
+of a parameter entity must precede any reference to it. Similarly, </phrase>The\r
+declaration of a general entity must precede any reference to it which appears\r
+in a default value in an attribute-list declaration.</p>\r
+<p>Note that if entities are declared in the external subset or in external\r
+parameter entities, a non-validating processor is <titleref href="#include-if-valid">not\r
+obligated to</titleref> read and process their declarations; for such documents,\r
+the rule that an entity must be declared is a well-formedness constraint only\r
+if <titleref href="#sec-rmd">standalone='yes'</titleref>.</p>\r
+</wfcnote>\r
+<vcnote id="vc-entdeclared"><head>Entity Declared</head><p>In a document with\r
+an external subset or external parameter entities with <quote><code>standalone='no'</code></quote>,\r
+the <nt def="NT-Name">Name</nt> given in the entity reference must <termref\r
+def="dt-match">match</termref> that in an <titleref href="#sec-entity-decl">entity\r
+declaration</titleref>. For interoperability, valid documents should declare\r
+the entities &magicents;, in the form specified in <specref ref="sec-predefined-ent"/>.\r
+The declaration of a parameter entity must precede any reference to it. Similarly,\r
+the declaration of a general entity must precede any <phrase diff="chg"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E92">[E92]</loc>attribute-list\r
+declaration containing a default value with a direct or indirect reference\r
+to that general entity.</phrase></p>\r
+</vcnote>\r
+<!-- FINAL EDIT: is this duplication too clumsy? -->\r
+<wfcnote id="textent"><head>Parsed Entity</head><p>An entity reference must\r
+not contain the name of an <termref def="dt-unparsed">unparsed entity</termref>.\r
+Unparsed entities may be referred to only in <termref def="dt-attrval">attribute\r
+values</termref> declared to be of type <kw>ENTITY</kw> or <kw>ENTITIES</kw>.</p>\r
+</wfcnote>\r
+<wfcnote id="norecursion"><head>No Recursion</head><p>A parsed entity must\r
+not contain a recursive reference to itself, either directly or indirectly.</p>\r
+</wfcnote>\r
+<wfcnote id="indtd"><head>In DTD</head><p>Parameter-entity references may\r
+only appear in the <termref def="dt-doctype">DTD</termref>.</p>\r
+</wfcnote>\r
+<p>Examples of character and entity references:</p>\r
+<eg>Type &lt;key>less-than&lt;/key> (&hcro;3C;) to save options.\r
+This document was prepared on &amp;docdate; and\r
+is classified &amp;security-level;.</eg>\r
+<p>Example of a parameter-entity reference:</p>\r
+<eg><![CDATA[<!-- declare the parameter entity "ISOLat2"... -->\r
+<!ENTITY % ISOLat2\r
+         SYSTEM "http://www.xml.com/iso/isolat2-xml.entities" >\r
+<!-- ... now reference it. -->\r
+%ISOLat2;]]></eg>\r
+</div2>\r
+<div2 id="sec-entity-decl">\r
+<head>Entity Declarations</head>\r
+<p><termdef id="dt-entdecl" term="entity declaration"> Entities are declared\r
+thus:</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>Entity Declaration</head>\r
+<prodgroup pcw2="5" pcw4="18.5">\r
+<prod id="NT-EntityDecl">\r
+<lhs>EntityDecl</lhs><rhs><nt def="NT-GEDecl">GEDecl</nt><!--</rhs><com>General entities</com>\r
+<rhs>--> | <nt def="NT-PEDecl">PEDecl</nt></rhs>\r
+<!--<com>Parameter entities</com>-->\r
+</prod>\r
+<prod id="NT-GEDecl">\r
+<lhs>GEDecl</lhs><rhs>'&lt;!ENTITY' <nt def="NT-S">S</nt> <nt def="NT-Name">Name</nt> <nt\r
+def="NT-S">S</nt> <nt def="NT-EntityDef">EntityDef</nt> <nt def="NT-S">S</nt>?\r
+'>'</rhs>\r
+</prod>\r
+<prod id="NT-PEDecl">\r
+<lhs>PEDecl</lhs><rhs>'&lt;!ENTITY' <nt def="NT-S">S</nt> '%' <nt def="NT-S">S</nt> <nt\r
+def="NT-Name">Name</nt> <nt def="NT-S">S</nt> <nt def="NT-PEDef">PEDef</nt> <nt\r
+def="NT-S">S</nt>? '>'</rhs>\r
+<!--<com>Parameter entities</com>-->\r
+</prod>\r
+<prod id="NT-EntityDef">\r
+<lhs>EntityDef</lhs><rhs><nt def="NT-EntityValue">EntityValue</nt> <!--</rhs>\r
+<rhs>-->| (<nt def="NT-ExternalID">ExternalID</nt> <nt def="NT-NDataDecl">NDataDecl</nt>?)</rhs>\r
+<!-- <nt def='NT-ExternalDef'>ExternalDef</nt></rhs> -->\r
+</prod>\r
+<!-- FINAL EDIT: what happened to WFs here? -->\r
+<prod id="NT-PEDef">\r
+<lhs>PEDef</lhs><rhs><nt def="NT-EntityValue">EntityValue</nt> | <nt def="NT-ExternalID">ExternalID</nt></rhs>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>The <nt def="NT-Name">Name</nt> identifies the entity in an <termref def="dt-entref">entity\r
+reference</termref> or, in the case of an unparsed entity, in the value of\r
+an <kw>ENTITY</kw> or <kw>ENTITIES</kw> attribute. If the same entity is declared\r
+more than once, the first declaration encountered is binding; at user option,\r
+an XML processor may issue a warning if entities are declared multiple times.</p>\r
+<div3 id="sec-internal-ent">\r
+<head>Internal Entities</head>\r
+<p><termdef id="dt-internent" term="Internal Entity Replacement Text">If the\r
+entity definition is an <nt def="NT-EntityValue">EntityValue</nt>, the defined\r
+entity is called an <term>internal entity</term>. There is no separate physical\r
+storage object, and the content of the entity is given in the declaration.</termdef>\r
+Note that some processing of entity and character references in the <termref\r
+def="dt-litentval">literal entity value</termref> may be required to produce\r
+the correct <termref def="dt-repltext">replacement text</termref>: see <specref\r
+ref="intern-replacement"/>.</p>\r
+<p>An internal entity is a <termref def="dt-parsedent">parsed entity</termref>.</p>\r
+<p>Example of an internal entity declaration:</p>\r
+<eg>&lt;!ENTITY Pub-Status "This is a pre-release of the\r
+ specification."></eg>\r
+</div3>\r
+<div3 id="sec-external-ent">\r
+<head>External Entities</head>\r
+<p><termdef id="dt-extent" term="External Entity">If the entity is not internal,\r
+it is an <term>external entity</term>, declared as follows:</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>External Entity Declaration</head>\r
+<!--\r
+<prod id='NT-ExternalDef'><lhs>ExternalDef</lhs>\r
+<rhs></prod> -->\r
+<prod id="NT-ExternalID">\r
+<lhs>ExternalID</lhs><rhs>'SYSTEM' <nt def="NT-S">S</nt> <nt def="NT-SystemLiteral">SystemLiteral</nt></rhs>\r
+<rhs>| 'PUBLIC' <nt def="NT-S">S</nt> <nt def="NT-PubidLiteral">PubidLiteral</nt> <nt\r
+def="NT-S">S</nt> <nt def="NT-SystemLiteral">SystemLiteral</nt> </rhs>\r
+</prod>\r
+<prod id="NT-NDataDecl">\r
+<lhs>NDataDecl</lhs><rhs><nt def="NT-S">S</nt> 'NDATA' <nt def="NT-S">S</nt> <nt\r
+def="NT-Name">Name</nt></rhs><vc def="not-declared"/>\r
+</prod>\r
+</scrap>\r
+<p>If the <nt def="NT-NDataDecl">NDataDecl</nt> is present, this is a general <termref\r
+def="dt-unparsed">unparsed entity</termref>; otherwise it is a parsed entity.</p>\r
+<vcnote id="not-declared"><head>Notation Declared</head><p>The <nt def="NT-Name">Name</nt>\r
+must match the declared name of a <termref def="dt-notation">notation</termref>.</p>\r
+</vcnote>\r
+<p><phrase diff="chg"><termdef id="dt-sysid" term="System Identifier">The <nt\r
+def="NT-SystemLiteral">SystemLiteral</nt> is called the entity's <term>system\r
+identifier</term>. It is a <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E88">[E88]</loc>URI\r
+reference</phrase><phrase diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E66">[E66]</loc>\r
+(as defined in <bibref ref="rfc2396"/>, updated by <bibref ref="rfc2732"/>)</phrase>, <loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E76">[E76]</loc>meant\r
+to be dereferenced to obtain input for the XML processor to construct the\r
+entity's replacement text.</termdef> It is an error for a fragment identifier\r
+(beginning with a <code>#</code> character) to be part of a system identifier.</phrase>\r
+Unless otherwise provided by information outside the scope of this specification\r
+(e.g. a special XML element type defined by a particular DTD, or a processing\r
+instruction defined by a particular application specification), relative URIs\r
+are relative to the location of the resource within which the entity declaration\r
+occurs. A URI might thus be relative to the <termref def="dt-docent">document\r
+entity</termref>, to the entity containing the <termref def="dt-doctype">external\r
+DTD subset</termref>, or to some other <termref def="dt-extent">external parameter\r
+entity</termref>.</p>\r
+<p diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E78">[E78]</loc>URI\r
+references require encoding and escaping of certain characters. The disallowed\r
+characters include all non-ASCII characters, plus the excluded characters\r
+listed in Section 2.4 of <bibref ref="rfc2396"/>, except for the number sign\r
+(<code>#</code>) and percent sign (<code>%</code>) characters and the square\r
+bracket characters re-allowed in <bibref ref="rfc2732"/>. Disallowed characters\r
+must be escaped as follows:</p>\r
+<olist diff="add">\r
+<item><p>Each disallowed character is converted to UTF-8 <bibref ref="rfc2279"/>\r
+as one or more bytes.</p></item>\r
+<item><p>Any octets corresponding to a disallowed character are escaped with\r
+the URI escaping mechanism (that is, converted to <code>%</code><var>HH</var>,\r
+where HH is the hexadecimal notation of the byte value).</p></item>\r
+<item><p>The original character is replaced by the resulting character sequence.</p>\r
+</item>\r
+</olist>\r
+<p><termdef id="dt-pubid" term="Public identifier"> In addition to a system\r
+identifier, an external identifier may include a <term>public identifier</term>.</termdef>\r
+An XML processor attempting to retrieve the entity's content may use the public\r
+identifier to try to generate an alternative <phrase diff="chg"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E88">[E88]</loc>URI reference</phrase>.\r
+If the processor is unable to do so, it must use the <phrase diff="chg"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E88">[E88]</loc>URI\r
+reference</phrase> specified in the system literal. Before a match is attempted,\r
+all strings of white space in the public identifier must be normalized to\r
+single space characters (#x20), and leading and trailing white space must\r
+be removed.</p>\r
+<p>Examples of external entity declarations:</p>\r
+<eg>&lt;!ENTITY open-hatch\r
+         SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">\r
+&lt;!ENTITY open-hatch\r
+         PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN"\r
+         "http://www.textuality.com/boilerplate/OpenHatch.xml">\r
+&lt;!ENTITY hatch-pic\r
+         SYSTEM "../grafix/OpenHatch.gif"\r
+         NDATA gif ></eg>\r
+</div3>\r
+</div2>\r
+<div2 id="TextEntities">\r
+<head>Parsed Entities</head>\r
+<div3 id="sec-TextDecl">\r
+<head>The Text Declaration</head>\r
+<p>External parsed entities <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E107">[E107]</loc>should</phrase\r
+> each begin with a <term>text declaration</term>.</p>\r
+<scrap lang="ebnf">\r
+<head>Text Declaration</head>\r
+<prodgroup pcw4="12.5" pcw5="13">\r
+<prod id="NT-TextDecl">\r
+<lhs>TextDecl</lhs><rhs>&pio; <nt def="NT-VersionInfo">VersionInfo</nt>? <nt\r
+def="NT-EncodingDecl">EncodingDecl</nt> <nt def="NT-S">S</nt>? &pic;</rhs>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>The text declaration must be provided literally, not by reference to a\r
+parsed entity. No text declaration may appear at any position other than the\r
+beginning of an external parsed entity. <phrase diff="add"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E94">[E94]</loc>The text declaration\r
+in an external parsed entity is not considered part of its <termref def="dt-repltext">replacement\r
+text</termref>.</phrase></p>\r
+</div3>\r
+<div3 id="wf-entities">\r
+<head>Well-Formed Parsed Entities</head>\r
+<p>The document entity is well-formed if it matches the production labeled <nt\r
+def="NT-document">document</nt>. An external general parsed entity is well-formed\r
+if it matches the production labeled <nt def="NT-extParsedEnt">extParsedEnt</nt>. <phrase\r
+diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</loc>All\r
+external parameter entities are well-formed by definition.</phrase></p>\r
+<scrap lang="ebnf">\r
+<head>Well-Formed External Parsed Entity</head>\r
+<prod id="NT-extParsedEnt">\r
+<lhs>extParsedEnt</lhs><rhs><nt def="NT-TextDecl">TextDecl</nt>? <nt def="NT-content">content</nt></rhs>\r
+</prod>\r
+<prod id="NT-extPE" diff="del">\r
+<lhs>extPE</lhs><rhs><nt def="NT-TextDecl">TextDecl</nt>? <nt def="NT-extSubsetDecl">extSubsetDecl</nt></rhs>\r
+<com><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</loc></com>\r
+</prod>\r
+</scrap>\r
+<p>An internal general parsed entity is well-formed if its replacement text\r
+matches the production labeled <nt def="NT-content">content</nt>. All internal\r
+parameter entities are well-formed by definition.</p>\r
+<p>A consequence of well-formedness in entities is that the logical and physical\r
+structures in an XML document are properly nested; no <termref def="dt-stag">start-tag</termref>, <termref\r
+def="dt-etag">end-tag</termref>, <termref def="dt-empty">empty-element tag</termref>, <termref\r
+def="dt-element">element</termref>, <termref def="dt-comment">comment</termref>, <termref\r
+def="dt-pi">processing instruction</termref>, <termref def="dt-charref">character\r
+reference</termref>, or <termref def="dt-entref">entity reference</termref>\r
+can begin in one entity and end in another.</p>\r
+</div3>\r
+<div3 id="charencoding">\r
+<head>Character Encoding in Entities</head>\r
+<p>Each external parsed entity in an XML document may use a different encoding\r
+for its characters. All XML processors must be able to read entities in <phrase\r
+diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E56">[E56]</loc>both\r
+the UTF-8 and UTF-16 encodings.</phrase> <phrase diff="add"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E77">[E77]</loc>The terms <quote>UTF-8</quote>\r
+and <quote>UTF-16</quote> in this specification do not apply to character\r
+encodings with any other labels, even if the encodings or labels are very\r
+similar to UTF-8 or UTF-16.</phrase></p>\r
+<p>Entities encoded in UTF-16 must begin with the Byte Order Mark described\r
+by <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</loc>Annex\r
+F of <bibref ref="ISO10646"/>, Annex H of <bibref ref="ISO10646-2000"/>, section\r
+2.4 of <bibref ref="Unicode"/>, and section 2.7 of <bibref ref="Unicode3"/></phrase>\r
+(the ZERO WIDTH NO-BREAK SPACE character, #xFEFF). This is an encoding signature,\r
+not part of either the markup or the character data of the XML document. XML\r
+processors must be able to use this character to differentiate between UTF-8\r
+and UTF-16 encoded documents.</p>\r
+<p>Although an XML processor is required to read only entities in the UTF-8\r
+and UTF-16 encodings, it is recognized that other encodings are used around\r
+the world, and it may be desired for XML processors to read entities that\r
+use them. <phrase diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E47">[E47]</loc>In\r
+the absence of external character encoding information (such as MIME headers),</phrase>\r
+parsed entities which are stored in an encoding other than UTF-8 or UTF-16\r
+must begin with a text declaration <phrase diff="add">(see <specref ref="sec-TextDecl"/>) </phrase>containing\r
+an encoding declaration:</p>\r
+<scrap lang="ebnf">\r
+<head>Encoding Declaration</head>\r
+<prod id="NT-EncodingDecl">\r
+<lhs>EncodingDecl</lhs><rhs><nt def="NT-S">S</nt> 'encoding' <nt def="NT-Eq">Eq</nt>\r
+('"' <nt def="NT-EncName">EncName</nt> '"' | "'" <nt def="NT-EncName">EncName</nt>\r
+"'" ) </rhs>\r
+</prod>\r
+<prod id="NT-EncName">\r
+<lhs>EncName</lhs><rhs>[A-Za-z] ([A-Za-z0-9._] | '-')*</rhs><com>Encoding\r
+name contains only Latin characters</com>\r
+</prod>\r
+</scrap>\r
+<p>In the <termref def="dt-docent">document entity</termref>, the encoding\r
+declaration is part of the <termref def="dt-xmldecl">XML declaration</termref>.\r
+The <nt def="NT-EncName">EncName</nt> is the name of the encoding used.</p>\r
+<!-- FINAL EDIT: check name of IANA and charset names -->\r
+<p>In an encoding declaration, the values <quote><code>UTF-8</code></quote>, <quote><code>UTF-16</code></quote>, <quote><code>ISO-10646-UCS-2</code\r
+></quote>, and <quote><code>ISO-10646-UCS-4</code></quote> should be used\r
+for the various encodings and transformations of Unicode / ISO/IEC 10646,\r
+the values <quote><code>ISO-8859-1</code></quote>, <quote><code>ISO-8859-2</code></quote>,\r
+... <loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E106">[E106]</loc><phrase\r
+diff="chg"><quote><code>ISO-8859-</code><var>n</var></quote> (where <var>n</var>\r
+is the part number)</phrase> should be used for the parts of ISO 8859, and\r
+the values <quote><code>ISO-2022-JP</code></quote>, <quote><code>Shift_JIS</code></quote>,\r
+and <quote><code>EUC-JP</code></quote> should be used for the various encoded\r
+forms of JIS X-0208-1997. <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E57">[E57]</loc>It\r
+is recommended that character encodings registered (as <emph>charset</emph>s)\r
+with the Internet Assigned Numbers Authority <phrase diff="chg"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E58">[E58]</loc><bibref ref="IANA"/></phrase>,\r
+other than those just listed, be referred to using their registered names;\r
+other encodings should use names starting with an <quote>x-</quote> prefix.\r
+XML processors should match character encoding names in a case-insensitive\r
+way and should either interpret an IANA-registered name as the encoding registered\r
+at IANA for that name or treat it as unknown (processors are, of course, not\r
+required to support all IANA-registered encodings).</phrase></p>\r
+<p>In the absence of information provided by an external transport protocol\r
+(e.g. HTTP or MIME), it is an <termref def="dt-error">error</termref> for\r
+an entity including an encoding declaration to be presented to the XML processor\r
+in an encoding other than that named in the declaration, <phrase diff="del"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E5">[E5]</loc>for\r
+an encoding declaration to occur other than at the beginning of an external\r
+entity, </phrase>or for an entity which begins with neither a Byte Order Mark\r
+nor an encoding declaration to use an encoding other than UTF-8. Note that\r
+since ASCII is a subset of UTF-8, ordinary ASCII entities do not strictly\r
+need an encoding declaration.</p>\r
+<p diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E5">[E5]</loc>It\r
+is <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E36">[E36]</loc>a\r
+fatal</phrase> error for a <nt def="NT-TextDecl">TextDecl</nt> to occur other\r
+than at the beginning of an external entity.</p>\r
+<p>It is a <termref def="dt-fatal">fatal error</termref> when an XML processor\r
+encounters an entity with an encoding that it is unable to process. <phrase\r
+diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E79">[E79]</loc>It\r
+is a fatal error if an XML entity is determined (via default, encoding declaration,\r
+or higher-level protocol) to be in a certain encoding but contains octet sequences\r
+that are not legal in that encoding. It is also a fatal error if an XML entity\r
+contains no encoding declaration and its content is not legal UTF-8 or UTF-16.</phrase></p>\r
+<p>Examples of <phrase diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E23">[E23]</loc>text\r
+declarations containing </phrase>encoding declarations:</p>\r
+<eg>&lt;?xml encoding='UTF-8'?>\r
+&lt;?xml encoding='EUC-JP'?></eg>\r
+</div3>\r
+</div2>\r
+<div2 id="entproc">\r
+<head>XML Processor Treatment of Entities and References</head>\r
+<p>The table below summarizes the contexts in which character references,\r
+entity references, and invocations of unparsed entities might appear and the\r
+required behavior of an <termref def="dt-xml-proc">XML processor</termref>\r
+in each case. The labels in the leftmost column describe the recognition context: <glist>\r
+<gitem><label>Reference in Content</label>\r
+<def>\r
+<p>as a reference anywhere after the <termref def="dt-stag">start-tag</termref>\r
+and before the <termref def="dt-etag">end-tag</termref> of an element; corresponds\r
+to the nonterminal <nt def="NT-content">content</nt>.</p>\r
+</def></gitem>\r
+<gitem><label>Reference in Attribute Value</label>\r
+<def>\r
+<p>as a reference within either the value of an attribute in a <termref def="dt-stag">start-tag</termref>,\r
+or a default value in an <termref def="dt-attdecl">attribute declaration</termref>;\r
+corresponds to the nonterminal <nt def="NT-AttValue">AttValue</nt>.</p>\r
+</def></gitem>\r
+<gitem><label>Occurs as Attribute Value</label>\r
+<def>\r
+<p>as a <nt def="NT-Name">Name</nt>, not a reference, appearing either as\r
+the value of an attribute which has been declared as type <kw>ENTITY</kw>,\r
+or as one of the space-separated tokens in the value of an attribute which\r
+has been declared as type <kw>ENTITIES</kw>.</p>\r
+</def></gitem>\r
+<gitem><label>Reference in Entity Value</label>\r
+<def>\r
+<p>as a reference within a parameter or internal entity's <termref def="dt-litentval">literal\r
+entity value</termref> in the entity's declaration; corresponds to the nonterminal <nt\r
+def="NT-EntityValue">EntityValue</nt>.</p>\r
+</def></gitem>\r
+<gitem><label>Reference in DTD</label>\r
+<def>\r
+<p diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</loc>as\r
+a reference within either the internal or external subsets of the <termref\r
+def="dt-doctype">DTD</termref>, but outside of an <nt def="NT-EntityValue">EntityValue</nt>, <nt\r
+def="NT-AttValue">AttValue</nt>, <nt def="NT-PI">PI</nt>, <nt def="NT-Comment">Comment</nt>, <nt\r
+def="NT-SystemLiteral">SystemLiteral</nt>, <nt def="NT-PubidLiteral">PubidLiteral</nt>,\r
+or the contents of an ignored conditional section (see <specref ref="sec-condition-sect"/>).</p>\r
+<p>.</p>\r
+</def></gitem>\r
+</glist></p>\r
+<table border="1" frame="border" cellpadding="7"><tbody align="center"><tr>\r
+<td rowspan="2" colspan="1"></td><td colspan="4" align="center" valign="bottom">Entity\r
+Type</td><td rowspan="2" align="center">Character</td></tr><tr align="center"\r
+valign="bottom"><td>Parameter</td><td>Internal General</td><td>External Parsed\r
+General</td><td>Unparsed</td></tr><tr align="center" valign="middle"><td align="right">Reference\r
+in Content</td><td><titleref href="#not-recognized">Not recognized</titleref></td>\r
+<td><titleref href="#included">Included</titleref></td><td><titleref href="#include-if-valid">Included\r
+if validating</titleref></td><td><titleref href="#forbidden">Forbidden</titleref></td>\r
+<td><titleref href="#included">Included</titleref></td></tr><tr align="center"\r
+valign="middle"><td align="right">Reference in Attribute Value</td><td><titleref\r
+href="#not-recognized">Not recognized</titleref></td><td><titleref href="#inliteral">Included\r
+in literal</titleref></td><td><titleref href="#forbidden">Forbidden</titleref></td>\r
+<td><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E51">[E51]</loc><titleref\r
+diff="chg" href="#forbidden">Forbidden</titleref></td><td><titleref href="#included">Included</titleref></td>\r
+</tr><tr align="center" valign="middle"><td align="right">Occurs as Attribute\r
+Value</td><td><titleref href="#not-recognized">Not recognized</titleref></td>\r
+<td><titleref href="#forbidden">Forbidden</titleref></td><td><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E51">[E51]</loc><titleref\r
+diff="chg" href="#forbidden">Forbidden</titleref></td><td><titleref href="#notify">Notify</titleref></td>\r
+<td><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E51">[E51]</loc><titleref\r
+diff="chg" href="#not-recognized">Not recognized</titleref></td></tr><tr align="center"\r
+valign="middle"><td align="right">Reference in EntityValue</td><td><titleref\r
+href="#inliteral">Included in literal</titleref></td><td><titleref href="#bypass">Bypassed</titleref></td>\r
+<td><titleref href="#bypass">Bypassed</titleref></td><td><titleref href="#forbidden">Forbidden</titleref></td>\r
+<td><titleref href="#included">Included</titleref></td></tr><tr align="center"\r
+valign="middle"><td align="right">Reference in DTD</td><td><titleref href="#as-PE">Included\r
+as PE</titleref></td><td><titleref href="#forbidden">Forbidden</titleref></td>\r
+<td><titleref href="#forbidden">Forbidden</titleref></td><td><titleref href="#forbidden">Forbidden</titleref></td>\r
+<td><titleref href="#forbidden">Forbidden</titleref></td></tr></tbody></table>\r
+<div3 id="not-recognized">\r
+<head>Not Recognized</head>\r
+<p>Outside the DTD, the <code>%</code> character has no special significance;\r
+thus, what would be parameter entity references in the DTD are not recognized\r
+as markup in <nt def="NT-content">content</nt>. Similarly, the names of unparsed\r
+entities are not recognized except when they appear in the value of an appropriately\r
+declared attribute.</p>\r
+</div3>\r
+<div3 id="included">\r
+<head>Included</head>\r
+<p><termdef id="dt-include" term="Include">An entity is <term>included</term>\r
+when its <termref def="dt-repltext">replacement text</termref> is retrieved\r
+and processed, in place of the reference itself, as though it were part of\r
+the document at the location the reference was recognized.</termdef> The replacement\r
+text may contain both <termref def="dt-chardata">character data</termref>\r
+and (except for parameter entities) <termref def="dt-markup">markup</termref>,\r
+which must be recognized in the usual way<phrase diff="del"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E65">[E65]</loc>, except that\r
+the replacement text of entities used to escape markup delimiters (the entities &magicents;)\r
+is always treated as data</phrase>. (The string <quote><code>AT&amp;amp;T;</code></quote>\r
+expands to <quote><code>AT&amp;T;</code></quote> and the remaining ampersand\r
+is not recognized as an entity-reference delimiter.) A character reference\r
+is <term>included</term> when the indicated character is processed in place\r
+of the reference itself. </p>\r
+</div3>\r
+<div3 id="include-if-valid">\r
+<head>Included If Validating</head>\r
+<p>When an XML processor recognizes a reference to a parsed entity, in order\r
+to <termref def="dt-valid">validate</termref> the document, the processor\r
+must <termref def="dt-include">include</termref> its replacement text. If\r
+the entity is external, and the processor is not attempting to validate the\r
+XML document, the processor <termref def="dt-may">may</termref>, but need\r
+not, include the entity's replacement text. If a non-validating <phrase diff="chg"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E95">[E95]</loc>processor</phrase>\r
+does not include the replacement text, it must inform the application that\r
+it recognized, but did not read, the entity.</p>\r
+<p>This rule is based on the recognition that the automatic inclusion provided\r
+by the SGML and XML entity mechanism, primarily designed to support modularity\r
+in authoring, is not necessarily appropriate for other applications, in particular\r
+document browsing. Browsers, for example, when encountering an external parsed\r
+entity reference, might choose to provide a visual indication of the entity's\r
+presence and retrieve it for display only on demand.</p>\r
+</div3>\r
+<div3 id="forbidden">\r
+<head>Forbidden</head>\r
+<p>The following are forbidden, and constitute <termref def="dt-fatal">fatal</termref>\r
+errors:</p>\r
+<ulist>\r
+<item><p>the appearance of a reference to an <termref def="dt-unparsed">unparsed\r
+entity</termref>.</p></item>\r
+<item><p>the appearance of any character or general-entity reference in the\r
+DTD except within an <nt def="NT-EntityValue">EntityValue</nt> or <nt def="NT-AttValue">AttValue</nt>.</p>\r
+</item>\r
+<item><p>a reference to an external entity in an attribute value.</p></item>\r
+</ulist>\r
+</div3>\r
+<div3 id="inliteral">\r
+<head>Included in Literal</head>\r
+<p>When an <termref def="dt-entref">entity reference</termref> appears in\r
+an attribute value, or a parameter entity reference appears in a literal entity\r
+value, its <termref def="dt-repltext">replacement text</termref> is processed\r
+in place of the reference itself as though it were part of the document at\r
+the location the reference was recognized, except that a single or double\r
+quote character in the replacement text is always treated as a normal data\r
+character and will not terminate the literal. For example, this is well-formed:</p>\r
+<eg diff="chg">&lt;!-- <loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E4">[E4]</loc> -->\r
+<![CDATA[<!ENTITY % YN '"Yes"' >\r
+<!ENTITY WhatHeSaid "He said %YN;" >]]></eg>\r
+<p>while this is not:</p>\r
+<eg>&lt;!ENTITY EndAttr "27'" >\r
+&lt;element attribute='a-&amp;EndAttr;></eg>\r
+</div3>\r
+<div3 id="notify">\r
+<head>Notify</head>\r
+<p>When the name of an <termref def="dt-unparsed">unparsed entity</termref>\r
+appears as a token in the value of an attribute of declared type <kw>ENTITY</kw>\r
+or <kw>ENTITIES</kw>, a validating processor must inform the application of\r
+the <termref def="dt-sysid">system</termref> and <termref def="dt-pubid">public</termref>\r
+(if any) identifiers for both the entity and its associated <termref def="dt-notation">notation</termref>.</p>\r
+</div3>\r
+<div3 id="bypass">\r
+<head>Bypassed</head>\r
+<p>When a general entity reference appears in the <nt def="NT-EntityValue">EntityValue</nt>\r
+in an entity declaration, it is bypassed and left as is.</p>\r
+</div3>\r
+<div3 id="as-PE">\r
+<head>Included as PE</head>\r
+<p>Just as with external parsed entities, parameter entities need only be <titleref\r
+href="#include-if-valid">included if validating</titleref>. When a parameter-entity\r
+reference is recognized in the DTD and included, its <termref def="dt-repltext">replacement\r
+text</termref> is enlarged by the attachment of one leading and one following\r
+space (#x20) character; the intent is to constrain the replacement text of\r
+parameter entities to contain an integral number of grammatical tokens in\r
+the DTD. <phrase diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E96">[E96]</loc>This\r
+behavior does not apply to parameter entity references within entity values;\r
+these are described in <specref ref="inliteral"/>.</phrase></p>\r
+</div3>\r
+</div2>\r
+<div2 id="intern-replacement">\r
+<head>Construction of Internal Entity Replacement Text</head>\r
+<p>In discussing the treatment of internal entities, it is useful to distinguish\r
+two forms of the entity's value. <termdef id="dt-litentval" term="Literal Entity Value">The <term>literal\r
+entity value</term> is the quoted string actually present in the entity declaration,\r
+corresponding to the non-terminal <nt def="NT-EntityValue">EntityValue</nt>.</termdef> <termdef\r
+id="dt-repltext" term="Replacement Text">The <term>replacement text</term>\r
+is the content of the entity, after replacement of character references and\r
+parameter-entity references.</termdef></p>\r
+<p>The literal entity value as given in an internal entity declaration (<nt\r
+def="NT-EntityValue">EntityValue</nt>) may contain character, parameter-entity,\r
+and general-entity references. Such references must be contained entirely\r
+within the literal entity value. The actual replacement text that is <termref\r
+def="dt-include">included</termref> as described above must contain the <emph>replacement\r
+text</emph> of any parameter entities referred to, and must contain the character\r
+referred to, in place of any character references in the literal entity value;\r
+however, general-entity references must be left as-is, unexpanded. For example,\r
+given the following declarations:</p>\r
+<eg><![CDATA[<!ENTITY % pub    "&#xc9;ditions Gallimard" >\r
+<!ENTITY   rights "All rights reserved" >\r
+<!ENTITY   book   "La Peste: Albert Camus,\r
+&#xA9; 1947 %pub;. &rights;" >]]></eg>\r
+<p>then the replacement text for the entity <quote><code>book</code></quote>\r
+is:</p>\r
+<eg>La Peste: Albert Camus,\r
+© 1947 Ã‰ditions Gallimard. &amp;rights;</eg>\r
+<p>The general-entity reference <quote><code>&amp;rights;</code></quote> would\r
+be expanded should the reference <quote><code>&amp;book;</code></quote> appear\r
+in the document's content or an attribute value.</p>\r
+<p>These simple rules may have complex interactions; for a detailed discussion\r
+of a difficult example, see <specref ref="sec-entexpand"/>.</p>\r
+</div2>\r
+<div2 id="sec-predefined-ent">\r
+<head>Predefined Entities</head>\r
+<p><termdef id="dt-escape" term="escape">Entity and character references can\r
+both be used to <term>escape</term> the left angle bracket, ampersand, and\r
+other delimiters. A set of general entities (&magicents;) is specified for\r
+this purpose. Numeric character references may also be used; they are expanded\r
+immediately when recognized and must be treated as character data, so the\r
+numeric character references <quote><code>&amp;#60;</code></quote> and <quote><code>&amp;#38;</code></quote>\r
+may be used to escape <code>&lt;</code> and <code>&amp;</code> when they occur\r
+in character data.</termdef></p>\r
+<p>All XML processors must recognize these entities whether they are declared\r
+or not. <termref def="dt-interop">For interoperability</termref>, valid XML\r
+documents should declare these entities, like any others, before using them. <phrase\r
+diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E80">[E80]</loc>If\r
+the entities <code>lt</code> or <code>amp</code> are declared, they must be\r
+declared as internal entities whose replacement text is a character reference\r
+to the <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E103">[E103]</loc>respective\r
+character (less-than sign or ampersand)</phrase> being escaped; the double\r
+escaping is required for these entities so that references to them produce\r
+a well-formed result. If the entities <code>gt</code>, <code>apos</code>,\r
+or <code>quot</code> are declared, they must be declared as internal entities\r
+whose replacement text is the single character being escaped (or a character\r
+reference to that character; the double escaping here is unnecessary but harmless).\r
+For example:</phrase></p>\r
+<eg><![CDATA[<!ENTITY lt     "&#38;#60;">\r
+<!ENTITY gt     "&#62;">\r
+<!ENTITY amp    "&#38;#38;">\r
+<!ENTITY apos   "&#39;">\r
+<!ENTITY quot   "&#34;">]]></eg>\r
+<p diff="del">Note that the <code>&lt;</code> and <code>&amp;</code> characters\r
+in the declarations of <quote><code>lt</code></quote> and <quote><code>amp</code></quote>\r
+are doubly escaped to meet the requirement that entity replacement be well-formed.</p>\r
+</div2>\r
+<div2 id="Notations">\r
+<head>Notation Declarations</head>\r
+<p><termdef id="dt-notation" term="Notation"><term>Notations</term> identify\r
+by name the format of <termref def="dt-extent">unparsed entities</termref>,\r
+the format of elements which bear a notation attribute, or the application\r
+to which a <termref def="dt-pi">processing instruction</termref> is addressed.</termdef></p>\r
+<p><termdef id="dt-notdecl" term="Notation Declaration"> <term>Notation declarations</term>\r
+provide a name for the notation, for use in entity and attribute-list declarations\r
+and in attribute specifications, and an external identifier for the notation\r
+which may allow an XML processor or its client application to locate a helper\r
+application capable of processing data in the given notation.</termdef></p>\r
+<scrap lang="ebnf">\r
+<head>Notation Declarations</head>\r
+<prod id="NT-NotationDecl">\r
+<lhs>NotationDecl</lhs><rhs>'&lt;!NOTATION' <nt def="NT-S">S</nt> <nt def="NT-Name">Name</nt> <nt\r
+def="NT-S">S</nt> (<nt def="NT-ExternalID">ExternalID</nt> | <nt def="NT-PublicID">PublicID</nt>) <nt\r
+def="NT-S">S</nt>? '>'</rhs><vc def="UniqueNotationName" diff="add"/>\r
+</prod>\r
+<prod id="NT-PublicID">\r
+<lhs>PublicID</lhs><rhs>'PUBLIC' <nt def="NT-S">S</nt> <nt def="NT-PubidLiteral">PubidLiteral</nt> </rhs>\r
+</prod>\r
+</scrap>\r
+<vcnote id="UniqueNotationName" diff="add"><head><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E22">[E22]</loc>Unique\r
+Notation Name</head><p>Only one notation declaration can declare a given <nt\r
+def="NT-Name">Name</nt>.</p>\r
+</vcnote>\r
+<p>XML processors must provide applications with the name and external identifier(s)\r
+of any notation declared and referred to in an attribute value, attribute\r
+definition, or entity declaration. They may additionally resolve the external\r
+identifier into the <termref def="dt-sysid">system identifier</termref>, file\r
+name, or other information needed to allow the application to call a processor\r
+for data in the notation described. (It is not an error, however, for XML\r
+documents to declare and refer to notations for which notation-specific applications\r
+are not available on the system where the XML processor or application is\r
+running.)</p>\r
+</div2>\r
+<div2 id="sec-doc-entity">\r
+<head>Document Entity</head>\r
+<p><termdef id="dt-docent" term="Document Entity">The <term>document entity</term>\r
+serves as the root of the entity tree and a starting-point for an <termref\r
+def="dt-xml-proc">XML processor</termref>.</termdef> This specification does\r
+not specify how the document entity is to be located by an XML processor;\r
+unlike other entities, the document entity has no name and might well appear\r
+on a processor input stream without any identification at all.</p>\r
+</div2>\r
+</div1>\r
+<!-- &Conformance; -->\r
+<div1 id="sec-conformance">\r
+<head>Conformance</head>\r
+<div2 id="proc-types">\r
+<head>Validating and Non-Validating Processors</head>\r
+<p>Conforming <termref def="dt-xml-proc">XML processors</termref> fall into\r
+two classes: validating and non-validating.</p>\r
+<p>Validating and non-validating processors alike must report violations of\r
+this specification's well-formedness constraints in the content of the <termref\r
+def="dt-docent">document entity</termref> and any other <termref def="dt-parsedent">parsed\r
+entities</termref> that they read.</p>\r
+<p><termdef id="dt-validating" term="Validating Processor"><term>Validating\r
+processors</term> must<phrase diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E21">[E21]</loc>,\r
+at user option,</phrase> report violations of the constraints expressed by\r
+the declarations in the <termref def="dt-doctype">DTD</termref>, and failures\r
+to fulfill the validity constraints given in this specification.</termdef>\r
+To accomplish this, validating XML processors must read and process the entire\r
+DTD and all external parsed entities referenced in the document.</p>\r
+<p>Non-validating processors are required to check only the <termref def="dt-docent">document\r
+entity</termref>, including the entire internal DTD subset, for well-formedness. <termdef\r
+id="dt-use-mdecl" term="Process Declarations"> While they are not required\r
+to check the document for validity, they are required to <term>process</term>\r
+all the declarations they read in the internal DTD subset and in any parameter\r
+entity that they read, up to the first reference to a parameter entity that\r
+they do <emph>not</emph> read; that is to say, they must use the information\r
+in those declarations to <titleref href="#AVNormalize">normalize</titleref>\r
+attribute values, <titleref href="#included">include</titleref> the replacement\r
+text of internal entities, and supply <titleref href="#sec-attr-defaults">default\r
+attribute values</titleref>.</termdef> <phrase diff="add"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E33">[E33]</loc>Except when <code>standalone="yes"</code>, </phrase>they\r
+must not <termref def="dt-use-mdecl">process</termref> <termref def="dt-entdecl">entity\r
+declarations</termref> or <termref def="dt-attdecl">attribute-list declarations</termref>\r
+encountered after a reference to a parameter entity that is not read, since\r
+the entity may have contained overriding declarations.</p>\r
+</div2>\r
+<div2 id="safe-behavior">\r
+<head>Using XML Processors</head>\r
+<p>The behavior of a validating XML processor is highly predictable; it must\r
+read every piece of a document and report all well-formedness and validity\r
+violations. Less is required of a non-validating processor; it need not read\r
+any part of the document other than the document entity. This has two effects\r
+that may be important to users of XML processors:</p>\r
+<ulist>\r
+<item><p>Certain well-formedness errors, specifically those that require reading\r
+external entities, may not be detected by a non-validating processor. Examples\r
+include the constraints entitled <titleref href="#wf-entdeclared">Entity Declared</titleref>, <titleref\r
+href="#textent">Parsed Entity</titleref>, and <titleref href="#norecursion">No\r
+Recursion</titleref>, as well as some of the cases described as <titleref\r
+href="#forbidden">forbidden</titleref> in <specref ref="entproc"/>.</p></item>\r
+<item><p>The information passed from the processor to the application may\r
+vary, depending on whether the processor reads parameter and external entities.\r
+For example, a non-validating processor may not <titleref href="#AVNormalize">normalize</titleref>\r
+attribute values, <titleref href="#included">include</titleref> the replacement\r
+text of internal entities, or supply <titleref href="#sec-attr-defaults">default\r
+attribute values</titleref>, where doing so depends on having read declarations\r
+in external or parameter entities.</p></item>\r
+</ulist>\r
+<p>For maximum reliability in interoperating between different XML processors,\r
+applications which use non-validating processors should not rely on any behaviors\r
+not required of such processors. Applications which require facilities such\r
+as the use of default attributes or internal entities which are declared in\r
+external entities should use validating XML processors.</p>\r
+</div2>\r
+</div1>\r
+<div1 id="sec-notation">\r
+<head>Notation</head>\r
+<p>The formal grammar of XML is given in this specification using a simple\r
+Extended Backus-Naur Form (EBNF) notation. Each rule in the grammar defines\r
+one symbol, in the form</p>\r
+<eg>symbol ::= expression</eg>\r
+<p>Symbols are written with an initial capital letter if they are <phrase\r
+diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E42">[E42]</loc>the\r
+start symbol of a regular language,</phrase> otherwise with an initial lower\r
+case letter. Literal strings are quoted.</p>\r
+<p>Within the expression on the right-hand side of a rule, the following expressions\r
+are used to match strings of one or more characters: <glist>\r
+<gitem><label><code>#xN</code></label>\r
+<def>\r
+<p>where <code>N</code> is a hexadecimal integer, the expression matches the\r
+character in ISO/IEC 10646 whose canonical (UCS-4) code value, when interpreted\r
+as an unsigned binary number, has the value indicated. The number of leading\r
+zeros in the <code>#xN</code> form is insignificant; the number of leading\r
+zeros in the corresponding code value is governed by the character encoding\r
+in use and is not significant for XML.</p>\r
+</def></gitem>\r
+<gitem><label><code>[a-zA-Z]</code>, <code>[#xN-#xN]</code></label>\r
+<def>\r
+<p>matches any <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E93">[E93]</loc><nt\r
+def="NT-Char">Char</nt></phrase> with a value in the range(s) indicated (inclusive).</p>\r
+</def></gitem>\r
+<gitem diff="add"><label><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E3">[E3]</loc><code>[abc]</code>, <code>[#xN#xN#xN]</code\r
+></label>\r
+<def>\r
+<p>matches any <nt def="NT-Char">Char</nt> with a value among the characters\r
+enumerated. Enumerations and ranges can be mixed in one set of brackets.</p>\r
+</def></gitem>\r
+<gitem><label><code>[^a-z]</code>, <code>[^#xN-#xN]</code></label>\r
+<def>\r
+<p>matches any <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E93">[E93]</loc><nt\r
+def="NT-Char">Char</nt></phrase> with a value <emph>outside</emph> the range\r
+indicated.</p>\r
+</def></gitem>\r
+<gitem><label><code>[^abc]</code>, <code>[^#xN#xN#xN]</code></label>\r
+<def>\r
+<p>matches any <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E93">[E93]</loc><nt\r
+def="NT-Char">Char</nt></phrase> with a value not among the characters given. <phrase\r
+diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E3">[E3]</loc>Enumerations\r
+and ranges of forbidden values can be mixed in one set of brackets.</phrase></p>\r
+</def></gitem>\r
+<gitem><label><code>"string"</code></label>\r
+<def>\r
+<p>matches a literal string <termref def="dt-match">matching</termref> that\r
+given inside the double quotes.</p>\r
+</def></gitem>\r
+<gitem><label><code>'string'</code></label>\r
+<def>\r
+<p>matches a literal string <termref def="dt-match">matching</termref> that\r
+given inside the single quotes.</p>\r
+</def></gitem>\r
+</glist> These symbols may be combined to match more complex patterns as follows,\r
+where <code>A</code> and <code>B</code> represent simple expressions: <glist>\r
+<gitem><label>(<code>expression</code>)</label>\r
+<def>\r
+<p><code>expression</code> is treated as a unit and may be combined as described\r
+in this list.</p>\r
+</def></gitem>\r
+<gitem><label><code>A?</code></label>\r
+<def>\r
+<p>matches <code>A</code> or nothing; optional <code>A</code>.</p>\r
+</def></gitem>\r
+<gitem><label><code>A B</code></label>\r
+<def>\r
+<p>matches <code>A</code> followed by <code>B</code>. <phrase diff="add"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E20">[E20]</loc>This\r
+operator has higher precedence than alternation; thus <code>A B | C D</code>\r
+is identical to <code>(A B) | (C D)</code>.</phrase></p>\r
+</def></gitem>\r
+<gitem><label><code>A | B</code></label>\r
+<def>\r
+<p>matches <code>A</code> or <code>B</code> but not both.</p>\r
+</def></gitem>\r
+<gitem><label><code>A - B</code></label>\r
+<def>\r
+<p>matches any string that matches <code>A</code> but does not match <code>B</code>.</p>\r
+</def></gitem>\r
+<gitem><label><code>A+</code></label>\r
+<def>\r
+<p>matches one or more occurrences of <code>A</code>.<phrase diff="add"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E20">[E20]</loc>Concatenation\r
+has higher precedence than alternation; thus <code>A+ | B+</code> is identical\r
+to <code>(A+) | (B+)</code>.</phrase></p>\r
+</def></gitem>\r
+<gitem><label><code>A*</code></label>\r
+<def>\r
+<p>matches zero or more occurrences of <code>A</code>. <phrase diff="add"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E20">[E20]</loc>Concatenation\r
+has higher precedence than alternation; thus <code>A* | B*</code> is identical\r
+to <code>(A*) | (B*)</code>.</phrase></p>\r
+</def></gitem>\r
+</glist> Other notations used in the productions are: <glist>\r
+<gitem><label><code>/* ... */</code></label>\r
+<def>\r
+<p>comment.</p>\r
+</def></gitem>\r
+<gitem><label><code>[ wfc: ... ]</code></label>\r
+<def>\r
+<p>well-formedness constraint; this identifies by name a constraint on <termref\r
+def="dt-wellformed">well-formed</termref> documents associated with a production.</p>\r
+</def></gitem>\r
+<gitem><label><code>[ vc: ... ]</code></label>\r
+<def>\r
+<p>validity constraint; this identifies by name a constraint on <termref def="dt-valid">valid</termref>\r
+documents associated with a production.</p>\r
+</def></gitem>\r
+</glist></p>\r
+</div1>\r
+</body><back>\r
+<!-- &SGML; -->\r
+<!-- &Biblio; -->\r
+<div1 id="sec-bibliography">\r
+<head>References</head>\r
+<div2 id="sec-existing-stds">\r
+<head>Normative References</head>\r
+<blist>\r
+<bibl id="IANA" diff="chg" key="IANA-CHARSETS"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E58">[E58]</loc>(Internet\r
+Assigned Numbers Authority) <titleref>Official Names for Character Sets</titleref>,\r
+ed. Keld Simonsen et al. See <loc href="ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets">ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets</loc\r
+>. </bibl>\r
+<bibl id="RFC1766" href="http://www.ietf.org/rfc/rfc1766.txt" key="IETF RFC 1766">IETF\r
+(Internet Engineering Task Force). <titleref>RFC 1766: Tags for the Identification\r
+of Languages</titleref>, ed. H. Alvestrand. 1995.</bibl>\r
+<bibl id="ISO639-old" diff="del" key="ISO 639"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E38">[E38]</loc>\r
+(International Organization for Standardization). <titleref>ISO 639:1988 (E).\r
+Code for the representation of names of languages.</titleref> [Geneva]: International\r
+Organization for Standardization, 1988.</bibl>\r
+<bibl id="ISO3166-old" diff="del" key="ISO 3166"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E38">[E38]</loc>\r
+(International Organization for Standardization). <titleref>ISO 3166-1:1997\r
+(E). Codes for the representation of names of countries and their subdivisions &mdash;\r
+Part 1: Country codes</titleref> [Geneva]: International Organization for\r
+Standardization, 1997.</bibl>\r
+<bibl id="ISO10646" key="ISO/IEC 10646">ISO (International Organization for\r
+Standardization). <titleref>ISO/IEC 10646-1993 (E). Information technology &mdash;\r
+Universal Multiple-Octet Coded Character Set (UCS) &mdash; Part 1: Architecture\r
+and Basic Multilingual Plane.</titleref> [Geneva]: International Organization\r
+for Standardization, 1993 (plus amendments AM 1 through AM 7).</bibl>\r
+<bibl id="ISO10646-2000" diff="add" key="ISO/IEC 10646-2000"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</loc> ISO (International\r
+Organization for Standardization). <titleref>ISO/IEC 10646-1:2000. Information\r
+technology &mdash; Universal Multiple-Octet Coded Character Set (UCS) &mdash;\r
+Part 1: Architecture and Basic Multilingual Plane.</titleref> [Geneva]: International\r
+Organization for Standardization, 2000.</bibl>\r
+<bibl id="Unicode" key="Unicode">The Unicode Consortium. <emph>The Unicode\r
+Standard, Version 2.0.</emph> Reading, Mass.: Addison-Wesley Developers Press,\r
+1996.</bibl>\r
+<bibl id="Unicode3" diff="add" key="Unicode3"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</loc>\r
+The Unicode Consortium. <emph>The Unicode Standard, Version 3.0.</emph> Reading,\r
+Mass.: Addison-Wesley Developers Press, 2000. ISBN 0-201-61633-5.</bibl>\r
+</blist></div2>\r
+<div2 id="null">\r
+<!--\r
+ID made "null" to match its previous value in the First\r
+Edition; it's odd, but if there's no set value, the stylesheet \r
+currently generates an odd string that would be backwards\r
+incompatible with any references anyone might have made before.\r
+-->\r
+<head>Other References</head>\r
+<blist>\r
+<bibl id="Aho" key="Aho/Ullman">Aho, Alfred V., Ravi Sethi, and Jeffrey D.\r
+Ullman. <titleref>Compilers: Principles, Techniques, and Tools</titleref>.\r
+Reading: Addison-Wesley, 1986, rpt. corr. 1988.</bibl>\r
+<bibl id="Berners-Lee" key="Berners-Lee et al."> Berners-Lee, T., R. Fielding,\r
+and L. Masinter. <titleref>Uniform Resource Identifiers (URI): Generic Syntax\r
+and Semantics</titleref>. 1997. (Work in progress; see updates to RFC1738.)</bibl>\r
+<bibl id="ABK" diff="chg" key="Brüggemann-Klein"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E2">[E2]</loc>Brüggemann-Klein,\r
+Anne. Formal Models in Document Processing. Habilitationsschrift. Faculty\r
+of Mathematics at the University of Freiburg, 1993. (See <loc href="ftp://ftp.informatik.uni-freiburg.de/documents/papers/brueggem/habil.ps">ftp://ftp.informatik.uni-freiburg.de/documents/papers/brueggem/habil.ps</loc\r
+>.)</bibl>\r
+<bibl id="ABKDW" diff="chg" key="Brüggemann-Klein and Wood"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E2">[E2]</loc>Brüggemann-Klein,\r
+Anne, and Derick Wood. <titleref>Deterministic Regular Languages</titleref>.\r
+Universität Freiburg, Institut für Informatik, Bericht 38, Oktober 1991. Extended\r
+abstract in A. Finkel, M. Jantzen, Hrsg., STACS 1992, S. 173-184. Springer-Verlag,\r
+Berlin 1992. Lecture Notes in Computer Science 577. Full version titled <titleref>One-Unambiguous\r
+Regular Languages</titleref> in Information and Computation 140 (2): 229-253,\r
+February 1998.</bibl>\r
+<bibl id="Clark" key="Clark">James Clark. Comparison of SGML and XML. See <loc\r
+href="http://www.w3.org/TR/NOTE-sgml-xml-971215">http://www.w3.org/TR/NOTE-sgml-xml-971215</loc>. </bibl>\r
+<bibl id="IANA-LANGCODES" diff="add" href="http://www.isi.edu/in-notes/iana/assignments/languages/"\r
+key="IANA-LANGCODES"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E58">[E58]</loc>(Internet\r
+Assigned Numbers Authority) <titleref>Registry of Language Tags</titleref>,\r
+ed. Keld Simonsen et al.</bibl>\r
+<bibl id="RFC1738" diff="del" href="http://www.ietf.org/rfc/rfc1738.txt" key="IETF RFC1738">IETF\r
+(Internet Engineering Task Force). <titleref>RFC 1738: Uniform Resource Locators\r
+(URL)</titleref>, ed. T. Berners-Lee, L. Masinter, M. McCahill. 1994. </bibl>\r
+<bibl id="RFC1808" diff="del" href="http://www.ietf.org/rfc/rfc1808.txt" key="IETF RFC1808">IETF\r
+(Internet Engineering Task Force). <titleref>RFC 1808: Relative Uniform Resource\r
+Locators</titleref>, ed. R. Fielding. 1995. </bibl>\r
+<bibl id="RFC2141" href="http://www.ietf.org/rfc/rfc2141.txt" key="IETF RFC2141">IETF\r
+(Internet Engineering Task Force). <emph>RFC 2141: URN Syntax</emph>, ed.\r
+R. Moats. 1997. </bibl>\r
+<bibl id="rfc2279" diff="add" href="http://www.ietf.org/rfc/rfc2279.txt" key="IETF RFC 2279"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E78">[E78]</loc>IETF\r
+(Internet Engineering Task Force). <titleref>RFC 2279: UTF-8, a transformation\r
+format of ISO 10646</titleref>, <phrase diff="add">ed. F. Yergeau, </phrase>1998.</bibl>\r
+<bibl id="rfc2376" diff="add" href="http://www.ietf.org/rfc/rfc2376.txt" key="IETF RFC 2376"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E48">[E48]</loc>IETF\r
+(Internet Engineering Task Force). <titleref>RFC 2376: XML Media Types</titleref>.\r
+ed. E. Whitehead, M. Murata. 1998.</bibl>\r
+<bibl id="rfc2396" diff="add" href="http://www.ietf.org/rfc/rfc2396.txt" key="IETF RFC 2396"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E66">[E66]</loc>IETF\r
+(Internet Engineering Task Force). <titleref>RFC 2396: Uniform Resource Identifiers\r
+(URI): Generic Syntax</titleref>. T. Berners-Lee, R. Fielding, L. Masinter.\r
+1998.</bibl>\r
+<bibl id="rfc2732" diff="add" href="http://www.ietf.org/rfc/rfc2732.txt" key="IETF RFC 2732"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E66">[E66]</loc>IETF\r
+(Internet Engineering Task Force). <titleref>RFC 2732: Format for Literal\r
+IPv6 Addresses in URL's</titleref>. R. Hinden, B. Carpenter, L. Masinter.\r
+1999.</bibl>\r
+<bibl id="rfc2781" diff="add" href="http://www.ietf.org/rfc/rfc2781.txt" key="IETF RFC 2781"><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E77">[E77]</loc>\r
+IETF (Internet Engineering Task Force). <emph>RFC 2781: UTF-16, an encoding\r
+of ISO 10646</emph>, ed. P. Hoffman, F. Yergeau. 2000.</bibl>\r
+<bibl id="ISO639" diff="add" key="ISO 639"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E38">[E38]</loc>\r
+(International Organization for Standardization). <titleref>ISO 639:1988 (E).\r
+Code for the representation of names of languages.</titleref> [Geneva]: International\r
+Organization for Standardization, 1988.</bibl>\r
+<bibl id="ISO3166" diff="add" key="ISO 3166"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E38">[E38]</loc>\r
+(International Organization for Standardization). <titleref>ISO 3166-1:1997\r
+(E). Codes for the representation of names of countries and their subdivisions &mdash;\r
+Part 1: Country codes</titleref> [Geneva]: International Organization for\r
+Standardization, 1997.</bibl>\r
+<bibl id="ISO8879" key="ISO 8879">ISO (International Organization for Standardization). <titleref>ISO\r
+8879:1986(E). Information processing &mdash; Text and Office Systems &mdash;\r
+Standard Generalized Markup Language (SGML).</titleref> First edition &mdash;\r
+1986-10-15. [Geneva]: International Organization for Standardization, 1986. </bibl>\r
+<bibl id="ISO10744" key="ISO/IEC 10744">ISO (International Organization for\r
+Standardization). <titleref>ISO/IEC 10744-1992 (E). Information technology &mdash;\r
+Hypermedia/Time-based Structuring Language (HyTime). </titleref> [Geneva]:\r
+International Organization for Standardization, 1992. <emph>Extended Facilities\r
+Annexe.</emph> [Geneva]: International Organization for Standardization, 1996. </bibl>\r
+<bibl id="websgml" diff="add" href="http://www.sgmlsource.com/8879rev/n0029.htm"\r
+key="WEBSGML"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E43">[E43]</loc>ISO\r
+(International Organization for Standardization). <titleref>ISO 8879:1986\r
+TC2. Information technology &mdash; Document Description and Processing Languages. </titleref>\r
+[Geneva]: International Organization for Standardization, 1998.</bibl>\r
+<bibl id="xml-names" diff="add" xmlns:xlink="http://www.w3.org/TR/WD-xlink"\r
+href="http://www.w3.org/TR/REC-xml-names/" key="XML Names"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E98">[E98]</loc>Tim Bray,\r
+Dave Hollander, and Andrew Layman, editors. <titleref>Namespaces in XML</titleref>.\r
+Textuality, Hewlett-Packard, and Microsoft. World Wide Web Consortium, 1999.</bibl>\r
+</blist></div2>\r
+</div1>\r
+<div1 id="CharClasses">\r
+<head>Character Classes</head>\r
+<p>Following the characteristics defined in the Unicode standard, characters\r
+are classed as base characters (among others, these contain the alphabetic\r
+characters of the Latin alphabet<phrase diff="del"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E84">[E84]</loc>, without\r
+diacritics</phrase>), ideographic characters, and combining characters (among\r
+others, this class contains most diacritics)<phrase diff="del"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E30">[E30]</loc>; these classes\r
+combine to form the class of letters.</phrase> Digits and extenders are also\r
+distinguished.</p>\r
+<scrap id="CHARACTERS" lang="ebnf">\r
+<head>Characters</head>\r
+<prodgroup pcw3="3" pcw4="15">\r
+<prod id="NT-Letter">\r
+<lhs>Letter</lhs><rhs><nt def="NT-BaseChar">BaseChar</nt> | <nt def="NT-Ideographic">Ideographic</nt></rhs>\r
+</prod>\r
+<prod id="NT-BaseChar">\r
+<lhs>BaseChar</lhs><rhs>[#x0041-#x005A] |&nbsp;[#x0061-#x007A] |&nbsp;[#x00C0-#x00D6]\r
+|&nbsp;[#x00D8-#x00F6] |&nbsp;[#x00F8-#x00FF] |&nbsp;[#x0100-#x0131] |&nbsp;[#x0134-#x013E]\r
+|&nbsp;[#x0141-#x0148] |&nbsp;[#x014A-#x017E] |&nbsp;[#x0180-#x01C3] |&nbsp;[#x01CD-#x01F0]\r
+|&nbsp;[#x01F4-#x01F5] |&nbsp;[#x01FA-#x0217] |&nbsp;[#x0250-#x02A8] |&nbsp;[#x02BB-#x02C1]\r
+|&nbsp;#x0386 |&nbsp;[#x0388-#x038A] |&nbsp;#x038C |&nbsp;[#x038E-#x03A1]\r
+|&nbsp;[#x03A3-#x03CE] |&nbsp;[#x03D0-#x03D6] |&nbsp;#x03DA |&nbsp;#x03DC\r
+|&nbsp;#x03DE |&nbsp;#x03E0 |&nbsp;[#x03E2-#x03F3] |&nbsp;[#x0401-#x040C]\r
+|&nbsp;[#x040E-#x044F] |&nbsp;[#x0451-#x045C] |&nbsp;[#x045E-#x0481] |&nbsp;[#x0490-#x04C4]\r
+|&nbsp;[#x04C7-#x04C8] |&nbsp;[#x04CB-#x04CC] |&nbsp;[#x04D0-#x04EB] |&nbsp;[#x04EE-#x04F5]\r
+|&nbsp;[#x04F8-#x04F9] |&nbsp;[#x0531-#x0556] |&nbsp;#x0559 |&nbsp;[#x0561-#x0586]\r
+|&nbsp;[#x05D0-#x05EA] |&nbsp;[#x05F0-#x05F2] |&nbsp;[#x0621-#x063A] |&nbsp;[#x0641-#x064A]\r
+|&nbsp;[#x0671-#x06B7] |&nbsp;[#x06BA-#x06BE] |&nbsp;[#x06C0-#x06CE] |&nbsp;[#x06D0-#x06D3]\r
+|&nbsp;#x06D5 |&nbsp;[#x06E5-#x06E6] |&nbsp;[#x0905-#x0939] |&nbsp;#x093D\r
+|&nbsp;[#x0958-#x0961] |&nbsp;[#x0985-#x098C] |&nbsp;[#x098F-#x0990] |&nbsp;[#x0993-#x09A8]\r
+|&nbsp;[#x09AA-#x09B0] |&nbsp;#x09B2 |&nbsp;[#x09B6-#x09B9] |&nbsp;[#x09DC-#x09DD]\r
+|&nbsp;[#x09DF-#x09E1] |&nbsp;[#x09F0-#x09F1] |&nbsp;[#x0A05-#x0A0A] |&nbsp;[#x0A0F-#x0A10]\r
+|&nbsp;[#x0A13-#x0A28] |&nbsp;[#x0A2A-#x0A30] |&nbsp;[#x0A32-#x0A33] |&nbsp;[#x0A35-#x0A36]\r
+|&nbsp;[#x0A38-#x0A39] |&nbsp;[#x0A59-#x0A5C] |&nbsp;#x0A5E |&nbsp;[#x0A72-#x0A74]\r
+|&nbsp;[#x0A85-#x0A8B] |&nbsp;#x0A8D |&nbsp;[#x0A8F-#x0A91] |&nbsp;[#x0A93-#x0AA8]\r
+|&nbsp;[#x0AAA-#x0AB0] |&nbsp;[#x0AB2-#x0AB3] |&nbsp;[#x0AB5-#x0AB9] |&nbsp;#x0ABD\r
+|&nbsp;#x0AE0 |&nbsp;[#x0B05-#x0B0C] |&nbsp;[#x0B0F-#x0B10] |&nbsp;[#x0B13-#x0B28]\r
+|&nbsp;[#x0B2A-#x0B30] |&nbsp;[#x0B32-#x0B33] |&nbsp;[#x0B36-#x0B39] |&nbsp;#x0B3D\r
+|&nbsp;[#x0B5C-#x0B5D] |&nbsp;[#x0B5F-#x0B61] |&nbsp;[#x0B85-#x0B8A] |&nbsp;[#x0B8E-#x0B90]\r
+|&nbsp;[#x0B92-#x0B95] |&nbsp;[#x0B99-#x0B9A] |&nbsp;#x0B9C |&nbsp;[#x0B9E-#x0B9F]\r
+|&nbsp;[#x0BA3-#x0BA4] |&nbsp;[#x0BA8-#x0BAA] |&nbsp;[#x0BAE-#x0BB5] |&nbsp;[#x0BB7-#x0BB9]\r
+|&nbsp;[#x0C05-#x0C0C] |&nbsp;[#x0C0E-#x0C10] |&nbsp;[#x0C12-#x0C28] |&nbsp;[#x0C2A-#x0C33]\r
+|&nbsp;[#x0C35-#x0C39] |&nbsp;[#x0C60-#x0C61] |&nbsp;[#x0C85-#x0C8C] |&nbsp;[#x0C8E-#x0C90]\r
+|&nbsp;[#x0C92-#x0CA8] |&nbsp;[#x0CAA-#x0CB3] |&nbsp;[#x0CB5-#x0CB9] |&nbsp;#x0CDE\r
+|&nbsp;[#x0CE0-#x0CE1] |&nbsp;[#x0D05-#x0D0C] |&nbsp;[#x0D0E-#x0D10] |&nbsp;[#x0D12-#x0D28]\r
+|&nbsp;[#x0D2A-#x0D39] |&nbsp;[#x0D60-#x0D61] |&nbsp;[#x0E01-#x0E2E] |&nbsp;#x0E30\r
+|&nbsp;[#x0E32-#x0E33] |&nbsp;[#x0E40-#x0E45] |&nbsp;[#x0E81-#x0E82] |&nbsp;#x0E84\r
+|&nbsp;[#x0E87-#x0E88] |&nbsp;#x0E8A |&nbsp;#x0E8D |&nbsp;[#x0E94-#x0E97]\r
+|&nbsp;[#x0E99-#x0E9F] |&nbsp;[#x0EA1-#x0EA3] |&nbsp;#x0EA5 |&nbsp;#x0EA7\r
+|&nbsp;[#x0EAA-#x0EAB] |&nbsp;[#x0EAD-#x0EAE] |&nbsp;#x0EB0 |&nbsp;[#x0EB2-#x0EB3]\r
+|&nbsp;#x0EBD |&nbsp;[#x0EC0-#x0EC4] |&nbsp;[#x0F40-#x0F47] |&nbsp;[#x0F49-#x0F69]\r
+|&nbsp;[#x10A0-#x10C5] |&nbsp;[#x10D0-#x10F6] |&nbsp;#x1100 |&nbsp;[#x1102-#x1103]\r
+|&nbsp;[#x1105-#x1107] |&nbsp;#x1109 |&nbsp;[#x110B-#x110C] |&nbsp;[#x110E-#x1112]\r
+|&nbsp;#x113C |&nbsp;#x113E |&nbsp;#x1140 |&nbsp;#x114C |&nbsp;#x114E |&nbsp;#x1150\r
+|&nbsp;[#x1154-#x1155] |&nbsp;#x1159 |&nbsp;[#x115F-#x1161] |&nbsp;#x1163\r
+|&nbsp;#x1165 |&nbsp;#x1167 |&nbsp;#x1169 |&nbsp;[#x116D-#x116E] |&nbsp;[#x1172-#x1173]\r
+|&nbsp;#x1175 |&nbsp;#x119E |&nbsp;#x11A8 |&nbsp;#x11AB |&nbsp;[#x11AE-#x11AF]\r
+|&nbsp;[#x11B7-#x11B8] |&nbsp;#x11BA |&nbsp;[#x11BC-#x11C2] |&nbsp;#x11EB\r
+|&nbsp;#x11F0 |&nbsp;#x11F9 |&nbsp;[#x1E00-#x1E9B] |&nbsp;[#x1EA0-#x1EF9]\r
+|&nbsp;[#x1F00-#x1F15] |&nbsp;[#x1F18-#x1F1D] |&nbsp;[#x1F20-#x1F45] |&nbsp;[#x1F48-#x1F4D]\r
+|&nbsp;[#x1F50-#x1F57] |&nbsp;#x1F59 |&nbsp;#x1F5B |&nbsp;#x1F5D |&nbsp;[#x1F5F-#x1F7D]\r
+|&nbsp;[#x1F80-#x1FB4] |&nbsp;[#x1FB6-#x1FBC] |&nbsp;#x1FBE |&nbsp;[#x1FC2-#x1FC4]\r
+|&nbsp;[#x1FC6-#x1FCC] |&nbsp;[#x1FD0-#x1FD3] |&nbsp;[#x1FD6-#x1FDB] |&nbsp;[#x1FE0-#x1FEC]\r
+|&nbsp;[#x1FF2-#x1FF4] |&nbsp;[#x1FF6-#x1FFC] |&nbsp;#x2126 |&nbsp;[#x212A-#x212B]\r
+|&nbsp;#x212E |&nbsp;[#x2180-#x2182] |&nbsp;[#x3041-#x3094] |&nbsp;[#x30A1-#x30FA]\r
+|&nbsp;[#x3105-#x312C] |&nbsp;[#xAC00-#xD7A3] </rhs>\r
+</prod>\r
+<prod id="NT-Ideographic">\r
+<lhs>Ideographic</lhs><rhs>[#x4E00-#x9FA5] |&nbsp;#x3007 |&nbsp;[#x3021-#x3029] </rhs>\r
+</prod>\r
+<prod id="NT-CombiningChar">\r
+<lhs>CombiningChar</lhs><rhs>[#x0300-#x0345] |&nbsp;[#x0360-#x0361] |&nbsp;[#x0483-#x0486]\r
+|&nbsp;[#x0591-#x05A1] |&nbsp;[#x05A3-#x05B9] |&nbsp;[#x05BB-#x05BD] |&nbsp;#x05BF\r
+|&nbsp;[#x05C1-#x05C2] |&nbsp;#x05C4 |&nbsp;[#x064B-#x0652] |&nbsp;#x0670\r
+|&nbsp;[#x06D6-#x06DC] |&nbsp;[#x06DD-#x06DF] |&nbsp;[#x06E0-#x06E4] |&nbsp;[#x06E7-#x06E8]\r
+|&nbsp;[#x06EA-#x06ED] |&nbsp;[#x0901-#x0903] |&nbsp;#x093C |&nbsp;[#x093E-#x094C]\r
+|&nbsp;#x094D |&nbsp;[#x0951-#x0954] |&nbsp;[#x0962-#x0963] |&nbsp;[#x0981-#x0983]\r
+|&nbsp;#x09BC |&nbsp;#x09BE |&nbsp;#x09BF |&nbsp;[#x09C0-#x09C4] |&nbsp;[#x09C7-#x09C8]\r
+|&nbsp;[#x09CB-#x09CD] |&nbsp;#x09D7 |&nbsp;[#x09E2-#x09E3] |&nbsp;#x0A02\r
+|&nbsp;#x0A3C |&nbsp;#x0A3E |&nbsp;#x0A3F |&nbsp;[#x0A40-#x0A42] |&nbsp;[#x0A47-#x0A48]\r
+|&nbsp;[#x0A4B-#x0A4D] |&nbsp;[#x0A70-#x0A71] |&nbsp;[#x0A81-#x0A83] |&nbsp;#x0ABC\r
+|&nbsp;[#x0ABE-#x0AC5] |&nbsp;[#x0AC7-#x0AC9] |&nbsp;[#x0ACB-#x0ACD] |&nbsp;[#x0B01-#x0B03]\r
+|&nbsp;#x0B3C |&nbsp;[#x0B3E-#x0B43] |&nbsp;[#x0B47-#x0B48] |&nbsp;[#x0B4B-#x0B4D]\r
+|&nbsp;[#x0B56-#x0B57] |&nbsp;[#x0B82-#x0B83] |&nbsp;[#x0BBE-#x0BC2] |&nbsp;[#x0BC6-#x0BC8]\r
+|&nbsp;[#x0BCA-#x0BCD] |&nbsp;#x0BD7 |&nbsp;[#x0C01-#x0C03] |&nbsp;[#x0C3E-#x0C44]\r
+|&nbsp;[#x0C46-#x0C48] |&nbsp;[#x0C4A-#x0C4D] |&nbsp;[#x0C55-#x0C56] |&nbsp;[#x0C82-#x0C83]\r
+|&nbsp;[#x0CBE-#x0CC4] |&nbsp;[#x0CC6-#x0CC8] |&nbsp;[#x0CCA-#x0CCD] |&nbsp;[#x0CD5-#x0CD6]\r
+|&nbsp;[#x0D02-#x0D03] |&nbsp;[#x0D3E-#x0D43] |&nbsp;[#x0D46-#x0D48] |&nbsp;[#x0D4A-#x0D4D]\r
+|&nbsp;#x0D57 |&nbsp;#x0E31 |&nbsp;[#x0E34-#x0E3A] |&nbsp;[#x0E47-#x0E4E]\r
+|&nbsp;#x0EB1 |&nbsp;[#x0EB4-#x0EB9] |&nbsp;[#x0EBB-#x0EBC] |&nbsp;[#x0EC8-#x0ECD]\r
+|&nbsp;[#x0F18-#x0F19] |&nbsp;#x0F35 |&nbsp;#x0F37 |&nbsp;#x0F39 |&nbsp;#x0F3E\r
+|&nbsp;#x0F3F |&nbsp;[#x0F71-#x0F84] |&nbsp;[#x0F86-#x0F8B] |&nbsp;[#x0F90-#x0F95]\r
+|&nbsp;#x0F97 |&nbsp;[#x0F99-#x0FAD] |&nbsp;[#x0FB1-#x0FB7] |&nbsp;#x0FB9\r
+|&nbsp;[#x20D0-#x20DC] |&nbsp;#x20E1 |&nbsp;[#x302A-#x302F] |&nbsp;#x3099\r
+|&nbsp;#x309A </rhs>\r
+</prod>\r
+<prod id="NT-Digit">\r
+<lhs>Digit</lhs><rhs>[#x0030-#x0039] |&nbsp;[#x0660-#x0669] |&nbsp;[#x06F0-#x06F9]\r
+|&nbsp;[#x0966-#x096F] |&nbsp;[#x09E6-#x09EF] |&nbsp;[#x0A66-#x0A6F] |&nbsp;[#x0AE6-#x0AEF]\r
+|&nbsp;[#x0B66-#x0B6F] |&nbsp;[#x0BE7-#x0BEF] |&nbsp;[#x0C66-#x0C6F] |&nbsp;[#x0CE6-#x0CEF]\r
+|&nbsp;[#x0D66-#x0D6F] |&nbsp;[#x0E50-#x0E59] |&nbsp;[#x0ED0-#x0ED9] |&nbsp;[#x0F20-#x0F29] </rhs>\r
+</prod>\r
+<prod id="NT-Extender">\r
+<lhs>Extender</lhs><rhs>#x00B7 |&nbsp;#x02D0 |&nbsp;#x02D1 |&nbsp;#x0387 |&nbsp;#x0640\r
+|&nbsp;#x0E46 |&nbsp;#x0EC6 |&nbsp;#x3005 |&nbsp;[#x3031-#x3035] |&nbsp;[#x309D-#x309E]\r
+|&nbsp;[#x30FC-#x30FE] </rhs>\r
+</prod>\r
+</prodgroup></scrap>\r
+<p>The character classes defined here can be derived from the Unicode <phrase\r
+diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</loc>2.0</phrase>\r
+character database as follows:</p>\r
+<ulist>\r
+<item><p>Name start characters must have one of the categories Ll, Lu, Lo,\r
+Lt, Nl.</p></item>\r
+<item><p>Name characters other than Name-start characters must have one of\r
+the categories Mc, Me, Mn, Lm, or Nd.</p></item>\r
+<item><p>Characters in the compatibility area (i.e. with character code greater\r
+than #xF900 and less than #xFFFE) are not allowed in XML names.</p></item>\r
+<item><p>Characters which have a font or compatibility decomposition (i.e.\r
+those with a <quote>compatibility formatting tag</quote> in field 5 of the\r
+database -- marked by field 5 beginning with a <quote>&lt;</quote>) are not\r
+allowed.</p></item>\r
+<item><p>The following characters are treated as name-start characters rather\r
+than name characters, because the property file classifies them as Alphabetic:\r
+[#x02BB-#x02C1], #x0559, #x06E5, #x06E6.</p></item>\r
+<item><p>Characters #x20DD-#x20E0 are excluded (in accordance with Unicode <phrase\r
+diff="add"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</loc>2.0</phrase>,\r
+section 5.14).</p></item>\r
+<item><p>Character #x00B7 is classified as an extender, because the property\r
+list so identifies it.</p></item>\r
+<item><p>Character #x0387 is added as a name character, because #x00B7 is\r
+its canonical equivalent.</p></item>\r
+<item><p>Characters ':' and '_' are allowed as name-start characters.</p>\r
+</item>\r
+<item><p>Characters '-' and '.' are allowed as name characters.</p></item>\r
+</ulist>\r
+</div1>\r
+<inform-div1 id="sec-xml-and-sgml">\r
+<head>XML and SGML</head>\r
+<p><phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E43">[E43]</loc>XML\r
+is designed to be a subset of SGML, in that every XML document should also\r
+be a conforming SGML document.</phrase> For a detailed comparison of the additional\r
+restrictions that XML places on documents beyond those of SGML, see <bibref\r
+ref="Clark"/>.</p>\r
+</inform-div1>\r
+<inform-div1 id="sec-entexpand">\r
+<head>Expansion of Entity and Character References</head>\r
+<p>This appendix contains some examples illustrating the sequence of entity-\r
+and character-reference recognition and expansion, as specified in <specref\r
+ref="entproc"/>.</p>\r
+<p>If the DTD contains the declaration</p>\r
+<eg><![CDATA[<!ENTITY example "<p>An ampersand (&#38;#38;) may be escaped\r
+numerically (&#38;#38;#38;) or with a general entity\r
+(&amp;amp;).</p>" >]]></eg>\r
+<p>then the XML processor will recognize the character references when it\r
+parses the entity declaration, and resolve them before storing the following\r
+string as the value of the entity <quote><code>example</code></quote>:</p>\r
+<eg><![CDATA[<p>An ampersand (&#38;) may be escaped\r
+numerically (&#38;#38;) or with a general entity\r
+(&amp;amp;).</p>]]></eg>\r
+<p>A reference in the document to <quote><code>&amp;example;</code></quote>\r
+will cause the text to be reparsed, at which time the start- and end-tags\r
+of the <el>p</el> element will be recognized and the three references will\r
+be recognized and expanded, resulting in a <el>p</el> element with the following\r
+content (all data, no delimiters or markup):</p>\r
+<eg><![CDATA[An ampersand (&) may be escaped\r
+numerically (&#38;) or with a general entity\r
+(&amp;).]]></eg>\r
+<p>A more complex example will illustrate the rules and their effects fully.\r
+In the following example, the line numbers are solely for reference.</p>\r
+<eg><![CDATA[1 <?xml version='1.0'?>\r
+2 <!DOCTYPE test [\r
+3 <!ELEMENT test (#PCDATA) >\r
+4 <!ENTITY % xx '&#37;zz;'>\r
+5 <!ENTITY % zz '&#60;!ENTITY tricky "error-prone" >' >\r
+6 %xx;\r
+7 ]>\r
+8 <test>This sample shows a &tricky; method.</test>]]></eg>\r
+<p>This produces the following:</p>\r
+<ulist spacing="compact">\r
+<item><p>in line 4, the reference to character 37 is expanded immediately,\r
+and the parameter entity <quote><code>xx</code></quote> is stored in the symbol\r
+table with the value <quote><code>%zz;</code></quote>. Since the replacement\r
+text is not rescanned, the reference to parameter entity <quote><code>zz</code></quote>\r
+is not recognized. (And it would be an error if it were, since <quote><code>zz</code></quote>\r
+is not yet declared.)</p></item>\r
+<item><p>in line 5, the character reference <quote><code>&amp;#60;</code></quote>\r
+is expanded immediately and the parameter entity <quote><code>zz</code></quote>\r
+is stored with the replacement text <quote><code>&lt;!ENTITY tricky "error-prone"\r
+></code></quote>, which is a well-formed entity declaration.</p></item>\r
+<item><p>in line 6, the reference to <quote><code>xx</code></quote> is recognized,\r
+and the replacement text of <quote><code>xx</code></quote> (namely <quote><code>%zz;</code></quote>)\r
+is parsed. The reference to <quote><code>zz</code></quote> is recognized in\r
+its turn, and its replacement text (<quote><code>&lt;!ENTITY tricky "error-prone"\r
+></code></quote>) is parsed. The general entity <quote><code>tricky</code></quote>\r
+has now been declared, with the replacement text <quote><code>error-prone</code></quote>.</p>\r
+</item>\r
+<item><p>in line 8, the reference to the general entity <quote><code>tricky</code></quote>\r
+is recognized, and it is expanded, so the full content of the <el>test</el>\r
+element is the self-describing (and ungrammatical) string <emph>This sample\r
+shows a error-prone method.</emph></p></item>\r
+</ulist>\r
+</inform-div1>\r
+<inform-div1 id="determinism">\r
+<head>Deterministic Content Models</head>\r
+<p><phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E102">[E102]</loc>As\r
+noted in <specref ref="sec-element-content"/>, it is required that content\r
+models in element type declarations be deterministic. This requirement is <termref\r
+def="dt-compat">for compatibility</termref> with SGML (which calls deterministic\r
+content models <quote>unambiguous</quote>);</phrase> XML processors built\r
+using SGML systems may flag non-deterministic content models as errors.</p>\r
+<p>For example, the content model <code>((b, c) | (b, d))</code> is non-deterministic,\r
+because given an initial <el>b</el> the <phrase diff="chg"><loc role="erratumref"\r
+href="http://www.w3.org/XML/xml-19980210-errata#E95">[E95]</loc>XML processor</phrase>\r
+cannot know which <el>b</el> in the model is being matched without looking\r
+ahead to see which element follows the <el>b</el>. In this case, the two references\r
+to <el>b</el> can be collapsed into a single reference, making the model read <code>(b,\r
+(c | d))</code>. An initial <el>b</el> now clearly matches only a single name\r
+in the content model. The <phrase diff="chg"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E95">[E95]</loc>processor</phrase\r
+> doesn't need to look ahead to see what follows; either <el>c</el> or <el>d</el>\r
+would be accepted.</p>\r
+<p>More formally: a finite state automaton may be constructed from the content\r
+model using the standard algorithms, e.g. algorithm 3.5 in section 3.9 of\r
+Aho, Sethi, and Ullman <bibref ref="Aho"/>. In many such algorithms, a follow\r
+set is constructed for each position in the regular expression (i.e., each\r
+leaf node in the syntax tree for the regular expression); if any position\r
+has a follow set in which more than one following position is labeled with\r
+the same element type name, then the content model is in error and may be\r
+reported as an error.</p>\r
+<p>Algorithms exist which allow many but not all non-deterministic content\r
+models to be reduced automatically to equivalent deterministic models; see\r
+Brüggemann-Klein 1991 <bibref ref="ABK"/>.</p>\r
+</inform-div1>\r
+<inform-div1 id="sec-guessing">\r
+<head><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E105">[E105]</loc><loc\r
+role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E48">[E48]</loc>Autodetection\r
+of Character Encodings</head>\r
+<p>The XML encoding declaration functions as an internal label on each entity,\r
+indicating which character encoding is in use. Before an XML processor can\r
+read the internal label, however, it apparently has to know what character\r
+encoding is in use&mdash;which is what the internal label is trying to indicate.\r
+In the general case, this is a hopeless situation. It is not entirely hopeless\r
+in XML, however, because XML limits the general case in two ways: each implementation\r
+is assumed to support only a finite set of character encodings, and the XML\r
+encoding declaration is restricted in position and content in order to make\r
+it feasible to autodetect the character encoding in use in each entity in\r
+normal cases. Also, in many cases other sources of information are available\r
+in addition to the XML data stream itself. Two cases may be distinguished,\r
+depending on whether the XML entity is presented to the processor without,\r
+or with, any accompanying (external) information. We consider the first case\r
+first.</p>\r
+<div2 id="sec-guessing-no-ext-info">\r
+<head diff="add">Detection Without External Encoding Information</head>\r
+<p>Because each XML entity <phrase diff="add">not accompanied by external\r
+encoding information and </phrase>not in UTF-8 or UTF-16 <phrase diff="chg">encoding</phrase> <emph>must</emph>\r
+begin with an XML encoding declaration, in which the first characters must\r
+be '<code>&lt;?xml</code>', any conforming processor can detect, after two\r
+to four octets of input, which of the following cases apply. In reading this\r
+list, it may help to know that in UCS-4, '&lt;' is <quote><code>#x0000003C</code></quote>\r
+and '?' is <quote><code>#x0000003F</code></quote>, and the Byte Order Mark\r
+required of UTF-16 data streams is <quote><code>#xFEFF</code></quote>. <phrase\r
+diff="add">The notation <var>##</var> is used to denote any byte value except <phrase\r
+diff="chg">that two consecutive <var>##</var>s cannot be both 00</phrase>.</phrase></p>\r
+<p diff="add">With a Byte Order Mark:</p>\r
+<table diff="add" border="1" frame="border"><tbody><tr><td><code>00 00 FE\r
+FF</code></td><td>UCS-4, big-endian machine (1234 order)</td></tr><tr><td><code>FF\r
+FE 00 00</code></td><td>UCS-4, little-endian machine (4321 order)</td></tr>\r
+<tr><td><code>00 00 FF FE</code></td><td>UCS-4, unusual octet order (2143)</td>\r
+</tr><tr><td><code>FE FF 00 00</code></td><td>UCS-4, unusual octet order (3412)</td>\r
+</tr><tr><td><code>FE FF ## ##</code></td><td>UTF-16, big-endian</td></tr>\r
+<tr><td><code>FF FE ## ##</code></td><td>UTF-16, little-endian</td></tr><tr>\r
+<td><code>EF BB BF</code></td><td>UTF-8</td></tr></tbody></table>\r
+<p diff="add">Without a Byte Order Mark:</p>\r
+<table diff="add" border="1" frame="border"><tbody><tr><td><code>00&nbsp;00&nbsp;00&nbsp;3C</code></td>\r
+<td rowspan="4">UCS-4 or other encoding with a 32-bit code unit and ASCII\r
+characters encoded as ASCII values, in respectively big-endian (1234), little-endian\r
+(4321) and two unusual byte orders (2143 and 3412). The encoding declaration\r
+must be read to determine which of UCS-4 or other supported 32-bit encodings\r
+applies.</td></tr><tr><td><code>3C 00 00 00</code></td>\r
+<!--<td>UCS-4, little-endian machine (4321 order)</td>-->\r
+</tr><tr><td><code>00 00 3C 00</code></td>\r
+<!--<td>UCS-4, unusual octet order (2143)</td>-->\r
+</tr><tr><td><code>00 3C 00 00</code></td>\r
+<!--<td>UCS-4, unusual octet order (3412)</td>-->\r
+</tr><tr><td><code>00 3C 00 3F</code></td><td>UTF-16BE or big-endian ISO-10646-UCS-2\r
+or other encoding with a 16-bit code unit in big-endian order and ASCII characters\r
+encoded as ASCII values (the encoding declaration must be read to determine\r
+which)</td></tr><tr><td><code>3C 00 3F 00</code></td><td>UTF-16LE or little-endian\r
+ISO-10646-UCS-2 or other encoding with a 16-bit code unit in little-endian\r
+order and ASCII characters encoded as ASCII values (the encoding declaration\r
+must be read to determine which)</td></tr><tr><td><code>3C 3F 78 6D</code></td>\r
+<td>UTF-8, ISO 646, ASCII, some part of ISO 8859, Shift-JIS, EUC, or any other\r
+7-bit, 8-bit, or mixed-width encoding which ensures that the characters of\r
+ASCII have their normal positions, width, and values; the actual encoding\r
+declaration must be read to detect which of these applies, but since all of\r
+these encodings use the same bit patterns for the relevant ASCII characters,\r
+the encoding declaration itself may be read reliably</td></tr><tr><td><code>4C\r
+6F A7 94</code></td><td>EBCDIC (in some flavor; the full encoding declaration\r
+must be read to tell which code page is in use)</td></tr><tr><td>Other</td>\r
+<td>UTF-8 without an encoding declaration, or else the data stream is mislabeled\r
+(lacking a required encoding declaration), corrupt, fragmentary, or enclosed\r
+in a wrapper of some kind</td></tr></tbody></table>\r
+<note diff="add">\r
+<p>In cases above which do not require reading the encoding declaration to\r
+determine the encoding, section 4.3.3 still requires that the encoding declaration,\r
+if present, be read and that the encoding name be checked to match the actual\r
+encoding of the entity. Also, it is possible that new character encodings\r
+will be invented that will make it necessary to use the encoding declaration\r
+to determine the encoding, in cases where this is not required at present.</p>\r
+</note>\r
+<p>This level of autodetection is enough to read the XML encoding declaration\r
+and parse the character-encoding identifier, which is still necessary to distinguish\r
+the individual members of each family of encodings (e.g. to tell UTF-8 from\r
+8859, and the parts of 8859 from each other, or to distinguish the specific\r
+EBCDIC code page in use, and so on).</p>\r
+<p>Because the contents of the encoding declaration are restricted to <phrase\r
+diff="chg">characters from the ASCII repertoire (however encoded)</phrase>,\r
+a processor can reliably read the entire encoding declaration as soon as it\r
+has detected which family of encodings is in use. Since in practice, all widely\r
+used character encodings fall into one of the categories above, the XML encoding\r
+declaration allows reasonably reliable in-band labeling of character encodings,\r
+even when external sources of information at the operating-system or transport-protocol\r
+level are unreliable. <phrase diff="del">Note that since external parsed entities\r
+in UTF-16 may begin with any character, this autodetection does not always\r
+work. Also, </phrase><phrase diff="add">Character encodings such as UTF-7\r
+that make overloaded usage of ASCII-valued bytes may fail to be reliably detected.</phrase></p>\r
+<p>Once the processor has detected the character encoding in use, it can act\r
+appropriately, whether by invoking a separate input routine for each case,\r
+or by calling the proper conversion function on each character of input.</p>\r
+<p>Like any self-labeling system, the XML encoding declaration will not work\r
+if any software changes the entity's character set or encoding without updating\r
+the encoding declaration. Implementors of character-encoding routines should\r
+be careful to ensure the accuracy of the internal and external information\r
+used to label the entity.</p>\r
+</div2>\r
+<div2 id="sec-guessing-with-ext-info">\r
+<head diff="add">Priorities in the Presence of External Encoding Information</head>\r
+<p>The second possible case occurs when the XML entity is accompanied by encoding\r
+information, as in some file systems and some network protocols. When multiple\r
+sources of information are available, their relative priority and the preferred\r
+method of handling conflict should be specified as part of the higher-level\r
+protocol used to deliver XML. <phrase diff="chg">In particular, please refer\r
+to <bibref ref="rfc2376"/> or its successor, which defines the <code>text/xml</code>\r
+and <code>application/xml</code> MIME types and provides some useful guidance.\r
+In the interests of interoperability, however, the following rule is recommended.</phrase></p>\r
+<ulist>\r
+<item><p>If an XML entity is in a file, the Byte-Order Mark and encoding declaration <phrase\r
+diff="del">PI </phrase>are used (if present) to determine the character encoding.<phrase\r
+diff="del"><loc role="erratumref" href="http://www.w3.org/XML/xml-19980210-errata#E74">[E74]</loc>\r
+All other heuristics and sources of information are solely for error recovery.</phrase></p>\r
+</item>\r
+</ulist>\r
+<ulist diff="del">\r
+<item><p>If an XML entity is delivered with a MIME type of text/xml, then\r
+the <code>charset</code> parameter on the MIME type determines the character\r
+encoding method; all other heuristics and sources of information are solely\r
+for error recovery.</p></item>\r
+<item><p>If an XML entity is delivered with a MIME type of application/xml,\r
+then the Byte-Order Mark and encoding-declaration PI are used (if present)\r
+to determine the character encoding. All other heuristics and sources of information\r
+are solely for error recovery.</p></item>\r
+</ulist>\r
+<p diff="del">These rules apply only in the absence of protocol-level documentation;\r
+in particular, when the MIME types text/xml and application/xml are defined,\r
+the recommendations of the relevant RFC will supersede these rules.</p>\r
+</div2>\r
+</inform-div1>\r
+<inform-div1 id="sec-xml-wg">\r
+<head>W3C XML Working Group</head>\r
+<p>This specification was prepared and approved for publication by the W3C\r
+XML Working Group (WG). WG approval of this specification does not necessarily\r
+imply that all WG members voted for its approval. The current and former members\r
+of the XML WG are:</p>\r
+<orglist>\r
+<member><name>Jon Bosak</name><affiliation>Sun</affiliation><role>Chair</role>\r
+</member>\r
+<member><name>James Clark</name><role>Technical Lead</role></member>\r
+<member><name>Tim Bray</name><affiliation>Textuality and Netscape</affiliation>\r
+<role>XML Co-editor</role></member>\r
+<member><name>Jean Paoli</name><affiliation>Microsoft</affiliation><role>XML\r
+Co-editor</role></member>\r
+<member><name>C. M. Sperberg-McQueen</name><affiliation>U. of Ill.</affiliation>\r
+<role>XML Co-editor</role></member>\r
+<member><name>Dan Connolly</name><affiliation>W3C</affiliation><role>W3C Liaison</role>\r
+</member>\r
+<member><name>Paula Angerstein</name><affiliation>Texcel</affiliation></member>\r
+<member><name>Steve DeRose</name><affiliation>INSO</affiliation></member>\r
+<member><name>Dave Hollander</name><affiliation>HP</affiliation></member>\r
+<member><name>Eliot Kimber</name><affiliation>ISOGEN</affiliation></member>\r
+<member><name>Eve Maler</name><affiliation>ArborText</affiliation></member>\r
+<member><name>Tom Magliery</name><affiliation>NCSA</affiliation></member>\r
+<member><name>Murray Maloney</name><affiliation diff="chg">SoftQuad, Grif\r
+SA, Muzmo and Veo Systems</affiliation></member>\r
+<member><name diff="chg">MURATA Makoto (FAMILY Given)</name><affiliation>Fuji\r
+Xerox Information Systems</affiliation></member>\r
+<member><name>Joel Nava</name><affiliation>Adobe</affiliation></member>\r
+<member><name>Conleth O'Connell</name><affiliation>Vignette</affiliation>\r
+</member>\r
+<member><name>Peter Sharpe</name><affiliation>SoftQuad</affiliation></member>\r
+<member><name>John Tigue</name><affiliation>DataChannel</affiliation></member>\r
+</orglist>\r
+</inform-div1>\r
+<inform-div1 id="sec-core-wg" diff="add">\r
+<head>W3C XML Core Group</head>\r
+<p>The second edition of this specification was prepared by the W3C XML Core\r
+Working Group (WG). The members of the WG at the time of publication of this\r
+edition were:</p>\r
+<orglist>\r
+<member><name>Paula Angerstein</name><affiliation>Vignette</affiliation></member>\r
+<member><name>Daniel Austin</name><affiliation>Ask Jeeves</affiliation></member>\r
+<member><name>Tim Boland</name></member>\r
+<member><name>Allen Brown</name><affiliation>Microsoft</affiliation></member>\r
+<member><name>Dan Connolly</name><affiliation>W3C</affiliation><role>Staff\r
+Contact</role></member>\r
+<member><name>John Cowan</name><affiliation>Reuters Limited</affiliation>\r
+</member>\r
+<member><name>John Evdemon</name><affiliation>XMLSolutions Corporation</affiliation>\r
+</member>\r
+<member><name>Paul Grosso</name><affiliation>Arbortext</affiliation><role>Co-Chair</role>\r
+</member>\r
+<member><name>Arnaud Le Hors</name><affiliation>IBM</affiliation><role>Co-Chair</role>\r
+</member>\r
+<member><name>Eve Maler</name><affiliation>Sun Microsystems</affiliation>\r
+<role>Second Edition Editor</role></member>\r
+<member><name>Jonathan Marsh</name><affiliation>Microsoft</affiliation></member>\r
+<member><name>MURATA Makoto (FAMILY Given)</name><affiliation>IBM</affiliation>\r
+</member>\r
+<member><name>Mark Needleman</name><affiliation>Data Research Associates</affiliation>\r
+</member>\r
+<member><name>David Orchard</name><affiliation>Jamcracker</affiliation></member>\r
+<member><name>Lew Shannon</name><affiliation>NCR</affiliation></member>\r
+<member><name>Richard Tobin</name><affiliation>University of Edinburgh</affiliation>\r
+</member>\r
+<member><name>Daniel Veillard</name><affiliation>W3C</affiliation></member>\r
+<member><name>Dan Vint</name><affiliation>Lexica</affiliation></member>\r
+<member><name>Norman Walsh</name><affiliation>Sun Microsystems</affiliation>\r
+</member>\r
+<member><name>François Yergeau</name><affiliation>Alis Technologies</affiliation>\r
+<role>Errata List Editor</role></member>\r
+<member><name>Kongyi Zhou</name><affiliation>Oracle</affiliation></member>\r
+</orglist>\r
+</inform-div1>\r
+<inform-div1 diff="add">\r
+<head>Production Notes</head>\r
+<p>This Second Edition was encoded in the <loc href="http://www.w3.org/XML/1998/06/xmlspec-v21.dtd">XMLspec\r
+DTD</loc> (which has <loc href="http://www.w3.org/XML/1998/06/xmlspec-report-v21.htm">documentation</loc>\r
+available). The HTML versions were produced with a combination of the <loc\r
+href="http://www.w3.org/XML/1998/06/xmlspec.xsl">xmlspec.xsl</loc>, <loc href="http://www.w3.org/XML/1998/06/diffspec.xsl">diffspec.xsl</loc>,\r
+and <loc href="http://www.w3.org/XML/1998/06/REC-xml-2e.xsl">REC-xml-2e.xsl</loc>\r
+XSLT stylesheets.  The PDF version was produced with the <loc href="http://www.tdb.uu.se/~jan/html2ps.html">html2ps</loc>\r
+facility and a distiller program.</p>\r
+</inform-div1>\r
+</back></spec>\r
diff --git a/tests/xmlspec/W3C-REC.css b/tests/xmlspec/W3C-REC.css
new file mode 100644 (file)
index 0000000..a52b50c
--- /dev/null
@@ -0,0 +1,94 @@
+/* This is an SSI script. Policy:
+   (1) Use CVS
+   (2) send e-mail to w3t-comm@w3.org if you edit this
+*/
+/* Style for a "Recommendation" */
+
+/*
+   This is an SSI script. Policy:
+   (1) Use CVS
+   (2) send e-mail to w3t-comm@w3.org if you edit this
+
+   Acknowledgments:
+
+   - 'background-color' doesn't work on Mac IE 3, but 'background'
+     does (Susan Lesch <lesch@macvirus.com>)
+
+   - 'smaller' leads to illegible text in both Mac IE and Mac NS,
+     'small' is better: works in Mac NS, but is always 12pt in Mac IE
+     3 (Susan Lesch <lesch@macvirus.com>)
+
+   $Id$
+*/
+
+body {
+  margin: 2em 1em 2em 70px;
+  font-family: sans-serif;
+  color: black;
+  background: white;
+  background-position: top left;
+  background-attachment: fixed;
+  background-repeat: no-repeat;
+}
+
+th, td { /* ns 4 */
+  font-family: sans-serif;
+}
+
+h1, h2, h3, h4, h5, h6 { text-align: left }
+h1, h2, h3 { color: #005A9C }
+h1 { font: 170% sans-serif }
+h2 { font: 140% sans-serif }
+h3 { font: 120% sans-serif }
+h4 { font: bold 100% sans-serif }
+h5 { font: italic 100% sans-serif }
+h6 { font: small-caps 100% sans-serif }
+
+.hide { display: none }
+
+div.head { margin-bottom: 1em }
+div.head h1 { margin-top: 2em; clear: both }
+div.head table { margin-left: 2em; margin-top: 2em }
+div.head img { color: white; border: none } /* remove border from top image */
+
+p.copyright { font-size: small }
+p.copyright small { font-size: small }
+
+@media screen {  /* hide from IE3 */
+a:hover { background: #ffa } 
+}
+
+pre { margin-left: 2em }
+/*
+p {
+  margin-top: 0.6em;
+  margin-bottom: 0.6em;
+}
+*/
+dt, dd { margin-top: 0; margin-bottom: 0 } /* opera 3.50 */
+dt { font-weight: bold }
+
+pre, code { font-family: monospace } /* navigator 4 requires this */
+
+ul.toc {
+  list-style: disc;            /* Mac NS has problem with 'none' */
+  list-style: none;
+}
+
+@media aural {  
+  h1, h2, h3 { stress: 20; richness: 90 }
+  .hide { speak: none }
+  p.copyright { volume: x-soft; speech-rate: x-fast }
+  dt { pause-before: 20% }
+  pre { speak-punctuation: code } 
+}
+
+/* Things (icons) that should only show up in projection mode */
+.projection { display: none }
+@media projection { .projection { display: inline } }
+
+
+body {
+  background-image: url(logo-REC);
+}
+
diff --git a/tests/xmlspec/logo-REC b/tests/xmlspec/logo-REC
new file mode 100644 (file)
index 0000000..bddad3e
Binary files /dev/null and b/tests/xmlspec/logo-REC differ
diff --git a/tests/xmlspec/xmlspec-v21.dtd b/tests/xmlspec/xmlspec-v21.dtd
new file mode 100644 (file)
index 0000000..b70fd69
--- /dev/null
@@ -0,0 +1,1734 @@
+<!-- ............................................................... -->
+<!-- XML specification DTD ......................................... -->
+<!-- ............................................................... -->
+
+<!--
+TYPICAL INVOCATION:
+#  <!DOCTYPE spec PUBLIC
+#       "-//W3C//DTD Specification V2.1//EN"
+#       "http://www.w3.org/XML/1998/06/xmlspec-v21.dtd">
+
+PURPOSE:
+  This XML DTD is for W3C specifications and other technical reports.
+  It is based in part on the TEI Lite and Sweb DTDs.
+
+DEPENDENCIES:
+  None.
+
+CHANGE HISTORY:
+  The list of changes is at the end of the DTD.
+
+  For all details, see the design report at:
+
+#   <http://www.w3.org/XML/1998/06/xmlspec-report-v21.htm>
+
+  Search this file for "#" in the first column to see change history
+  comments.  To find changes made this time, search for "2000-03-07".
+
+MAINTAINER:
+  Eve Maler
+  Sun Microsystems, Inc.
+  elm@east.sun.com
+  voice: +1 781 442 3190
+  fax:   +1 781 442 1437
+-->
+
+<!-- ............................................................... -->
+<!-- Entities for characters and symbols ........................... -->
+<!-- ............................................................... -->
+
+<!--
+#1998-03-10: maler: Added &ldquo; and &rdquo;.
+#                   Used 8879:1986-compatible decimal character
+#                   references.
+#                   Merged charent.mod file back into main file.
+#1998-05-14: maler: Fixed ldquo and rdquo.  Gave mdash a real number.
+#1998-12-03: maler: Escaped the leading ampersands.
+-->
+
+<!ENTITY lt     "&#38;#60;">
+<!ENTITY gt     "&#62;">
+<!ENTITY amp    "&#38;#38;">
+<!ENTITY apos   "&#39;">
+<!ENTITY quot   "&#34;">
+<!ENTITY nbsp   "&#160;">
+<!ENTITY mdash  "&#38;#x2014;">
+<!ENTITY ldquo  "&#38;#x201C;">
+<!ENTITY rdquo  "&#38;#x201D;">
+
+<!-- ............................................................... -->
+<!-- Entities for classes of standalone elements ................... -->
+<!-- ............................................................... -->
+
+<!--
+#1997-10-16: maler: Added table to %illus.class;.
+#1997-11-28: maler: Added htable to %illus.class;.
+#1997-12-29: maler: IGNOREd table.
+#1998-03-10: maler: Removed SGML Open-specific %illus.class;.
+#                   Added "local" entities for customization.
+#1998-05-14: maler: Added issue to %note.class;.
+#                   Removed %[local.]statusp.class;.
+#1998-05-21: maler: Added constraintnote to %note.class;.
+#1998-08-22: maler: Changed htable to table in %illus.class;.
+#                   Added definitions to %illus.class;.
+#2000-03-07: maler: Added proto and example to %illus.class;.
+-->
+
+<!ENTITY % local.p.class        "">
+<!ENTITY % p.class              "p
+                                %local.p.class;">
+
+<!ENTITY % local.list.class     "">
+<!ENTITY % list.class           "ulist|olist|slist|glist
+                                %local.list.class;">
+
+<!ENTITY % local.speclist.class "">
+<!ENTITY % speclist.class       "orglist|blist
+                                %local.speclist.class;">
+
+<!ENTITY % local.note.class     "">
+<!ENTITY % note.class           "note|issue|wfcnote|vcnote
+                                |constraintnote %local.note.class;">
+
+<!ENTITY % local.illus.class    "">
+<!ENTITY % illus.class          "eg|graphic|scrap|table|definitions
+                                |proto|example
+                                %local.illus.class;">
+
+<!-- ............................................................... -->
+<!-- Entities for classes of phrase-level elements ................. -->
+<!-- ............................................................... -->
+
+<!--
+#1997-12-29: maler: Added xspecref to %ref.class;.
+#1998-03-10: maler: Added %ednote.class;.
+#                   Added "local" entities for customization.
+#2000-03-07: maler: Added function, var, el, att, and attval to
+#                   %tech.class;.
+#                   Added sub, sup, and phrase to %emph.class;.
+-->
+
+<!ENTITY % local.annot.class    "">
+<!ENTITY % annot.class          "footnote
+                                %local.annot.class;">
+
+<!ENTITY % local.termdef.class  "">
+<!ENTITY % termdef.class        "termdef|term
+                                %local.termdef.class;">
+
+<!ENTITY % local.emph.class     "">
+<!ENTITY % emph.class           "emph|phrase|quote|sub|sup
+                                %local.emph.class;">
+
+<!ENTITY % local.ref.class      "">
+<!ENTITY % ref.class            "bibref|specref|termref|titleref
+                                |xspecref|xtermref
+                                %local.ref.class;">
+
+<!ENTITY % local.loc.class      "">
+<!ENTITY % loc.class            "loc
+                                %local.loc.class;">
+
+<!ENTITY % local.tech.class     "">
+<!ENTITY % tech.class           "kw|nt|xnt|code|function|var
+                                |el|att|attval
+                                %local.tech.class;">
+
+<!ENTITY % local.ednote.class   "">
+<!ENTITY % ednote.class         "ednote
+                                %local.ednote.class;">
+
+<!-- ............................................................... -->
+<!-- Entities for mixtures of standalone elements .................. -->
+<!-- ............................................................... -->
+
+<!--
+#1997-09-30: maler: Created %p.mix; to eliminate p from self.
+#1997-09-30: maler: Added %speclist.class; to %obj.mix; and %p.mix;.
+#1997-09-30: maler: Added %note.class; to %obj.mix; and %p.mix;.
+#1997-10-16: maler: Created %entry.mix;.  Note that some elements
+#                   left out here are still allowed in termdef,
+#                   which entry can contain through %p.pcd.mix;.
+#1997-11-28: maler: Added %p.class; to %statusobj.mix;.
+#1998-03-10: maler: Added %ednote.class; to all mixtures, except
+#                   %p.mix; and %statusobj.mix;, because paragraphs
+#                   and status paragraphs will contain ednote
+#                   through %p.pcd.mix;.
+#1998-03-23: maler: Added %termdef.mix; (broken out from
+#                    %termdef.pcd.mix;).
+#1998-05-14: maler: Removed %statusobj.mix; and all mentions of
+#                   %statusp.mix;.
+-->
+
+<!ENTITY % div.mix
+        "%p.class;|%list.class;|%speclist.class;|%note.class;
+        |%illus.class;|%ednote.class;">
+<!ENTITY % obj.mix
+        "%p.class;|%list.class;|%speclist.class;|%note.class;
+        |%illus.class;|%ednote.class;">
+<!ENTITY % p.mix
+        "%list.class;|%speclist.class;|%note.class;|%illus.class;">
+<!ENTITY % entry.mix
+        "%list.class;|note|eg|graphic|%ednote.class;">
+<!ENTITY % hdr.mix
+        "%p.class;|%list.class;|%ednote.class;">
+<!ENTITY % termdef.mix
+        "%note.class;|%illus.class;">
+
+<!-- ............................................................... -->
+<!-- Entities for mixtures of #PCDATA and phrase-level elements .... -->
+<!-- ............................................................... -->
+
+<!--    Note that %termdef.pcd.mix contains %note.class;
+        and %illus.class;, considered standalone elements. -->
+
+<!--
+#1997-09-30: maler: Added scrap and %note.class; to %termdef.pcd.mix;.
+#1997-11-28: maler: Added %loc.class; to %p.pcd.mix;.
+#1998-03-10: maler: Added %ednote.class; to all mixtures.
+#1998-03-23: maler: Moved some %termdef.pcd.mix; stuff out to
+#                   %termdef.mix;.
+#1998-05-14: maler: Removed %statusp.pcd.mix;.
+#1998-05-21: maler: Added constraint element to %eg.pcd.mix;.
+#1999-07-02: maler: Added %loc.class; to %head.pcd.mix;,
+#                   %label.pcd.mix;, %eg.pcd.mix;, %termdef.pcd.mix;,
+#                   %tech.pcd.mix; (net: all PCD mixes have it).
+#                   Removed unused %loc.pcd.mix;.
+-->
+
+<!ENTITY % p.pcd.mix
+        "#PCDATA|%annot.class;|%termdef.class;|%emph.class;
+        |%ref.class;|%tech.class;|%loc.class;|%ednote.class;">
+<!ENTITY % head.pcd.mix
+        "#PCDATA|%annot.class;|%emph.class;|%tech.class;
+        |%loc.class;|%ednote.class;">
+<!ENTITY % label.pcd.mix
+        "#PCDATA|%annot.class;|%termdef.class;|%emph.class;
+        |%tech.class;|%loc.class;|%ednote.class;">
+<!ENTITY % eg.pcd.mix
+        "#PCDATA|%annot.class;|%emph.class;|%loc.class;
+        |%ednote.class;|constraint">
+<!ENTITY % termdef.pcd.mix
+        "#PCDATA|term|%emph.class;|%ref.class;|%tech.class;
+        |%loc.class;|%ednote.class;">
+<!ENTITY % bibl.pcd.mix
+        "#PCDATA|%emph.class;|%ref.class;|%loc.class;|%ednote.class;">
+<!ENTITY % tech.pcd.mix
+        "#PCDATA|%loc.class;|%ednote.class;">
+
+<!-- ............................................................... -->
+<!-- Entities for customizable content models ...................... -->
+<!-- ............................................................... -->
+
+<!--
+#1998-03-10: maler: Added customization entities.
+#1998-05-14: maler: Allowed prevlocs and latestloc in either order.
+#1999-07-02: maler: Made version optional; added copyright element.
+#2000-03-07: maler: Allowed status and abstract in opposite order.
+-->
+
+<!ENTITY % spec.mdl
+        "header, front?, body, back?">
+
+<!ENTITY % header.mdl
+        "title, subtitle?, version?, w3c-designation, w3c-doctype,
+        pubdate, notice*, publoc, ((prevlocs, latestloc?) |
+        (latestloc, prevlocs?))?, authlist, copyright?,
+        ((status, abstract) | (abstract, status)), pubstmt?,
+        sourcedesc?, langusage, revisiondesc">
+
+<!ENTITY % pubdate.mdl
+        "day?, month, year">
+
+<!-- ............................................................... -->
+<!-- Entities for common attributes ................................ -->
+<!-- ............................................................... -->
+
+<!--
+#2000-03-07: maler: Added %argtypes;.
+-->
+
+<!--    argtypes:
+        Values for function prototype argument datatypes. -->
+<!ENTITY % argtypes
+        '(boolean
+         |expression
+         |location-set
+         |node-set
+         |number
+         |object
+         |point
+         |range
+         |string)'>
+
+<!--    key attribute:
+        Optionally provides a sorting or indexing key, for cases when
+        the element content is inappropriate for this purpose. -->
+<!ENTITY % key.att
+        'key                    CDATA           #IMPLIED'>
+
+<!--    def attribute:
+        Points to the element where the relevant definition can be
+        found, using the IDREF mechanism.  %def.att; is for optional
+        def attributes, and %def-req.att; is for required def
+        attributes. -->
+<!ENTITY % def.att
+        'def                    IDREF           #IMPLIED'>
+<!ENTITY % def-req.att
+        'def                    IDREF           #REQUIRED'>
+
+<!--    ref attribute:
+        Points to the element where more information can be found,
+        using the IDREF mechanism.  %ref.att; is for optional
+        ref attributes, and %ref-req.att; is for required ref
+        attributes. -->
+<!ENTITY % ref.att
+        'ref                    IDREF           #IMPLIED'>
+<!ENTITY % ref-req.att
+        'ref                    IDREF           #REQUIRED'>
+
+<!--
+#1998-03-23: maler: Added show and actuate attributes to href.
+#                   Added semi-common xml:space attribute.
+#1998-08-22: maler: Used new xlink:form and #IMPLIED features.
+#1999-07-02: maler: Reorganized XLink-related entities completely;
+#                   added xmlns:xlink attribute to the mix.
+#2000-03-07: maler: Updated XLink usage to February 2000 draft,
+#                   except that href still has no namespace prefix.
+-->
+
+<!--    xmlns:xlink and xlink:type attributes:
+        xmlns:xlink declares the association of the xlink prefix
+        with the namespace created by the XLink specification.
+        xlink:type identifies an element as an XLink "simple" linking
+        element. -->
+<!ENTITY % simple-xlink.att
+        'xmlns:xlink            CDATA   #FIXED
+                                        "http://www.w3.org/1999/xlink"
+        xlink:type              CDATA   #FIXED "simple" '>
+
+<!--    href attributes:
+        The href attribute locates the remote-resource half of a
+        simple link; the element on which the href appears is the
+        local-resource half.  Some elements are usable links only if
+        the author chooses to supply a functional href.  The attribute
+        name should really be xlink:href, but is kept without the
+        prefix for now in order to be backwards-compatible. -->
+
+<!ENTITY % href.att
+        'href                   CDATA           #IMPLIED '>
+<!ENTITY % href-req.att
+        'href                   CDATA           #REQUIRED '>
+
+<!--    xlink:show and xlink:actuate attributes:
+        These attributes offer instructions to the display engine
+        about how to handle traversal to resource indicated by an
+        href locator. -->
+<!ENTITY % auto-embed.att
+        'xlink:show             CDATA           #FIXED "embed"
+        xlink:actuate           CDATA           #FIXED "onLoad" '>
+<!ENTITY % user-replace.att
+        'xlink:show             CDATA           #FIXED "replace"
+        xlink:actuate           CDATA           #FIXED "onRequest" '>
+<!ENTITY % user-new.att
+        'xlink:show             CDATA           #FIXED "new"
+        xlink:actuate           CDATA           #FIXED "onRequest" '>
+
+<!--    xml:space attribute:
+        Indicates that the element contains whitespace that the
+        formatter or other application should retain, as appropriate
+        to its function. -->
+<!ENTITY % xmlspace.att
+        'xml:space              (default
+                                |preserve)      #FIXED "preserve" '>
+
+<!--
+#2000-03-07: maler: Added common diff attribute.  Made %role.att;.
+-->
+
+<!--    diff attribute:
+        Indicates in what way the element has changed.  When a value
+        is not provided, that subelement should inherit a value from
+        its parent.  If the root element has no value supplied,
+        assume "off". -->
+<!ENTITY % diff.att
+        'diff                   (chg
+                                |add
+                                |del
+                                |off)           #IMPLIED'>
+
+<!--    role attribute:
+        Extends the useful life of the DTD by allowing authors to
+        make a subtype of any element.  No default. -->
+<!ENTITY % role.att
+        'role                   NMTOKEN         #IMPLIED'>
+
+<!--    Common attributes:
+        Every element has an ID attribute for links, a role
+        attribute, and a diff attribute. %common.att; is for
+        common attributes where the ID is optional, and
+        %common-idreq.att; is for common attributes where the
+        ID is required. -->
+<!ENTITY % common.att
+        'id                     ID              #IMPLIED
+        %role.att;
+        %diff.att;'>
+<!ENTITY % common-idreq.att
+        'id                     ID              #REQUIRED
+        %role.att;
+        %diff.att;'>
+
+<!-- ............................................................... -->
+<!-- Common elements ............................................... -->
+<!-- ............................................................... -->
+
+<!--    head: Title on divisions, productions, and the like -->
+<!ELEMENT head (%head.pcd.mix;)*>
+<!ATTLIST head %common.att;>
+
+<!-- ............................................................... -->
+<!-- Major specification structure ................................. -->
+<!-- ............................................................... -->
+
+<!--
+#1998-03-10: maler: Made spec content model easily customizable.
+#1999-07-02: maler: Added doctype atts and status att.
+#2000-03-07: maler: Added cr, issues, and dispcmts to w3c-doctype.
+-->
+
+<!ELEMENT spec (%spec.mdl;)>
+<!--    w3c-doctype attributes:
+        Indicates the type of document, so that the appropriate
+        stylesheet or workflow routing can be applied.  Should
+        *not* generate any text (such as the "REC-" or "NOTE-"
+        prefix on the W3C designation content).  No default.  If
+        w3c-doctype is "other", other-doctype should be filled in.
+
+        status attribute:
+        Indicates the stage of review of the document.  May affect
+        the stylesheet's treatment of ednotes (e.g., whether to
+        output them).  No default. -->
+
+<!ATTLIST spec
+        %common.att;
+        w3c-doctype     (cr
+                        |dispcmts
+                        |issues
+                        |note
+                        |other
+                        |pr
+                        |rec
+                        |wd)                    #IMPLIED
+        other-doctype   CDATA                   #IMPLIED
+        status          (int-review
+                        |ext-review
+                        |final)                 #IMPLIED
+>
+
+<!ELEMENT front (div1+)>
+<!ATTLIST front %common.att;>
+
+<!ELEMENT body (div1+)>
+<!ATTLIST body %common.att;>
+
+<!--
+#1997-09-30: maler: Added inform-div1 to back content.
+-->
+
+<!ELEMENT back ((div1+, inform-div1*) | inform-div1+)>
+<!ATTLIST back %common.att;>
+
+<!ELEMENT div1 (head, (%div.mix;)*, div2*)>
+<!ATTLIST div1 %common.att;>
+
+<!--
+#1997-09-30: maler: Added inform-div1 declarations.
+#2000-03-07: maler: Added div5 level.
+-->
+
+<!--    inform-div1: Non-normative division in back matter -->
+<!ELEMENT inform-div1 (head, (%div.mix;)*, div2*)>
+<!ATTLIST inform-div1 %common.att;>
+
+<!ELEMENT div2 (head, (%div.mix;)*, div3*)>
+<!ATTLIST div2 %common.att;>
+
+<!ELEMENT div3 (head, (%div.mix;)*, div4*)>
+<!ATTLIST div3 %common.att;>
+
+<!ELEMENT div4 (head, (%div.mix;)*, div5*)>
+<!ATTLIST div4 %common.att;>
+
+<!ELEMENT div5 (head, (%div.mix;)*)>
+<!ATTLIST div5 %common.att;>
+
+<!-- ............................................................... -->
+<!-- Specification header .......................................... -->
+<!-- ............................................................... -->
+
+<!--
+#1998-03-10: maler: Made header content model easily customizable.
+-->
+
+<!ELEMENT header (%header.mdl;)>
+<!ATTLIST header %common.att;>
+
+<!--    Example of title: "Extensible Cheese Language (XCL)" -->
+<!ELEMENT title (#PCDATA)>
+<!ATTLIST title %common.att;>
+
+<!--    Example of subtitle: "A Cheesy Specification" -->
+<!ELEMENT subtitle (#PCDATA)>
+<!ATTLIST subtitle %common.att;>
+
+<!--    Example of version: "Version 666.0" -->
+<!ELEMENT version (#PCDATA)>
+<!ATTLIST version %common.att;>
+
+<!--    Example of w3c-designation: "WD-xcl-19991231" -->
+<!ELEMENT w3c-designation (#PCDATA)>
+<!ATTLIST w3c-designation %common.att;>
+
+<!--    Example of w3c-doctype: "W3C Working Draft" -->
+<!ELEMENT w3c-doctype (#PCDATA)>
+<!ATTLIST w3c-doctype %common.att;>
+
+<!--
+#1998-03-10: maler: Made pubdate content model easily customizable.
+-->
+
+<!ELEMENT pubdate (%pubdate.mdl;)>
+<!ATTLIST pubdate %common.att;>
+
+<!ELEMENT day (#PCDATA)>
+<!ATTLIST day %common.att;>
+
+<!ELEMENT month (#PCDATA)>
+<!ATTLIST month %common.att;>
+
+<!ELEMENT year (#PCDATA)>
+<!ATTLIST year %common.att;>
+
+<!--
+#1999-07-02: maler: Declared copyright element.
+-->
+
+<!ELEMENT copyright (%hdr.mix;)+>
+<!ATTLIST copyright %common.att;>
+
+<!--    Example of notice: "This draft is for public comment..." -->
+<!ELEMENT notice (%hdr.mix;)+>
+<!ATTLIST notice %common.att;>
+
+<!--
+#2000-03-07: maler: Broadened models of *loc to %p.pcd.mix;.
+-->
+
+<!ELEMENT publoc (%p.pcd.mix;)*>
+<!ATTLIST publoc %common.att;>
+
+<!ELEMENT prevlocs (%p.pcd.mix;)*>
+<!ATTLIST prevlocs %common.att;>
+
+<!ELEMENT latestloc (%p.pcd.mix;)*>
+<!ATTLIST latestloc %common.att;>
+
+<!--      loc (defined in "Phrase-level elements" below) -->
+
+<!ELEMENT authlist (author+)>
+<!ATTLIST authlist %common.att;>
+
+<!--
+#1997-09-30: maler: Made affiliation optional.
+#1998-03-10: maler: Made email optional.
+-->
+
+<!ELEMENT author (name, affiliation?, email?)>
+<!ATTLIST author %common.att;>
+
+<!ELEMENT name (#PCDATA)>
+<!ATTLIST name
+        %common.att;
+        %key.att;>
+
+<!ELEMENT affiliation (#PCDATA)>
+<!ATTLIST affiliation %common.att;>
+
+<!--
+#1999-07-02: maler: Added show/actuate attributes and default values.
+-->
+
+
+<!ELEMENT email (#PCDATA)>
+<!--    href attribute:
+        email functions as a hypertext reference through this
+        required attribute.  Typically the reference would use
+        the mailto: scheme.  E.g.:
+
+<email href="mailto:elm@arbortext.com">elm@arbortext.com</email>
+        -->
+
+<!ATTLIST email
+        %common.att;
+        %simple-xlink.att;
+        %href-req.att;
+        %user-new.att;>
+
+<!--
+#1998-05-15: maler: Changed status content from %statusobj.mix;
+#                   to plain %obj.mix;.  statusp is obsolete.
+-->
+
+<!ELEMENT status (%obj.mix;)+>
+<!ATTLIST status %common.att;>
+
+<!ELEMENT abstract (%hdr.mix;)*>
+<!ATTLIST abstract %common.att;>
+
+<!ELEMENT pubstmt (%hdr.mix;)+>
+<!ATTLIST pubstmt %common.att;>
+
+<!ELEMENT sourcedesc (%hdr.mix;)+>
+<!ATTLIST sourcedesc %common.att;>
+
+<!ELEMENT langusage (language+)>
+<!ATTLIST langusage %common.att;>
+
+<!ELEMENT language (#PCDATA)>
+<!ATTLIST language %common.att;>
+
+<!ELEMENT revisiondesc (%hdr.mix;)+>
+<!ATTLIST revisiondesc %common.att;>
+
+<!-- ............................................................... -->
+<!-- Paragraph ..................................................... -->
+<!-- ............................................................... -->
+
+<!--
+#1997-09-30: maler: Changed from %obj.mix; to %p.mix;.
+#1997-12-29: maler: Changed order of %p.mix; and %p.pcd.mix;
+#                   references.
+#1997-12-29: maler: Changed order of %statusobj.mix; and
+#                   %statusp.pcd.mix; references.
+#1998-05-14: maler: Removed statusp declarations.
+-->
+
+<!ELEMENT p (%p.pcd.mix;|%p.mix;)*>
+<!ATTLIST p %common.att;>
+
+<!-- ............................................................... -->
+<!-- Regular lists ................................................. -->
+<!-- ............................................................... -->
+
+<!--    ulist: Unordered list, typically bulleted. -->
+<!ELEMENT ulist (item+)>
+<!--    spacing attribute:
+        Use "normal" to get normal vertical spacing for items;
+        use "compact" to get less spacing.  The default is dependent
+        on the stylesheet. -->
+<!ATTLIST ulist
+        %common.att;
+        spacing         (normal|compact)        #IMPLIED>
+
+<!--    olist: Ordered list, typically numbered. -->
+<!ELEMENT olist (item+)>
+<!--    spacing attribute:
+        Use "normal" to get normal vertical spacing for items;
+        use "compact" to get less spacing.  The default is dependent
+        on the stylesheet. -->
+<!ATTLIST olist
+        %common.att;
+        spacing         (normal|compact)        #IMPLIED>
+
+<!ELEMENT item (%obj.mix;)+>
+<!ATTLIST item %common.att;>
+
+<!--    slist: Simple list, typically with no mark. -->
+<!ELEMENT slist (sitem+)>
+<!ATTLIST slist %common.att;>
+
+<!ELEMENT sitem (%p.pcd.mix;)*>
+<!ATTLIST sitem %common.att;>
+
+<!--    glist: Glossary list, typically two-column. -->
+<!ELEMENT glist (gitem+)>
+<!ATTLIST glist %common.att;>
+
+<!ELEMENT gitem (label, def)>
+<!ATTLIST gitem %common.att;>
+
+<!ELEMENT label (%label.pcd.mix;)*>
+<!ATTLIST label %common.att;>
+
+<!ELEMENT def (%obj.mix;)*>
+<!ATTLIST def %common.att;>
+
+<!-- ............................................................... -->
+<!-- Special lists ................................................. -->
+<!-- ............................................................... -->
+
+<!--    blist: Bibliography list. -->
+<!ELEMENT blist (bibl+)>
+<!ATTLIST blist %common.att;>
+
+<!--
+#1999-07-02: maler: Added show/actuate attributes and default values.
+-->
+
+<!ELEMENT bibl (%bibl.pcd.mix;)*>
+<!--    href attribute:
+        bibl optionally functions as a hypertext reference to the
+        referred-to resource through this attribute.  E.g.:
+
+        <bibl href="http://www.my.com/doc.htm">My Document</bibl>
+        -->
+<!ATTLIST bibl
+        %common.att;
+        %simple-xlink.att;
+        %href.att;
+        %user-replace.att;
+        %key.att;>
+
+<!--    orglist: Organization member list. -->
+<!ELEMENT orglist (member+)>
+<!ATTLIST orglist %common.att;>
+
+<!--
+#1997-09-30: maler: Added optional affiliation.
+-->
+
+<!ELEMENT member (name, affiliation?, role?)>
+<!ATTLIST member %common.att;>
+
+<!--      name (defined in "Specification header" above) -->
+<!--      affiliation (defined in "Specification header" above) -->
+
+<!ELEMENT role (#PCDATA)>
+<!ATTLIST role %common.att;>
+
+<!-- ............................................................... -->
+<!-- Notes ......................................................... -->
+<!-- ............................................................... -->
+
+<!ELEMENT note (%obj.mix;)+>
+<!ATTLIST note %common.att;>
+
+<!--
+#1998-05-14: maler: Declared issue element.
+#2000-03-07: maler: Added head, source, resolution, and status.
+-->
+
+<!ELEMENT issue (head?, source*, (%obj.mix;)+, resolution?)>
+<!--    status attribute:
+        Indicates whether the issue is open or closed.  Note that
+        the lack of a resolution element does not necessarily mean
+        that the issue is still open. -->
+<!ATTLIST issue
+        id              ID              #REQUIRED
+        %role.att;
+        %diff.att;
+        status          (open
+                        |closed)        "open"
+>
+
+<!ELEMENT source (%p.pcd.mix;)*>
+<!ATTLIST source
+        %common.att;>
+
+<!ELEMENT resolution (%obj.mix;)+>
+<!ATTLIST resolution %common.att;>
+
+<!--    wfcnote: Well-formedness constraint note. -->
+<!ELEMENT wfcnote (head, (%obj.mix;)+)>
+<!--    ID attribute:
+        wfcnote must have an ID so that it can be pointed to
+        from a wfc element in a production. -->
+<!ATTLIST wfcnote
+        %common-idreq.att;>
+
+<!--    vcnote: Validity constraint note. -->
+<!ELEMENT vcnote (head, (%obj.mix;)+)>
+<!--    ID attribute:
+        vcnote must have an ID so that it can be pointed to
+        from a vc element in a production. -->
+<!ATTLIST vcnote
+        %common-idreq.att;>
+
+<!--
+#1998-05-21: maler: Declared generic constraintnote element.
+-->
+
+<!--    constraintnote: Generic constraint note. -->
+<!ELEMENT constraintnote (head, (%obj.mix;)+)>
+<!--    ID attribute:
+        constraintnote must have an ID so that it can be
+        pointed to from a constraint element in a production. -->
+<!--    type attribute:
+        constraintnote must have a type value keyword so that
+        it can be correctly characterized in the specification. -->
+<!ATTLIST constraintnote
+        %common-idreq.att;
+        type            NMTOKEN         #REQUIRED>
+
+<!-- ............................................................... -->
+<!-- Basic display elements ........................................ -->
+<!-- ............................................................... -->
+
+<!--
+#1998-03-23: maler: Added xml:space attribute.
+-->
+
+<!--    eg: Example element, with whitespace respected. -->
+<!ELEMENT eg (%eg.pcd.mix;)*>
+<!ATTLIST eg
+        %common.att;
+        %xmlspace.att;>
+
+<!--
+#2000-03-07: maler: Removed the xml:attributes attribute.
+#                   Added %local.graphic.att;.
+-->
+
+<!--    graphic: Displayed graphic.  Graphic data should be
+        displayed at the point where it is referenced.  Not
+        actually conforming to XLink right now. -->
+<!ELEMENT graphic EMPTY>
+<!--    source attribute:
+        The graphic data must reside at the location pointed to. -->
+<!ENTITY % local.graphic.att "">
+<!ATTLIST graphic
+        %common.att;
+        %simple-xlink.att;
+        source                  CDATA           #REQUIRED
+        %auto-embed.att;
+        alt                     CDATA           #IMPLIED
+        %local.graphic.att;>
+
+<!--
+#2000-03-07: maler: Added proto element structure.
+-->
+
+<!--    proto: Function prototype, in the XPath/XPointer style. -->
+<!ELEMENT proto (arg*)>
+<!ATTLIST proto
+        %common.att;
+        name            NMTOKEN         #REQUIRED
+        return-type     %argtypes;      #REQUIRED
+>
+
+<!ELEMENT arg EMPTY>
+<!ATTLIST arg
+        %common.att;
+        type            %argtypes;      #REQUIRED
+        occur           (opt|req)       #IMPLIED
+>
+
+<!--
+#2000-03-07: maler: Added example element.
+-->
+
+<!ELEMENT example (head?, (%obj.mix;)+)>
+<!ATTLIST example %common.att;>
+
+<!-- ............................................................... -->
+<!-- EBNF .......................................................... -->
+<!-- ............................................................... -->
+
+<!--
+#1997-11-28: maler: Added prodgroup to scrap and defined it.
+#1998-05-21: maler: Added constraint to prod.
+#1999-07-02: maler: Added prodrecap to scrap; broadened scrap model.
+#                   Added headstyle attribute to scrap.
+-->
+
+<!--    scrap: Collection of EBNF language productions. -->
+<!ELEMENT scrap (head, (prodgroup | prod | bnf | prodrecap)+)>
+<!--    lang attribute:
+        The scrap can link to a description of the language used,
+        found in a language element in the header.
+        headstyle attribute:
+        Allows a scrap title to be suppressed from output.  To be
+        used only when a scrap title directly next to a section
+        title is distracting or repetetive. -->
+<!ATTLIST scrap
+        %common.att;
+        lang            IDREF           #IMPLIED
+        headstyle       (show|suppress) "show"
+>
+
+<!--    prodgroup: Sub-collection of productions, needed for
+        formatting reasons. -->
+<!ELEMENT prodgroup (prod+)>
+<!--    pcw<n> attributes:
+        Presentational attributes to control the width
+        of the "pseudo-table" columns used to output
+        groups of productions. -->
+<!ATTLIST prodgroup
+        %common.att;
+        pcw1            CDATA           #IMPLIED
+        pcw2            CDATA           #IMPLIED
+        pcw3            CDATA           #IMPLIED
+        pcw4            CDATA           #IMPLIED
+        pcw5            CDATA           #IMPLIED
+>
+
+<!--    prod: EBNF language production. -->
+<!ELEMENT prod (lhs, (rhs, (com|wfc|vc|constraint)*)+)>
+<!--    ID attribute:
+        The production must have an ID so that cross-references
+        (specref) and mentions of nonterminals (nt) can link to
+        it. -->
+<!ATTLIST prod
+        %common-idreq.att;>
+
+<!--    lhs: Left-hand side of production. -->
+<!ELEMENT lhs (#PCDATA)>
+<!ATTLIST lhs %common.att;>
+
+<!--    rhs: Right-hand side of production; may have many
+        "right-hand sides," one to a line. -->
+<!ELEMENT rhs (#PCDATA|nt|xnt|com)*>
+<!ATTLIST rhs %common.att;>
+
+<!--      nt and xnt (defined in "Phrase-level elements" below) -->
+
+<!--
+#1997-11-28: maler: Added loc and bibref to com content.
+-->
+
+<!--    com: Production comment. -->
+<!ELEMENT com (#PCDATA|loc|bibref)*>
+<!ATTLIST com %common.att;>
+
+<!--    wfc: Reference to a well-formedness constraint; should
+        generate the head of the wfcnote pointed to. -->
+<!ELEMENT wfc EMPTY>
+<!--    def attribute:
+        Each well formedness tagline in a production must link to the
+        wfcnote that defines it. -->
+<!ATTLIST wfc
+        %def-req.att;
+        %common.att;>
+
+<!--    vc: Reference to a validity constraint; should generate
+        the head of the vcnote pointed to. -->
+<!ELEMENT vc EMPTY>
+<!--    def attribute:
+        Each validity tagline in a production must link to the vcnote
+        that defines it. -->
+<!ATTLIST vc
+        %def-req.att;
+        %common.att;>
+
+<!--
+#1998-05-21: maler: Declared generic constraint element.
+-->
+
+<!--    constraint: Reference to a generic constraint; should
+        generate the head of the constraintnote pointed to. -->
+<!ELEMENT constraint EMPTY>
+<!--    def attribute:
+        Each constraint tagline in a production must link to the
+        constraint note that defines it. -->
+<!ATTLIST constraint
+        %def-req.att;
+        %common.att;>
+
+<!--
+#1998-03-23: maler: Added xml:space attribute.
+-->
+
+<!--    bnf: Un-marked-up EBNF production, with whitespace
+        respected. -->
+<!ELEMENT bnf (%eg.pcd.mix;)*>
+<!ATTLIST bnf
+        %common.att;
+        %xmlspace.att;>
+
+<!--
+#1999-07-02: maler: Declared prodrecap.
+-->
+
+<!--    prodrecap: Reference to production or bnf that appears
+        in its "normative" form elsewhere in the spec; should
+        generate a copy of the original production, without
+        a production number next to it. -->
+<!ELEMENT prodrecap EMPTY>
+<!ATTLIST prodrecap
+        %common.att;
+        %ref-req.att;>
+
+<!-- ............................................................... -->
+<!-- Table ......................................................... -->
+<!-- ............................................................... -->
+
+<!--
+#1997-10-16: maler: Added table mechanism.
+#1997-11-28: maler: Added non-null system ID to entity declaration.
+#                   Added HTML table module.
+#1997-12-29: maler: IGNOREd SGML Open table model.
+#1998-03-10: maler: Removed SGML Open table model.
+#                   Merged html-tbl.mod file into main file.
+#                   Added %common.att; to all HTML table elements.
+#1998-05-14: maler: Replaced table model with full HTML 4.0 model.
+#                   Removed htable in favor of table.
+#                   Removed htbody in favor of tbody.
+-->
+
+<!ENTITY % cellhalign.att
+        'align          (left|center
+                        |right|justify
+                        |char)          #IMPLIED
+        char            CDATA           #IMPLIED
+        charoff         CDATA           #IMPLIED'>
+
+<!ENTITY % cellvalign.att
+        'valign         (top|middle
+                        |bottom
+                        |baseline)      #IMPLIED'>
+
+<!ENTITY % thtd.att
+        'abbr           CDATA           #IMPLIED
+        axis            CDATA           #IMPLIED
+        headers         IDREFS          #IMPLIED
+        scope           (row
+                        |col
+                        |rowgroup
+                        |colgroup)      #IMPLIED
+        rowspan         NMTOKEN         "1"
+        colspan         NMTOKEN         "1"'>
+
+<!ENTITY % width.att
+        'width          CDATA           #IMPLIED'>
+
+<!ENTITY % span.att
+        'span           NMTOKEN         "1"'>
+
+<!--    table: HTML-based geometric table model. -->
+<!ELEMENT table
+        (caption?, (col*|colgroup*), thead?, tfoot?, tbody+)>
+<!ATTLIST table
+        %common.att;
+        %width.att;
+        summary         CDATA           #IMPLIED
+        border          CDATA           #IMPLIED
+        frame           (void|above
+                        |below|hsides
+                        |lhs|rhs
+                        |vsides|box
+                        |border)        #IMPLIED
+        rules           (none|groups
+                        |rows|cols
+                        |all)           #IMPLIED
+        cellspacing     CDATA           #IMPLIED
+        cellpadding     CDATA           #IMPLIED>
+
+<!ELEMENT caption (%p.pcd.mix;)*>
+<!ATTLIST caption %common.att;>
+
+<!ELEMENT col EMPTY>
+<!ATTLIST col
+        %common.att;
+        %span.att;
+        %width.att;
+        %cellhalign.att;
+        %cellvalign.att;>
+
+<!ELEMENT colgroup (col)*>
+<!ATTLIST colgroup
+        %common.att;
+        %span.att;
+        %width.att;
+        %cellhalign.att;
+        %cellvalign.att;>
+
+<!ELEMENT thead (tr)+>
+<!ATTLIST thead
+        %common.att;
+        %cellhalign.att;
+        %cellvalign.att;>
+
+<!ELEMENT tfoot (tr)+>
+<!ATTLIST tfoot
+        %common.att;
+        %cellhalign.att;
+        %cellvalign.att;>
+
+<!ELEMENT tbody (tr)+>
+<!ATTLIST tbody
+        %common.att;
+        %cellhalign.att;
+        %cellvalign.att;>
+
+<!ELEMENT tr (th|td)+>
+<!ATTLIST tr
+        %common.att;
+        %cellhalign.att;
+        %cellvalign.att;>
+
+<!ELEMENT th (%p.pcd.mix;|%p.mix;)*>
+<!ATTLIST th
+        %common.att;
+        %thtd.att;
+        %cellhalign.att;
+        %cellvalign.att;>
+
+<!ELEMENT td (%p.pcd.mix;|%p.mix;)*>
+<!ATTLIST td
+        %common.att;
+        %thtd.att;
+        %cellhalign.att;
+        %cellvalign.att;>
+
+<!-- ............................................................... -->
+<!-- IDL structures for DOM specifications ......................... -->
+<!-- ............................................................... -->
+
+<!-- ............................................................... -->
+<!-- Specialized entities for classes .............................. -->
+
+<!ENTITY % idl-desc.class
+        "p|note">
+
+<!ENTITY % idl-tdef.class
+        "typedef|constant|exception|reference|group">
+
+<!ENTITY % idl-mod.class
+        "module|interface">
+
+<!ENTITY % idl-struct.class
+        "struct|enum|sequence|union|typename">
+
+<!ENTITY % idl-meth.class
+        "method|attribute">
+
+<!-- ............................................................... -->
+<!-- Specialized entities for mixtures ............................. -->
+
+<!--    Quick reference to content model mixtures:
+
+                        desc tdef mod struct meth
+group                     x    x   x    x      x
+definitions, module       x    x   x
+interface                 x    x               x
+typedef, case, component                x
+-->
+
+<!ENTITY % idl-grp.mix
+        "%idl-desc.class;|%idl-tdef.class;|%idl-mod.class;
+        |%idl-struct.class;|%idl-meth.class;">
+
+<!ENTITY % idl-defn.mix
+        "%idl-desc.class;|%idl-tdef.class;|%idl-mod.class;">
+
+<!ENTITY % idl-intfc.mix
+        "%idl-desc.class;|%idl-tdef.class;|%idl-meth.class;">
+
+<!ENTITY % idl-type.mix
+        "%idl-struct.class;">
+
+<!-- ............................................................... -->
+<!-- Specialized entities for common attributes .................... -->
+
+<!--    name attribute:
+        Provides a name.  Required. -->
+<!ENTITY % idl-name.att
+        'name                   CDATA           #REQUIRED'>
+
+<!--    type attribute:
+        Provides a type.  Required. -->
+<!ENTITY % idl-type.att
+        'type                   CDATA           #REQUIRED'>
+
+<!-- ............................................................... -->
+<!-- Common IDL element ............................................ -->
+
+<!ELEMENT descr ((%obj.mix;)*)>
+<!ATTLIST descr %common.att;>
+
+<!-- ............................................................... -->
+<!-- IDL definition elements ....................................... -->
+
+<!--    definitions: Top-level element for definitions. -->
+<!ELEMENT definitions (%idl-defn.mix;)+>
+<!ATTLIST definitions %common.att;>
+
+<!--    group: Element used to group a set of definitions. -->
+
+<!ELEMENT group (descr, (%idl-grp.mix;)*)>
+<!ATTLIST group
+        %common.att;
+        %idl-name.att;>
+
+<!--    interface: Definition of an interface. -->
+<!ELEMENT interface (descr, (%idl-intfc.mix;)*)>
+<!ATTLIST interface
+        %common.att;
+        %idl-name.att;
+        inherits        CDATA           #IMPLIED>
+
+<!--    module: Definition of a module. -->
+<!ELEMENT module (descr, (%idl-defn.mix;)*)>
+<!ATTLIST module
+        %common.att;
+        %idl-name.att;>
+
+<!--    reference: Reference to some other declaration. -->
+<!ELEMENT reference EMPTY>
+<!ATTLIST reference
+        %common.att;
+        declaration     IDREF           #REQUIRED>
+
+<!--    typedef: Definition of a named type. -->
+<!ELEMENT typedef (descr, (%idl-type.mix;))>
+<!ATTLIST typedef
+        %common.att;
+        %idl-name.att;
+        array.size      NMTOKEN         #IMPLIED>
+
+<!--    struct: Declaration of a struct type. -->
+<!ELEMENT struct (descr, component+)>
+<!ATTLIST struct
+        %common.att;
+        %idl-name.att;>
+
+<!--    component: Declaration of a structural member. -->
+<!ELEMENT component (%idl-type.mix;)>
+<!ATTLIST component
+        %common.att;
+        %idl-name.att;>
+
+<!--    union: Declaration of a union type. -->
+<!ELEMENT union (descr, case+)>
+<!ATTLIST union
+        %common.att;
+        %idl-name.att;
+        switch.type     CDATA           #REQUIRED>
+
+<!ELEMENT case (descr, (%idl-type.mix;))>
+<!ATTLIST case
+        %common.att;
+        labels          CDATA           #REQUIRED>
+
+<!--    enum: Declaration of an enum type. -->
+<!ELEMENT enum (descr, enumerator+)>
+<!ATTLIST enum
+        %common.att;
+        %idl-name.att;>
+
+<!ELEMENT enumerator (descr)>
+<!ATTLIST enumerator
+        %common.att;
+        %idl-name.att;>
+
+<!--    sequence: Declaration of a sequence type (not named). -->
+<!ELEMENT sequence (sequence*)>
+<!ATTLIST sequence
+        %common.att;
+        %idl-type.att;
+        size            NMTOKEN         #IMPLIED>
+
+<!--    constant: Declaration of a named constant. -->
+<!ELEMENT constant (descr)>
+<!ATTLIST constant
+        %common.att;
+        %idl-name.att;
+        %idl-type.att;
+        value           CDATA           #REQUIRED>
+
+<!--    exception: Declaration of an exception. -->
+<!ELEMENT exception (descr, component*)>
+<!ATTLIST exception
+        %common.att;
+        %idl-name.att;>
+<!-- component (defined under struct, above)-->
+
+<!--    attribute: Declaration of an attribute (data member). -->
+<!ELEMENT attribute (descr)>
+<!ATTLIST attribute
+        %common.att;
+        %idl-name.att;
+        %idl-type.att;
+        readonly        (yes
+                        |no)            "no">
+
+<!--    method: Declaration of a method. -->
+<!ELEMENT method (descr, parameters, returns, raises)>
+<!ATTLIST method
+        %common.att;
+        %idl-name.att;>
+
+<!ELEMENT parameters (param*)>
+<!ATTLIST parameters %common.att;>
+
+<!ELEMENT param (descr)>
+<!ATTLIST param
+        %common.att;
+        %idl-name.att;
+        %idl-type.att;
+        attr            (in
+                        |out
+                        |inout)         "inout">
+
+<!ELEMENT returns (descr)>
+<!ATTLIST returns
+        %common.att;
+        %idl-type.att;>
+
+<!ELEMENT raises (exception*)>
+<!-- exception (defined under constant, above)-->
+
+<!ELEMENT typename (#PCDATA)>
+<!ATTLIST typename %common.att;>
+
+<!-- ............................................................... -->
+<!-- Phrase-level elements ......................................... -->
+<!-- ............................................................... -->
+
+<!--
+#2000-03-07: maler: Added att and attval elements.
+-->
+
+<!--    att: Attribute name. -->
+<!ELEMENT att (%tech.pcd.mix;)*>
+<!ATTLIST att %common.att;>
+
+<!--    attval: Attribute value. -->
+<!ELEMENT attval (%tech.pcd.mix;)*>
+<!ATTLIST attval %common.att;>
+
+<!--    bibref: Reference to a bibliography list entry; should
+        generate, in square brackets, "key" on bibl. -->
+<!ELEMENT bibref EMPTY>
+<!--    ref attribute:
+        A bibliography reference must link to the bibl element that
+        describes the resource. -->
+<!ATTLIST bibref
+        %common.att;
+        %ref-req.att;>
+
+<!ELEMENT code (%tech.pcd.mix;)*>
+<!ATTLIST code %common.att;>
+
+<!--
+#1998-03-10: maler: Declared ednote and related elements.
+#1999-07-02: maler: Changed edtext content from #PCDATA to %p.pcd.mix;.
+-->
+
+<!--    ednote: Editorial note for communication among editors. -->
+<!ELEMENT ednote (name?, date?, edtext)>
+<!ATTLIST ednote %common.att;>
+
+<!ELEMENT date (#PCDATA)>
+<!ATTLIST date %common.att;>
+
+<!ELEMENT edtext (%p.pcd.mix;)*>
+<!ATTLIST edtext %common.att;>
+
+<!--
+#2000-03-07: maler: Added el element.
+-->
+
+<!--    el: Element type name (GI). -->
+<!ELEMENT el (%tech.pcd.mix;)*>
+<!ATTLIST el %common.att;>
+
+<!--
+#2000-03-07: maler: Expanded emph to %p.pcd.mix;.
+-->
+
+<!ELEMENT emph (%p.pcd.mix;)*>
+<!ATTLIST emph %common.att;>
+
+<!--    footnote: Both footnote content and call to footnote. -->
+<!ELEMENT footnote (%obj.mix;)+>
+<!ATTLIST footnote %common.att;>
+
+<!--
+#2000-03-07: maler: Added function and gave it content of
+#                   %tech.pcd.mix; instead of XPath's #PCDATA.
+-->
+
+<!ELEMENT function (%tech.pcd.mix;)*>
+<!ATTLIST function %common.att;>
+
+<!ELEMENT kw (%tech.pcd.mix;)*>
+<!ATTLIST kw %common.att;>
+
+<!--
+#1999-07-02: maler: Added show/actuate attributes and default values.
+-->
+
+<!--    loc: Generic link to a Web resource, similar to HTML's A. -->
+<!ELEMENT loc (#PCDATA)>
+<!--    href attribute:
+        The purpose of a loc element is to function as a A-like
+        hypertext link to a resource.  (Ideally, the content of loc
+        will also mention the URI of the resource, so that readers of
+        the printed version will be able to locate the resource.) E.g.:
+
+<loc href="http://www.my.com/doc.htm">http://www.my.com/doc.htm</loc>
+        -->
+<!ATTLIST loc
+        %common.att;
+        %simple-xlink.att;
+        %href-req.att;
+        %user-replace.att;>
+
+<!--    nt: Mention of a nonterminal in text, along with a link to
+        the production in the current document that defines it. -->
+<!ELEMENT nt (#PCDATA)>
+<!--    def attribute:
+        The nonterminal must link to the production that defines
+        it. -->
+<!ATTLIST nt
+        %common.att;
+        %def-req.att;>
+
+<!--
+#2000-03-07: maler: Declared phrase.
+-->
+
+<!--    phrase: "Attribute hanger" for small bits of (e.g.) differenced
+        text in a paragraph or similar, when another element isn't handy.
+        Beware that its content model may allow more nested elements than
+        would normally be allowed in some contexts. -->
+<!ELEMENT phrase (%p.pcd.mix;)*>
+<!ATTLIST phrase %common.att;>
+
+<!--
+#1998-03-10: maler: Declared quote.
+-->
+
+<!--    quote: Scare quotes and other purely presentational quotes. -->
+<!ELEMENT quote (%p.pcd.mix;)*>
+<!ATTLIST quote %common.att;>
+
+<!--    specref: Reference to a div, olist item, prod, or issue
+        in the current document; should generate italic "[n.n],
+        Section Title" for div, "n" for numbered item, "[n]" for
+        production, or "Issue id" for issue. -->
+<!ELEMENT specref EMPTY>
+<!--    ref attribute:
+        The purpose of a specref element is to link to a div, item
+        in an olist, or production in the current spec. -->
+<!ATTLIST specref
+        %common.att;
+        %ref-req.att;>
+
+<!--
+#2000-03-07: maler: Added sub and sup.
+-->
+
+<!--    sub: Subscript. -->
+<!ELEMENT sub (#PCDATA)>
+<!ATTLIST sub %common.att;>
+
+<!--    sup: Superscript. -->
+<!ELEMENT sup (#PCDATA)>
+<!ATTLIST sup %common.att;>
+
+<!--    term: The term in text that is being defined in text. -->
+<!ELEMENT term (#PCDATA)>
+<!ATTLIST term %common.att;>
+
+<!--    termdef: Definition of a term in text. -->
+<!ELEMENT termdef (%termdef.pcd.mix;|%termdef.mix;)*>
+<!--    ID attribute:
+        A term definition must have an ID so that it can be linked
+        to from termref elements. -->
+<!--    term attribute:
+        The canonical form of the term or phrase being defined must
+        appear in this attribute, even if the term or phrase also
+        appears in the element content in identical form (e.g., in
+        the term element). -->
+<!ATTLIST termdef
+        %common-idreq.att;
+        term            CDATA           #REQUIRED>
+
+<!--    termref: Mention of a term, along with a link to the
+        definition in the current document. -->
+<!ELEMENT termref (#PCDATA)>
+<!--    ref attribute:
+        A term reference must link to the termdef element that
+        defines the term. -->
+<!ATTLIST termref
+        %common.att;
+        %def-req.att;>
+
+<!--
+#1999-07-02: maler: Added show/actuate attributes and default values.
+-->
+
+<!--    titleref: Citation of another document, which can also
+        link to that document if it is a Web resource. -->
+<!ELEMENT titleref (#PCDATA)>
+<!--    href attribute:
+        A title reference can optionally function as a hypertext
+        link to the resource with this title.  E.g.:
+
+<loc href="http://www.my.com/doc.htm">http://www.my.com/doc.htm</loc>
+        -->
+
+<!ATTLIST titleref
+        %common.att;
+        %simple-xlink.att;
+        %href.att;
+        %user-new.att;>
+
+<!--
+#2000-03-07: maler: Added var.
+-->
+
+<!--    var: String standing for a variable value that the user
+        or system will supply.  For example: "For each node
+        <var>x</var> in this node-set..." -->
+<!ELEMENT var (%tech.pcd.mix;)*>
+<!ATTLIST var %common.att;>
+
+<!--
+#1999-07-02: maler: Added show/actuate attributes and default values.
+-->
+
+<!--    xnt: Mention of a nonterminal in text, along with a link to
+        the production in another document that defines it. -->
+<!ELEMENT xnt (#PCDATA)>
+<!--    href attribute:
+        The nonterminal must hyperlink to a resource that serves
+        to define it (e.g., a production in a related XML
+        specification).  E.g.:
+
+<xnt href="http://www.w3.org/TR/spec.htm#prod3">Name</xnt>
+        -->
+
+<!ATTLIST xnt
+        %common.att;
+        %simple-xlink.att;
+        %href-req.att;
+        %user-new.att;>
+
+<!--
+#1997-12-29: maler: Declared xspecref.
+#1999-07-02: maler: Added show/actuate attributes and default values.
+-->
+
+<!--    xspecref: Reference to a div, olist item, prod, or issue
+        in a related specification document; should generate
+        no special text. -->
+<!ELEMENT xspecref (#PCDATA)>
+<!--    href attribute:
+        The spec reference must hyperlink to the resource to
+        cross-refer to (e.g., a section in a related XML
+        specification).  E.g.:
+
+<xspecref href="http://www.w3.org/TR/spec.htm#sec2">
+the section on constraints</xspecref>
+        -->
+
+<!ATTLIST xspecref
+        %common.att;
+        %simple-xlink.att;
+        %href-req.att;
+        %user-new.att;>
+
+<!--
+#1999-07-02: maler: Added show/actuate attributes and default values.
+-->
+
+<!--    termref: Mention of a term, along with a link to the
+        definition in a related document. -->
+<!ELEMENT xtermref (#PCDATA)>
+<!--    href attribute:
+        The term reference must hyperlink to the resource that
+        serves to define the term (e.g., a term definition in
+        a related XML specification).  E.g.:
+
+<xtermref href="http://www.w3.org/TR/spec.htm#term5">
+entity
+</xtermref>
+        -->
+
+<!ATTLIST xtermref
+        %common.att;
+        %simple-xlink.att;
+        %href-req.att;
+        %user-new.att;>
+
+<!-- ............................................................... -->
+<!-- Unused elements for ADEPT ..................................... -->
+<!-- ............................................................... -->
+
+<!--
+#1997-09-30: maler: Added unusued elements.
+#1997-10-14: maler: Fixed div to move nested div to the mixture.
+#1998-05-14: maler: Added key-term, htable, and htbody.
+#1998-11-30: maler: Added para, listitem, itemizedlist, and orderedlist.
+-->
+
+<!--    The following elements are purposely declared but never
+        referenced.  Declaring them allows them to be pasted from
+        an HTML document, an earlier version of an XMLspec document,
+        or a DocBook document into a document using this DTD in ADEPT.
+        The ATD Context Transformation mechanism will try to convert
+        them to the appropriate element for this DTD.  While this
+        conversion will not work for all fragments, it does allow many
+        cases to work reasonably well. -->
+
+<!ELEMENT div
+        (head?, (%div.mix;|ul|ol|h1|h2|h3|h4|h5|h6|div)*)>
+<!ELEMENT h1 (%head.pcd.mix;|em|a)*>
+<!ELEMENT h2 (%head.pcd.mix;|em|a)*>
+<!ELEMENT h3 (%head.pcd.mix;|em|a)*>
+<!ELEMENT h4 (%head.pcd.mix;|em|a)*>
+<!ELEMENT h5 (%head.pcd.mix;|em|a)*>
+<!ELEMENT h6 (%head.pcd.mix;|em|a)*>
+<!ELEMENT pre (%eg.pcd.mix;|em)*>
+<!ELEMENT ul (item|li)*>
+<!ELEMENT ol (item|li)*>
+<!ELEMENT li (#PCDATA|%obj.mix;)*>
+<!ELEMENT em (#PCDATA)>
+<!ELEMENT a (#PCDATA)>
+
+<!ELEMENT key-term (#PCDATA)>
+<!ELEMENT htable
+        (caption?, (col*|colgroup*), thead?, tfoot?, tbody+)>
+<!ELEMENT htbody (tr)+>
+<!ELEMENT statusp (%p.pcd.mix;|%p.mix;)*>
+
+<!ELEMENT itemizedlist (listitem*)>
+<!ELEMENT orderedlist (listitem*)>
+<!ELEMENT listitem (para*)>
+<!ELEMENT para (#PCDATA)>
+
+<!-- ............................................................... -->
+<!-- Change history ................................................ -->
+<!-- ............................................................... -->
+
+<!--
+#1997-08-18: maler
+#- Did a major revision.
+#1997-09-10: maler
+#- Updated FPI.
+#- Removed namekey element and put key attribute on name element.
+#- Made statusp element and supporting entities.
+#- Added slist element with sitem+ content.
+#- Required head on scrap and added new bnf subelement.
+#- Added an xnt element and allowed it and nt in regular text and rhs.
+#- Removed the ntref element.
+#- Added back the com element to the content of rhs.
+#- Added a key attribute to bibl.
+#- Removed the ident element.
+#- Added a term element to be used inside termdef.
+#- Added an xtermref element parallel to termref.
+#- Beefed up DTD comments.
+#1997-09-12: maler
+#- Allowed term element in general text.
+#- Changed bibref to EMPTY.
+#- Added ref.class to termdef.pcd.mix.
+#1997-09-14: maler
+#- Changed main attribute of xtermref from def to href.
+#- Added termdef.class to label contents.
+#1997-09-30: maler
+#- Added character entity module and added new entities.
+#- Removed p from appearing directly in self; created %p.mix;.
+#- Added inform-div (non-normative division) element.
+#- Fixed xtermref comment to mention href, not ref.
+#- Extended orglist model to allow optional affiliation.
+#- Modified author to make affiliation optional.
+#- Added %speclist.class; and %note.class; to %obj.mix; and %p.mix;.
+#- Added %note.class; and %illus.class; to %termdef.pcd.mix;.
+#- Added unused HTML elements.
+#- Put empty system ID next to public ID in entity declarations.
+#1997-10-14: maler
+#- Fixed "unused" div content model to move nested div to mixture.
+#1997-10-16: maler
+#- Added SGML Open Exchange tables.
+#1997-11-28: maler
+#- Added support for prodgroup and its attributes.
+#- Added support for HTML tables.
+#- Added loc and bibref to content of com.
+#- Added loc to general p content models.
+#- Allowed p as alternative to statusp in status.
+#- Added non-null system IDs to external parameter entity declarations.
+#- (Modified the SGML Open table module to make it XML-compliant.)
+#- (Modified the character entity module.)
+#1997-12-29: maler
+#- Moved #PCDATA occurrences to come before GIs in content models.
+#- Removed use of the SGML Open table module.
+#- Added xspecref element.
+#- Ensured that all FPIs contain 4-digit year.
+#- (Modified the character entity module.)
+#1998-03-10: maler
+#- Merged the character entity and table modules into the main file.
+#- Added ldquo and rdquo entities.
+#- Added common attributes to prodgroup.
+#- Made the email element in header optional.
+#- Removed reference to the SGML Open table model.
+#- Added ednote element.
+#- Added quote element.
+#- Updated XLink usage to reflect 3 March 1998 WD.
+#- Added "local" entities to the class entities for customization.
+#- Parameterized several content models to allow for customization.
+#1998-03-23: maler
+#- Cleaned up some comments and removed some others.
+#- Added xml:space semi-common attribute to eg and bnf elements.
+#- Added show and embed attributes on all the uses of href.
+#- Added %common.att; to all HTML table elements.
+#- Added a real URI to the "typical invocation" comment.
+#1998-05-14: maler
+#- Fixed mdash, ldquo, and rdquo character entities.
+#- Switched to the full HTML 4.0 table model.
+#- Removed htable/htbody elements and replaced them with table/tbody.
+#- Added issue element to %note.class; and declared it.
+#- Allowed prevlocs and latestloc in either order.
+#- Added key-term, htable, htbody, and statusp as unused elements.
+#- Removed real statusp element in favor of plain p.
+#1998-05-21: maler
+#- Declared generic constraint and constraintnote elements.
+#- Added constraintnote to %note.class;.
+#- Added constraint to %eg.pcd.mix; and prod content model.
+#1998-08-22: maler
+#- Fixed %illus.class; to mention table instead of htable.
+#- Added definitions to %illus.class; for DOM model.
+#- Added DOM definitions element and its substructure.
+#- Updated XLink usage in %href.att; to use xlink:form and #IMPLIED.
+#- Added clarifying comments to href-using elements.
+#1998-11-30: maler
+#- Added new unused elements to support DocBook translation.
+#- Updated maler phone numbers.
+#1998-12-3: maler
+#- Fixed character entities with respect to escaping of ampersands.
+#- Added many more explanatory comments.
+#1999-07-02: maler
+#- Added %loc.class; to all PCD mixes that didn't already have it.
+#- Removed unused %loc.pcd.mix;.
+#- Made version in spec header optional.
+#- Added three new attributes to spec.
+#- Broadened content of edtext.
+#- Added optional copyright element to header.
+#- Reorganized XLink-related parameter entities; added xmlns:xlink.
+#- Changed edtext content from #PCDATA to %p.pcd.mix;.
+#- Added show/actuate atts and default values to all href elements.
+#- Changed versioning scheme from 8-digit dates to version numbers.
+#- Added w3c-doctype, other-doctype, status atts to spec element.
+#- Added prodrecap element inside scrap.
+#- Added headstyle attribute to scrap.
+#2000-03-07: maler
+#- Added proto element, its arg subelement, and the %argtypes; entity.
+#- Added function, var, sub, sup, phrase, el, att, attval elements.
+#- Expanded emph to %p.pcd.mix;.
+#- Allowed status and abstract to appear in the opposite order.
+#- Updated XLink usage to the latest WD, except for href and source.
+#- Removed the xml:attributes attribute from graphic.
+#- Added %local.graphic.att; to graphic.
+#- Added common diff attribute.
+#- Added div5 element.
+#- Broadened content models of publoc, prevlocs, and latestloc.
+#- Added head, source, resolution, and status attribute to issue.
+#- Added cr, issues, and dispcmts to w3c-doctype attribute on spec.
+#- Added example element.
+-->
+
+<!-- ............................................................... -->
+<!-- End of XML specification DTD .................................. -->
+<!-- ............................................................... -->
diff --git a/tests/xmlspec/xmlspec.xsl b/tests/xmlspec/xmlspec.xsl
new file mode 100644 (file)
index 0000000..5fe48da
--- /dev/null
@@ -0,0 +1,2091 @@
+<?xml version="1.0"?>
+
+<!-- Version: $Id$ -->
+
+<!-- Stylesheet for XMLspec -->
+<!-- Author: Norman Walsh (Norman.Walsh@East.Sun.COM) -->
+<!-- Author: Chris Maden (crism@lexica.net) -->
+<!-- Author: Ben Trafford (ben@legendary.org) -->
+<!-- Author: Eve Maler (eve.maler@east.sun.com) -->
+<!-- Date Created: 1999.09.07 -->
+
+<!-- This stylesheet is copyright (c) 2000 by its authors.  Free
+     distribution and modification is permitted, including adding to
+     the list of authors and copyright holders, as long as this
+     copyright notice is maintained. -->
+
+<!-- This stylesheet attempts to implement the XML Specification V2.1
+     DTD.  Documents conforming to earlier DTDs may not be correctly
+     transformed. -->
+
+<!-- ChangeLog:
+
+     25 Sep 2000: (Norman.Walsh@East.Sun.COM)
+       - Sync'd with Eve's version:
+         o Concatenated each inline element's output all on one line
+           to avoid spurious spaces in the output. (This is really an
+           IE bug, but...) (15 Sep 2000)
+         o Updated crism's email address in header (7 Sep 2000)
+         o Changed handling of affiliation to use comma instead of
+           parentheses (9 Aug 2000)
+
+     14 Aug 2000: (Norman.Walsh@East.Sun.COM)
+
+       - Added additional.title param (for diffspec.xsl to change)
+       - Fixed URI of W3C home icon
+       - Made CSS stylesheet selection depend on the w3c-doctype attribute
+         of spec instead of the w3c-doctype element in the header
+
+     26 Jul 2000: (Norman.Walsh@East.Sun.COM)
+
+       - Improved semantics of specref. Added xsl:message for unsupported
+         cases. (I'm by no means confident that I've covered the whole
+         list.)
+       - Support @role on author.
+       - Make lhs/rhs "code" in EBNF.
+       - Fixed bug in ID/IDREF linking.
+       - More effectively disabled special markup for showing @diffed
+         versions
+
+     21 Jul 2000: (Norman.Walsh@East.Sun.COM)
+
+       - Added support for @diff change tracking, primarily through
+         the auxiliary stylesheet diffspec.xsl. However, it was
+         impractical to handle some constructions, such as DLs and TABLEs,
+         in a completely out-of-band manner. So there is some inline
+         support for @diff markup.
+
+       - Added $additional.css to allow downstream stylesheets to add
+         new markup to the <style> element.
+
+       - Added required "type" attribute to the <style> element.
+
+       - Fixed pervasive problem with nested <a> elements.
+
+       - Added doctype-public to xsl:output.
+
+       - Added $validity.hacks. If "1", then additional disable-output-escaping
+         markup may be inserted in some places to attempt to get proper,
+         valid HTML. For example, if a <glist> appears inside a <p> in the
+         xmlspec source, this creates a nested <dl> inside a <p> in the
+         HTML, which is not valid. If $validity.hacks is "1", then an
+         extra </p>, <p> pair is inserted around the <dl>.
+-->
+
+<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+               xmlns:saxon="http://icl.com/saxon"
+               exclude-result-prefixes="saxon"
+               version="1.0">
+
+  <xsl:param name="validity.hacks">1</xsl:param>
+  <xsl:param name="show.diff.markup">0</xsl:param>
+  <xsl:param name="additional.css"></xsl:param>
+  <xsl:param name="additional.title"></xsl:param>
+  <xsl:param name="called.by.diffspec">0</xsl:param>
+  <xsl:param name="show.ednotes">1</xsl:param>
+
+  <xsl:output method="html"
+       encoding="ISO-8859-1"
+       doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+       indent="no"/>
+
+  <xsl:strip-space elements="author"/>
+
+  <!-- not handled:
+    attribute:   unhandled IDL stuff
+    case:        unhandled IDL stuff
+    component:   unhandled IDL stuff
+    constant:    unhandled IDL stuff
+    copyright:   boilerplate notice always used instead
+    definitions: unhandled IDL stuff
+    descr:       unhandled IDL stuff
+    enum:        unhandled IDL stuff
+    enumerator:  unhandled IDL stuff
+    exception:   unhandled IDL stuff
+    group:       unhandled IDL stuff
+    interface:   unhandled IDL stuff
+    method:      unhandled IDL stuff
+    module:      unhandled IDL stuff
+    param:       unhandled IDL stuff
+    parameters:  unhandled IDL stuff
+    raises:      unhandled IDL stuff
+    reference:   unhandled IDL stuff
+    returns:     unhandled IDL stuff
+    sequence:    unhandled IDL stuff
+    struct:      unhandled IDL stuff
+    typedef:     unhandled IDL stuff
+    typename:    unhandled IDL stuff
+    union:       unhandled IDL stuff
+
+    Warning!
+    Only handles statuses of NOTE, WD, and REC.
+    -->
+
+  <!-- Template for the root node.  Creation of <html> element could
+       go here, but that doesn't feel right. -->
+  <xsl:template match="/">
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <!-- abstract: appears only in header -->
+  <!-- format as a second-level div -->
+  <!-- called in enforced order from header's template -->
+  <xsl:template match="abstract">
+    <div id="abstract">
+      <xsl:text>&#10;</xsl:text>
+      <h2>
+        <a name="abstract">Abstract</a>
+      </h2>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- affiliation: follows a name in author and member -->
+  <!-- put it in parens with a leading space -->
+  <xsl:template match="affiliation">
+    <xsl:text>, </xsl:text>
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <!-- arg: appears only in proto -->
+  <!-- argument in function prototype -->
+  <!-- output argument type, italicized as placeholder; separate the
+       list with commas and spaces -->
+  <xsl:template match="arg">
+    <xsl:if test="preceding-sibling::arg">
+      <xsl:text>, </xsl:text>
+    </xsl:if>
+    <var>
+      <xsl:value-of select="@type"/>
+    </var>
+    <xsl:if test="@occur = 'opt'">
+      <xsl:text>?</xsl:text>
+    </xsl:if>
+  </xsl:template>
+
+  <!-- att: attribute name -->
+  <!-- used lots of places -->
+  <!-- format as monospaced code -->
+  <xsl:template match="att">
+    <code><xsl:apply-templates/></code>
+  </xsl:template>
+
+  <!-- attribute: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- attval: attribute name -->
+  <!-- used lots of places -->
+  <!-- format as quoted string -->
+  <xsl:template match="attval">
+    <xsl:text>"</xsl:text>
+    <xsl:apply-templates/>
+    <xsl:text>"</xsl:text>
+  </xsl:template>
+
+  <!-- authlist: list of authors (editors, really) -->
+  <!-- called in enforced order from header's template, in <dl>
+       context -->
+  <xsl:template match="authlist">
+    <dt>
+      <xsl:text>Editor</xsl:text>
+      <xsl:if test="count(author) > 1">
+        <xsl:text>s</xsl:text>
+      </xsl:if>
+      <xsl:text>:</xsl:text>
+    </dt>
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <!-- author: an editor of a spec -->
+  <!-- only appears in authlist -->
+  <!-- called in <dl> context -->
+  <xsl:template match="author">
+    <dd>
+      <xsl:apply-templates/>
+      <xsl:if test="@role = '2e'">
+       <xsl:text> - Second Edition</xsl:text>
+      </xsl:if>
+    </dd>
+  </xsl:template>
+
+  <!-- back: back matter for the spec -->
+  <!-- make a <div> for neatness -->
+  <!-- affects numbering of div1 children -->
+  <xsl:template match="back">
+    <div class="back">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- bibl: bibliographic entry -->
+  <!-- only appears in blist -->
+  <!-- called with <dl> context -->
+  <!-- if there's a key, use it in the <dt>, otherwise use the ID -->
+  <!-- if there's an href, add a ref in parens at the end of the text -->
+  <xsl:template match="bibl">
+    <dt class="label">
+      <xsl:if test="@id">
+       <a name="{@id}"/>
+      </xsl:if>
+      <xsl:choose>
+       <xsl:when test="@key">
+         <xsl:value-of select="@key"/>
+       </xsl:when>
+       <xsl:otherwise>
+         <xsl:value-of select="@id"/>
+       </xsl:otherwise>
+      </xsl:choose>
+    </dt>
+    <dd>
+      <xsl:apply-templates/>
+      <xsl:if test="@href">
+        <xsl:text>  (See </xsl:text>
+        <a href="{@href}">
+          <xsl:value-of select="@href"/>
+        </a>
+        <xsl:text>.)</xsl:text>
+      </xsl:if>
+    </dd>
+  </xsl:template>
+
+  <!-- bibref: reference to a bibliographic entry -->
+  <!-- make a link to the bibl -->
+  <!-- if the bibl has a key, put it in square brackets; otherwise use
+       the bibl's ID -->
+  <xsl:template match="bibref">
+    <a>
+      <xsl:attribute name="href">
+        <xsl:call-template name="href.target">
+          <xsl:with-param name="target" select="id(@ref)"/>
+        </xsl:call-template>
+      </xsl:attribute>
+      <xsl:text>[</xsl:text>
+      <xsl:choose>
+        <xsl:when test="id(@ref)/@key">
+          <xsl:value-of select="id(@ref)/@key"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="@ref"/>
+        </xsl:otherwise>
+      </xsl:choose>
+      <xsl:text>]</xsl:text>
+    </a>
+  </xsl:template>
+
+  <!-- blist: list of bibliographic entries -->
+  <!-- set up the list and process children -->
+  <xsl:template match="blist">
+    <dl>
+      <xsl:apply-templates/>
+    </dl>
+  </xsl:template>
+
+  <!-- bnf: un-marked-up BNF productions -->
+  <!-- preformatted within a table cell -->
+  <!-- scrap provides <table> context -->
+  <xsl:template match="bnf">
+    <tbody>
+      <tr>
+        <td>
+         <xsl:if test="@diff and $show.diff.markup='1'">
+           <xsl:attribute name="class">
+             <xsl:text>diff-</xsl:text>
+             <xsl:value-of select="@diff"/>
+           </xsl:attribute>
+         </xsl:if>
+          <pre>
+            <xsl:apply-templates/>
+          </pre>
+        </td>
+      </tr>
+    </tbody>
+  </xsl:template>
+
+  <!-- body: the meat of the spec -->
+  <!-- create a TOC and then go to work -->
+  <!-- (don't forget the TOC for the back matter and a pointer to end
+       notes) -->
+  <xsl:template match="body">
+    <div class="toc">
+      <xsl:text>&#10;</xsl:text>
+      <h2>
+        <a name="contents">Table of Contents</a>
+      </h2>
+      <p class="toc">
+        <xsl:apply-templates mode="toc" select="div1"/>
+      </p>
+      <xsl:if test="../back">
+        <xsl:text>&#10;</xsl:text>
+        <h3>
+          <xsl:text>Appendi</xsl:text>
+          <xsl:choose>
+            <xsl:when test="count(../back/div1 | ../back/inform-div1) > 1">
+              <xsl:text>ces</xsl:text>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:text>x</xsl:text>
+            </xsl:otherwise>
+          </xsl:choose>
+        </h3>
+        <p class="toc">
+          <xsl:apply-templates mode="toc"
+            select="../back/div1 | ../back/inform-div1"/>
+        </p>
+      </xsl:if>
+      <xsl:if test="//footnote">
+        <p class="toc">
+          <a href="#endnotes">
+            <xsl:text>End Notes</xsl:text>
+          </a>
+        </p>
+      </xsl:if>
+    </div>
+    <hr/>
+    <div class="body">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- caption: see table -->
+
+  <!-- case: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- code: generic computer code -->
+  <!-- output as HTML <code> for monospaced formatting -->
+  <xsl:template match="code">
+    <code><xsl:apply-templates/></code>
+  </xsl:template>
+
+  <!-- col: see table -->
+
+  <!-- colgroup: see table -->
+
+  <!-- com: formal production comment -->
+  <!-- can appear in prod or rhs -->
+  <xsl:template match="com">
+    <xsl:choose>
+      <xsl:when test="preceding-sibling::*[1][name()='rhs']">
+        <td>
+         <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
+           <xsl:attribute name="class">
+             <xsl:text>diff-</xsl:text>
+             <xsl:value-of select="ancestor-or-self::*/@diff"/>
+           </xsl:attribute>
+         </xsl:if>
+          <i>
+            <xsl:text>/* </xsl:text>
+            <xsl:apply-templates/>
+            <xsl:text> */</xsl:text>
+          </i>
+        </td>
+      </xsl:when>
+      <xsl:otherwise>
+        <tr valign="baseline">
+          <td/><td/><td/><td/>
+          <td>
+           <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
+             <xsl:attribute name="class">
+               <xsl:text>diff-</xsl:text>
+               <xsl:value-of select="ancestor-or-self::*/@diff"/>
+             </xsl:attribute>
+           </xsl:if>
+            <i>
+              <xsl:text>/* </xsl:text>
+              <xsl:apply-templates/>
+              <xsl:text> */</xsl:text>
+            </i>
+          </td>
+        </tr>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <!-- this could probably be handled better, but given that rhs can
+       have arbitrary text and com mixed in, I don't feel like
+       spending enough time to figure out how -->
+  <xsl:template match="rhs/com">
+    <i>
+      <xsl:text>/* </xsl:text>
+      <xsl:apply-templates/>
+      <xsl:text> */</xsl:text>
+    </i>
+  </xsl:template>
+
+  <!-- component: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- constant: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- constraint: a note in a formal production -->
+  <!-- refers to a constraint note -->
+  <xsl:template match="constraint">
+    <xsl:choose>
+      <xsl:when test="preceding-sibling::*[1][name()='rhs']">
+        <td>
+         <xsl:if test="@diff and $show.diff.markup='1'">
+           <xsl:attribute name="class">
+             <xsl:text>diff-</xsl:text>
+             <xsl:value-of select="@diff"/>
+           </xsl:attribute>
+         </xsl:if>
+          <a>
+            <xsl:attribute name="href">
+              <xsl:call-template name="href.target">
+                <xsl:with-param name="target" select="id(@def)"/>
+              </xsl:call-template>
+            </xsl:attribute>
+            <xsl:text>[Constraint: </xsl:text>
+            <xsl:apply-templates select="id(@def)/head" mode="text"/>
+            <xsl:text>]</xsl:text>
+          </a>
+        </td>
+      </xsl:when>
+      <xsl:otherwise>
+        <tr valign="baseline">
+          <td/><td/><td/><td/>
+          <td>
+           <xsl:if test="@diff and $show.diff.markup='1'">
+             <xsl:attribute name="class">
+               <xsl:text>diff-</xsl:text>
+               <xsl:value-of select="@diff"/>
+             </xsl:attribute>
+           </xsl:if>
+            <a>
+              <xsl:attribute name="href">
+                <xsl:call-template name="href.target">
+                  <xsl:with-param name="target" select="id(@def)"/>
+                </xsl:call-template>
+              </xsl:attribute>
+              <xsl:text>[Constraint: </xsl:text>
+              <xsl:apply-templates select="id(@def)/head" mode="text"/>
+              <xsl:text>]</xsl:text>
+            </a>
+          </td>
+        </tr>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <!-- constraintnote: note constraining a formal production -->
+  <!-- see also constraintnote/head -->
+  <xsl:template match="constraintnote">
+    <div class="constraint">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- copyright: notice for this document-->
+  <!-- right now, a boilerplate copyright notice is inserted by the
+       template for header; this may need to be changed -->
+
+  <!-- day: day of month of spec -->
+  <!-- only used in pudate; called directly from header template -->
+
+  <!-- def: glossary definition -->
+  <!-- already in <dl> context from glist -->
+  <xsl:template match="def">
+    <dd>
+      <xsl:apply-templates/>
+    </dd>
+  </xsl:template>
+
+  <!-- definitions: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- descr: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- div[n]: structural divisions -->
+  <!-- make an HTML div -->
+  <!-- see also div[n]/head -->
+  <xsl:template match="div1">
+    <div class="div1">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <xsl:template match="div2">
+    <div class="div2">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <xsl:template match="div3">
+    <div class="div3">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <xsl:template match="div4">
+    <div class="div4">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <xsl:template match="div5">
+    <div class="div5">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- ednote: editors' note -->
+  <xsl:template match="ednote">
+    <xsl:if test="$show.ednotes != 0">
+      <table border="1">
+        <xsl:attribute name="summary">
+          <xsl:text>Editorial note</xsl:text>
+          <xsl:if test="name">
+            <xsl:text>: </xsl:text>
+            <xsl:value-of select="name"/>
+          </xsl:if>
+        </xsl:attribute>
+        <tr>
+          <td align="left" valign="top" width="50%">
+            <b>
+              <xsl:text>Editorial note</xsl:text>
+              <xsl:if test="name">
+                <xsl:text>: </xsl:text>
+                <xsl:apply-templates select="name"/>
+              </xsl:if>
+            </b>
+          </td>
+          <td align="right" valign="top" width="50%">
+            <xsl:choose>
+              <xsl:when test="date">
+                <xsl:apply-templates select="date"/>
+              </xsl:when>
+              <xsl:otherwise>&#160;</xsl:otherwise>
+            </xsl:choose>
+          </td>
+        </tr>
+        <tr>
+          <td colspan="2" align="left" valign="top">
+            <xsl:apply-templates select="edtext"/>
+          </td>
+        </tr>
+      </table>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="date">
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <!-- edtext: text of an editors' note -->
+  <!-- ednote is currently hidden -->
+
+  <!-- eg: a literal example -->
+  <!-- present as preformatted text -->
+  <xsl:template match="eg">
+    <table class="eg" cellpadding="5" border="1"
+           bgcolor="#99ffff" width="100%"
+           summary="Example">
+      <tr>
+        <td>
+         <xsl:if test="@diff and $show.diff.markup='1'">
+           <xsl:attribute name="class">
+             <xsl:text>diff-</xsl:text>
+             <xsl:value-of select="@diff"/>
+           </xsl:attribute>
+         </xsl:if>
+          <pre>
+            <xsl:apply-templates/>
+          </pre>
+        </td>
+      </tr>
+    </table>
+  </xsl:template>
+
+  <!-- el: an XML element -->
+  <!-- present as preformatted text, no markup -->
+  <!-- Chris's personal preference is to put pointy-brackets around
+       this, but he seems to be in the minority -->
+  <xsl:template match="el">
+    <code><xsl:apply-templates/></code>
+  </xsl:template>
+
+  <!-- email: an email address for an editor -->
+  <!-- only occurs in author -->
+  <xsl:template match="email">
+    <xsl:text> </xsl:text>
+    <a href="{@href}">
+      <xsl:text>&lt;</xsl:text>
+      <xsl:apply-templates/>
+      <xsl:text>&gt;</xsl:text>
+    </a>
+  </xsl:template>
+
+  <!-- emph: in-line emphasis -->
+  <!-- equates to HTML <em> -->
+  <!-- the role attribute could be used for multiple kinds of
+       emphasis, but that would not be kind -->
+  <xsl:template match="emph">
+    <em><xsl:apply-templates/></em>
+  </xsl:template>
+
+  <!-- enum: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- enumerator: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- example: what it seems -->
+  <!-- block-level with title -->
+  <!-- see also example/head -->
+  <xsl:template match="example">
+    <div class="example">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- exception: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- footnote: format as endnote, actually -->
+  <xsl:template match="footnote">
+    <xsl:variable name="this-note-id">
+      <xsl:choose>
+        <xsl:when test="@id">
+          <xsl:value-of select="@id"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="generate-id(.)"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <a name="FN-ANCH-{$this-note-id}" href="#{$this-note-id}">
+      <xsl:number level="any" format="[1]"/>
+    </a>
+  </xsl:template>
+
+  <!-- front: front matter for the spec -->
+  <!-- make a div for cleanliness -->
+  <xsl:template match="front">
+    <div class="front">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- function: name of a function -->
+  <!-- format as HTML <code> for monospaced presentation -->
+  <xsl:template match="function">
+    <code><xsl:apply-templates/></code>
+  </xsl:template>
+
+  <!-- gitem: glossary list entry -->
+  <!-- just pass children through for <dd>/<dt> formatting -->
+  <xsl:template match="gitem">
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <!-- glist: glossary list -->
+  <!-- create <dl> and handle children -->
+  <xsl:template match="glist">
+    <xsl:if test="$validity.hacks and local-name(..) = 'p'">
+      <xsl:text disable-output-escaping="yes">&lt;/p&gt;</xsl:text>
+    </xsl:if>
+    <dl>
+      <xsl:apply-templates/>
+    </dl>
+    <xsl:if test="$validity.hacks and local-name(..) = 'p'">
+      <xsl:text disable-output-escaping="yes">&lt;p&gt;</xsl:text>
+    </xsl:if>
+  </xsl:template>
+
+  <!-- graphic: external illustration -->
+  <!-- reference external graphic file with alt text -->
+  <xsl:template match="graphic">
+    <img src="{@source}">
+      <xsl:if test="@alt">
+        <xsl:attribute name="alt">
+          <xsl:value-of select="@alt"/>
+        </xsl:attribute>
+      </xsl:if>
+    </img>
+  </xsl:template>
+
+  <!-- group: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- head: title for a variety of constructs -->
+
+  <!-- constraintnotes have different types, but they're
+       non-enumerated; nothing is done with them right now -->
+  <xsl:template match="constraintnote/head">
+    <p class="prefix">
+      <xsl:if test="../@id">
+       <a name="{../@id}"/>
+      </xsl:if>
+      <b><xsl:text>Constraint: </xsl:text><xsl:apply-templates/></b>
+    </p>
+  </xsl:template>
+
+  <xsl:template match="div1/head">
+    <xsl:text>&#10;</xsl:text>
+    <h2>
+      <a>
+        <xsl:attribute name="name">
+          <xsl:choose>
+            <xsl:when test="../@id">
+              <xsl:value-of select="../@id"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:value-of select="generate-id(..)"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+      </a>
+      <xsl:apply-templates select=".." mode="divnum"/>
+      <xsl:apply-templates/>
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="div2/head">
+    <xsl:text>&#10;</xsl:text>
+    <h3>
+      <a>
+        <xsl:attribute name="name">
+          <xsl:choose>
+            <xsl:when test="../@id">
+              <xsl:value-of select="../@id"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:value-of select="generate-id(..)"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+      </a>
+      <xsl:apply-templates select=".." mode="divnum"/>
+      <xsl:apply-templates/>
+    </h3>
+  </xsl:template>
+
+  <xsl:template match="div3/head">
+    <xsl:text>&#10;</xsl:text>
+    <h4>
+      <a>
+       <xsl:attribute name="name">
+          <xsl:choose>
+            <xsl:when test="../@id">
+              <xsl:value-of select="../@id"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:value-of select="generate-id(..)"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+      </a>
+      <xsl:apply-templates select=".." mode="divnum"/>
+      <xsl:apply-templates/>
+    </h4>
+  </xsl:template>
+
+  <xsl:template match="div4/head">
+    <xsl:text>&#10;</xsl:text>
+    <h5>
+      <a>
+        <xsl:attribute name="name">
+          <xsl:choose>
+            <xsl:when test="../@id">
+              <xsl:value-of select="../@id"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:value-of select="generate-id(..)"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+      </a>
+      <xsl:apply-templates select=".." mode="divnum"/>
+      <xsl:apply-templates/>
+    </h5>
+  </xsl:template>
+
+  <xsl:template match="div5/head">
+    <xsl:text>&#10;</xsl:text>
+    <h6>
+      <a>
+        <xsl:attribute name="name">
+          <xsl:choose>
+            <xsl:when test="../@id">
+              <xsl:value-of select="../@id"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:value-of select="generate-id(..)"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+      </a>
+      <xsl:apply-templates select=".." mode="divnum"/>
+      <xsl:apply-templates/>
+    </h6>
+  </xsl:template>
+
+  <xsl:template match="example/head">
+    <xsl:text>&#10;</xsl:text>
+    <h5>
+      <xsl:text>Example: </xsl:text>
+      <xsl:apply-templates/>
+    </h5>
+  </xsl:template>
+
+  <xsl:template match="inform-div1/head">
+    <xsl:text>&#10;</xsl:text>
+    <h2>
+      <a>
+        <xsl:attribute name="name">
+          <xsl:choose>
+            <xsl:when test="../@id">
+              <xsl:value-of select="../@id"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:value-of select="generate-id(..)"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:attribute>
+      </a>
+      <xsl:apply-templates select=".." mode="divnum"/>
+      <xsl:apply-templates/>
+      <xsl:text> (Non-Normative)</xsl:text>
+    </h2>
+  </xsl:template>
+
+  <xsl:template match="issue/head">
+    <p class="prefix">
+      <b><xsl:apply-templates/></b>
+    </p>
+  </xsl:template>
+
+  <xsl:template match="scrap/head">
+    <xsl:text>&#10;</xsl:text>
+    <h5>
+      <xsl:apply-templates/>
+    </h5>
+  </xsl:template>
+
+  <xsl:template match="vcnote/head">
+    <p class="prefix">
+      <xsl:if test="../@id">
+       <a name="{../@id}"/>
+      </xsl:if>
+      <b><xsl:text>Validity constraint: </xsl:text><xsl:apply-templates/></b>
+    </p>
+  </xsl:template>
+
+  <xsl:template match="wfcnote/head">
+    <p class="prefix">
+      <xsl:if test="../@id">
+       <a name="{../@id}"/>
+      </xsl:if>
+      <b><xsl:text>Well-formedness constraint: </xsl:text><xsl:apply-templates/></b>
+    </p>
+  </xsl:template>
+
+  <!-- header: metadata about the spec -->
+  <!-- pull out information into standard W3C layout -->
+  <xsl:template match="header">
+    <div class="head">
+      <p>
+        <a href="http://www.w3.org/">
+          <img src="http://www.w3.org/Icons/w3c_home"
+            alt="W3C" height="48" width="72"/>
+        </a>
+      </p>
+      <xsl:text>&#10;</xsl:text>
+      <h1>
+        <xsl:apply-templates select="title"/>
+        <xsl:if test="version">
+          <xsl:text> </xsl:text>
+          <xsl:apply-templates select="version"/>
+        </xsl:if>
+      </h1>
+      <xsl:if test="subtitle">
+        <xsl:text>&#10;</xsl:text>
+        <h2>
+          <xsl:apply-templates select="subtitle"/>
+        </h2>
+      </xsl:if>
+      <xsl:text>&#10;</xsl:text>
+      <h2>
+        <xsl:apply-templates select="w3c-doctype"/>
+        <xsl:text> </xsl:text>
+        <xsl:if test="pubdate/day">
+          <xsl:apply-templates select="pubdate/day"/>
+          <xsl:text> </xsl:text>
+        </xsl:if>
+        <xsl:apply-templates select="pubdate/month"/>
+        <xsl:text> </xsl:text>
+        <xsl:apply-templates select="pubdate/year"/>
+      </h2>
+      <dl>
+        <xsl:apply-templates select="publoc"/>
+        <xsl:apply-templates select="latestloc"/>
+        <xsl:apply-templates select="prevlocs"/>
+        <xsl:apply-templates select="authlist"/>
+      </dl>
+      <p class="copyright">
+        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">
+          <xsl:text>Copyright</xsl:text>
+        </a>
+        <xsl:text>&#xa0;&#xa9;&#xa0;</xsl:text>
+        <xsl:apply-templates select="pubdate/year"/>
+        <xsl:text>&#xa0;</xsl:text>
+        <a href="http://www.w3.org/">
+          <abbr title="World Wide Web Consortium">W3C</abbr>
+        </a>
+        <sup>&#xae;</sup>
+        <xsl:text> (</xsl:text>
+        <a href="http://www.lcs.mit.edu/">
+          <abbr title="Massachusetts Institute of Technology">MIT</abbr>
+        </a>
+        <xsl:text>, </xsl:text>
+        <a href="http://www.inria.fr/">
+        <abbr lang="fr"
+          title="Institut National de Recherche en Informatique et Automatique">INRIA</abbr>
+        </a>
+        <xsl:text>, </xsl:text>
+        <a href="http://www.keio.ac.jp/">Keio</a>
+        <xsl:text>), All Rights Reserved. W3C </xsl:text>
+        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>
+        <xsl:text>, </xsl:text>
+        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
+        <xsl:text>, </xsl:text>
+        <a href="http://www.w3.org/Consortium/Legal/copyright-documents-19990405">document use</a>
+        <xsl:text>, and </xsl:text>
+        <a href="http://www.w3.org/Consortium/Legal/copyright-software-19980720">software licensing</a>
+        <xsl:text> rules apply.</xsl:text>
+      </p>
+    </div>
+    <hr/>
+    <xsl:apply-templates select="notice"/>
+    <xsl:apply-templates select="abstract"/>
+    <xsl:apply-templates select="status"/>
+  </xsl:template>
+
+  <!-- inform-div1: non-normative back matter top-level division -->
+  <!-- treat like div1 except add "(Non-Normative)" to title -->
+  <xsl:template match="inform-div1">
+    <div class="div1">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- interface: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- issue: open issue before the Working Group -->
+  <!-- maintain an ID for linking to it -->
+  <!-- currently generates boilerplate head plus optional head child
+       element; this should probably be cleaned up to only use the
+       head if it's present -->
+  <xsl:template match="issue">
+    <div class="issue">
+      <p class="prefix">
+       <xsl:if test="@id">
+         <a name="{@id}"/>
+       </xsl:if>
+       <b><xsl:text>Issue (</xsl:text><xsl:value-of select="@id"/><xsl:text>):</xsl:text></b>
+      </p>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- item: generic list item -->
+  <xsl:template match="item">
+    <li>
+      <xsl:apply-templates/>
+    </li>
+  </xsl:template>
+
+  <!-- kw: keyword -->
+  <!-- make it bold -->
+  <xsl:template match="kw">
+    <b><xsl:apply-templates/></b>
+  </xsl:template>
+
+  <!-- label: term for defintion in glossary entry -->
+  <!-- already in <dl> context from glist -->
+  <xsl:template match="label">
+    <dt class="label">
+      <xsl:if test="@id"><a name="{@id}"/></xsl:if>
+      <xsl:apply-templates/>
+    </dt>
+  </xsl:template>
+
+  <!-- language: -->
+  <!-- langusage: -->
+  <!-- identify language usage within a spec; not actually formatted -->
+
+  <!-- latestloc: latest location for this spec -->
+  <!-- called in a <dl> context from header -->
+  <xsl:template match="latestloc">
+    <dt>Latest version:</dt>
+    <dd>
+      <xsl:apply-templates/>
+    </dd>
+  </xsl:template>
+
+  <!-- lhs: left-hand side of formal productions -->
+  <!-- make a table row with the lhs and the corresponding other
+       pieces in this crazy mixed-up content model -->
+  <xsl:template match="lhs">
+    <tr valign="baseline">
+      <td>
+       <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
+         <xsl:attribute name="class">
+           <xsl:text>diff-</xsl:text>
+           <xsl:value-of select="ancestor-or-self::*/@diff"/>
+         </xsl:attribute>
+       </xsl:if>
+       <xsl:if test="../@id">
+         <a name="{../@id}"/>
+       </xsl:if>
+       <xsl:apply-templates select="ancestor::prod" mode="number"/>
+<!--
+  This could be done right here, but XT goes into deep space when the
+  node to be numbered isn't the current node and level="any":
+          <xsl:number count="prod" level="any" from="spec"
+            format="[1]"/>
+  -->
+       <xsl:text>&#xa0;&#xa0;&#xa0;</xsl:text>
+      </td>
+      <td>
+       <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
+         <xsl:attribute name="class">
+           <xsl:text>diff-</xsl:text>
+           <xsl:value-of select="ancestor-or-self::*/@diff"/>
+         </xsl:attribute>
+       </xsl:if>
+        <code><xsl:apply-templates/></code>
+      </td>
+      <td>
+       <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
+         <xsl:attribute name="class">
+           <xsl:text>diff-</xsl:text>
+           <xsl:value-of select="ancestor-or-self::*/@diff"/>
+         </xsl:attribute>
+       </xsl:if>
+        <xsl:text>&#xa0;&#xa0;&#xa0;::=&#xa0;&#xa0;&#xa0;</xsl:text>
+      </td>
+      <xsl:apply-templates
+        select="following-sibling::*[1][name()='rhs']"/>
+    </tr>
+  </xsl:template>
+
+  <!-- loc: a Web location -->
+  <!-- outside the header, it's a normal cross-reference -->
+  <xsl:template match="loc">
+    <a href="{@href}">
+      <xsl:apply-templates/>
+    </a>
+  </xsl:template>
+
+  <!-- member: member of an organization -->
+  <!-- appears only in orglist, which creates <ul> context -->
+  <xsl:template match="member">
+    <li>
+      <xsl:apply-templates/>
+    </li>
+  </xsl:template>
+
+  <!-- method: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- module: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- month: month of spec -->
+  <!-- only used in pudate; called directly from header template -->
+
+  <!-- name: name of an editor or organization member -->
+  <!-- only appears in author and member -->
+  <!-- just output text -->
+  <xsl:template match="name">
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <!-- note: a note about the spec -->
+  <xsl:template match="note">
+    <div class="note">
+      <p class="prefix">
+        <b>Note:</b>
+      </p>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- notice: a front-matter advisory about the spec's status -->
+  <!-- make sure people notice it -->
+  <xsl:template match="notice">
+    <div class="notice">
+      <p class="prefix">
+        <b>NOTICE:</b>
+      </p>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- nt: production non-terminal -->
+  <!-- make a link to the non-terminal's definition -->
+  <xsl:template match="nt">
+    <a>
+      <xsl:attribute name="href">
+        <xsl:call-template name="href.target">
+          <xsl:with-param name="target" select="id(@def)"/>
+        </xsl:call-template>
+      </xsl:attribute>
+      <xsl:apply-templates/>
+    </a>
+  </xsl:template>
+
+  <!-- olist: an ordered list -->
+  <xsl:template match="olist">
+    <ol>
+      <xsl:apply-templates/>
+    </ol>
+  </xsl:template>
+
+  <!-- orglist: a list of an organization's members -->
+  <xsl:template match="orglist">
+    <ul>
+      <xsl:apply-templates/>
+    </ul>
+  </xsl:template>
+
+  <!-- p: a standard paragraph -->
+  <xsl:template match="p">
+    <p>
+      <xsl:if test="@id">
+        <xsl:attribute name="id">
+          <xsl:value-of select="@id"/>
+        </xsl:attribute>
+      </xsl:if>
+      <xsl:if test="@role">
+        <xsl:attribute name="class">
+          <xsl:value-of select="@role"/>
+        </xsl:attribute>
+      </xsl:if>
+      <xsl:apply-templates/>
+    </p>
+  </xsl:template>
+
+  <!-- param: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- parameters: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- phrase: semantically meaningless markup hanger -->
+  <!-- role attributes may be used to request different formatting,
+       which isn't currently handled -->
+  <xsl:template match="phrase">
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <!-- prevlocs: previous locations for this spec -->
+  <!-- called in a <dl> context from header -->
+  <xsl:template match="prevlocs">
+    <dt>Previous versions:</dt>
+    <dd>
+      <xsl:apply-templates/>
+    </dd>
+  </xsl:template>
+
+  <!-- prod: a formal grammar production -->
+  <!-- if not in a prodgroup, needs a <tbody> -->
+  <!-- has a weird content model; makes a table but there are no
+       explicit rules; many different things can start a new row -->
+  <!-- process the first child in each row, and it will process the
+       others -->
+  <xsl:template match="prod">
+    <tbody>
+      <xsl:apply-templates
+        select="lhs |
+                rhs[preceding-sibling::*[1][name()!='lhs']] |
+                com[preceding-sibling::*[1][name()!='rhs']] |
+                constraint[preceding-sibling::*[1][name()!='rhs']] |
+                vc[preceding-sibling::*[1][name()!='rhs']] |
+                wfc[preceding-sibling::*[1][name()!='rhs']]"/>
+    </tbody>
+  </xsl:template>
+
+  <xsl:template match="prodgroup/prod">
+    <xsl:apply-templates
+      select="lhs |
+              rhs[preceding-sibling::*[1][name()!='lhs']] |
+              com[preceding-sibling::*[1][name()!='rhs']] |
+              constraint[preceding-sibling::*[1][name()!='rhs']] |
+              vc[preceding-sibling::*[1][name()!='rhs']] |
+              wfc[preceding-sibling::*[1][name()!='rhs']]"/>
+  </xsl:template>
+
+  <!-- prodgroup: group of formal productions -->
+  <!-- create one <tbody> for each group -->
+  <xsl:template match="prodgroup">
+    <tbody>
+      <xsl:apply-templates/>
+    </tbody>
+  </xsl:template>
+
+  <!-- prodrecap: reiteration of a prod -->
+  <!-- process the prod in another node that will never generate a
+       <tbody> or a number, plus links the lhs to the original
+       production -->
+  <xsl:template match="prodrecap">
+    <tbody>
+      <xsl:apply-templates select="id(@ref)" mode="ref"/>
+    </tbody>
+  </xsl:template>
+
+  <!-- proto: function prototype -->
+  <!-- type and name of the function, with arguments in parens -->
+  <xsl:template match="proto">
+    <p>
+      <em><xsl:value-of select="@return-type"/></em>
+      <xsl:text> </xsl:text>
+      <b><xsl:value-of select="@name"/></b>
+      <xsl:text>(</xsl:text>
+      <xsl:apply-templates/>
+      <xsl:text>)</xsl:text>
+    </p>
+  </xsl:template>
+
+  <!-- pubdate: date of spec -->
+  <!-- called directly from header -->
+
+  <!-- publoc: location of current version of spec -->
+  <!-- called from header in <dl> context -->
+  <xsl:template match="publoc">
+    <dt>This version:</dt>
+    <dd>
+      <xsl:apply-templates/>
+    </dd>
+  </xsl:template>
+
+  <!-- pubstmt: statement of publication -->
+  <!-- not currently output -->
+
+  <!-- quote: a quoted string or phrase -->
+  <!-- it would be nice to use HTML <q> elements, but browser support
+       is abysmal -->
+  <xsl:template match="quote">
+    <xsl:text>"</xsl:text>
+    <xsl:apply-templates/>
+    <xsl:text>"</xsl:text>
+  </xsl:template>
+
+  <!-- raises: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- reference: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- resolution: resolution of an issue -->
+  <xsl:template match="resolution">
+    <p class="prefix">
+      <b>Resolution:</b>
+    </p>
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <!-- returns: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- revisiondesc: description of spec revision -->
+  <!-- used for internal tracking; not formatted -->
+
+  <!-- rhs: right-hand side of a formal production -->
+  <!-- make a table cell; if it's not the first after an LHS, make a
+       new row, too -->
+  <xsl:template match="rhs">
+    <xsl:choose>
+      <xsl:when test="preceding-sibling::*[1][name()='lhs']">
+        <td>
+         <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
+           <xsl:attribute name="class">
+             <xsl:text>diff-</xsl:text>
+             <xsl:value-of select="ancestor-or-self::*/@diff"/>
+           </xsl:attribute>
+         </xsl:if>
+          <code><xsl:apply-templates/></code>
+        </td>
+        <xsl:apply-templates
+          select="following-sibling::*[1][name()='com' or
+                                          name()='constraint' or
+                                          name()='vc' or
+                                          name()='wfc']"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <tr valign="baseline">
+          <td/><td/><td/>
+          <td>
+           <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
+             <xsl:attribute name="class">
+               <xsl:text>diff-</xsl:text>
+               <xsl:value-of select="ancestor-or-self::*/@diff"/>
+             </xsl:attribute>
+           </xsl:if>
+            <code><xsl:apply-templates/></code>
+          </td>
+          <xsl:apply-templates
+            select="following-sibling::*[1][name()='com' or
+                                            name()='constraint' or
+                                            name()='vc' or
+                                            name()='wfc']"/>
+        </tr>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <!-- role: part played by a member of an organization -->
+  <xsl:template match="role">
+    <xsl:text> (</xsl:text>
+    <i><xsl:apply-templates/></i>
+    <xsl:text>) </xsl:text>
+  </xsl:template>
+
+  <!-- scrap: series of formal grammar productions -->
+  <!-- set up a <table> and handle children -->
+  <xsl:template match="scrap">
+    <xsl:apply-templates select="head"/>
+    <table class="scrap" summary="Scrap">
+      <xsl:apply-templates select="bnf | prod | prodgroup"/>
+    </table>
+  </xsl:template>
+
+  <!-- sequence: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- sitem: simple list item -->
+  <!-- just make one paragraph with <br>s between items -->
+  <xsl:template match="sitem[position() &gt; 1]">
+    <br/>
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <!-- slist: simple list -->
+  <!-- using a <blockquote> to indent the list is very wrong, but it
+       works -->
+  <xsl:template match="slist">
+    <blockquote>
+      <p>
+        <xsl:apply-templates/>
+      </p>
+    </blockquote>
+  </xsl:template>
+
+  <!-- source: the source of an issue -->
+  <xsl:template match="source">
+    <p>
+      <b>Source</b>
+      <xsl:text>: </xsl:text>
+      <xsl:apply-templates/>
+    </p>
+  </xsl:template>
+
+  <!-- sourcedesc: description of spec preparation -->
+  <!-- used for tracking the source, but not formatted -->
+
+  <!-- spec: the specification itself -->
+  <xsl:template match="spec">
+    <html>
+      <xsl:if test="header/langusage/language">
+        <xsl:attribute name="lang">
+          <xsl:value-of select="header/langusage/language/@id"/>
+        </xsl:attribute>
+      </xsl:if>
+      <head>
+       <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+        <title>
+          <xsl:apply-templates select="header/title"/>
+          <xsl:if test="header/version">
+            <xsl:text> </xsl:text>
+            <xsl:apply-templates select="header/version"/>
+          </xsl:if>
+          <xsl:if test="$additional.title != ''">
+            <xsl:text> -- </xsl:text>
+            <xsl:value-of select="$additional.title"/>
+         </xsl:if>
+        </title>
+        <xsl:call-template name="css"/>
+      </head>
+      <body>
+        <xsl:apply-templates/>
+        <xsl:if test="//footnote">
+          <hr/>
+          <div class="endnotes">
+            <xsl:text>&#10;</xsl:text>
+            <h3>
+              <a name="endnotes">
+                <xsl:text>End Notes</xsl:text>
+              </a>
+            </h3>
+            <dl>
+              <xsl:apply-templates select="//footnote" mode="notes"/>
+            </dl>
+          </div>
+        </xsl:if>
+      </body>
+    </html>
+  </xsl:template>
+
+  <!-- specref: reference to another part of teh current specification -->
+  <xsl:template match="specref">
+    <xsl:variable name="target" select="id(@ref)[1]"/>
+    <a>
+      <xsl:attribute name="href">
+        <xsl:call-template name="href.target">
+          <xsl:with-param name="target" select="id(@ref)"/>
+        </xsl:call-template>
+      </xsl:attribute>
+      <xsl:choose>
+       <xsl:when test="starts-with(local-name($target), 'div')">
+         <b><xsl:apply-templates select="id(@ref)" mode="divnum"/><xsl:apply-templates select="id(@ref)/head" mode="text"/></b>
+       </xsl:when>
+       <xsl:when test="starts-with(local-name($target), 'inform-div')">
+         <b><xsl:apply-templates select="id(@ref)" mode="divnum"/><xsl:apply-templates select="id(@ref)/head" mode="text"/></b>
+       </xsl:when>
+       <xsl:when test="local-name($target) = 'vcnote'">
+         <b><xsl:text>[VC: </xsl:text><xsl:apply-templates select="id(@ref)/head" mode="text"/><xsl:text>]</xsl:text></b>
+       </xsl:when>
+       <xsl:when test="local-name($target) = 'prod'">
+         <b>
+            <xsl:text>[PROD: </xsl:text>
+            <xsl:apply-templates select="$target" mode="number-simple"/>
+            <xsl:text>]</xsl:text>
+          </b>
+       </xsl:when>
+       <xsl:when test="local-name($target) = 'label'">
+         <b>
+            <xsl:text>[</xsl:text>
+            <xsl:value-of select="$target"/>
+            <xsl:text>]</xsl:text>
+          </b>
+       </xsl:when>
+       <xsl:otherwise>
+         <xsl:message>
+           <xsl:text>Unsupported specref to </xsl:text>
+           <xsl:value-of select="local-name($target)"/>
+           <xsl:text> [</xsl:text>
+           <xsl:value-of select="@ref"/>
+           <xsl:text>] </xsl:text>
+           <xsl:text> (Contact stylesheet maintainer).</xsl:text>
+         </xsl:message>
+         <b>???</b>
+       </xsl:otherwise>
+      </xsl:choose>
+    </a>
+  </xsl:template>
+
+  <!-- status: the status of the spec -->
+  <xsl:template match="status">
+    <div id="status">
+      <xsl:text>&#10;</xsl:text>
+      <h2>
+        <a name="status">Status of this Document</a>
+      </h2>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- struct: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- sub: subscript -->
+  <xsl:template match="sub">
+    <sub>
+      <xsl:apply-templates/>
+    </sub>
+  </xsl:template>
+
+  <!-- subtitle: secondary title of spec -->
+  <!-- handled directly within header -->
+
+  <!-- sup: superscript -->
+  <xsl:template match="sup">
+    <sup>
+      <xsl:apply-templates/>
+    </sup>
+  </xsl:template>
+
+  <!-- table: the HTML table model adopted wholesale -->
+  <!-- tbody: -->
+  <!-- td: -->
+  <xsl:template
+    match="caption | col | colgroup | table | tbody | td | tfoot | th | thead | tr">
+    <xsl:copy>
+      <xsl:for-each select="@*">
+       <!-- Wait: some of these aren't HTML attributes after all... -->
+       <xsl:if test="local-name(.) != 'diff'">
+         <xsl:copy>
+           <xsl:apply-templates/>
+         </xsl:copy>
+       </xsl:if>
+      </xsl:for-each>
+      <xsl:apply-templates/>
+    </xsl:copy>
+  </xsl:template>
+
+  <!-- term: the actual mention of a term within a termdef -->
+  <xsl:template match="term">
+    <b><xsl:apply-templates/></b>
+  </xsl:template>
+
+  <!-- termdef: sentence or phrase defining a term -->
+  <xsl:template match="termdef">
+    <xsl:text>[</xsl:text>
+    <a name="{@id}" title="{@term}">
+      <xsl:text>Definition</xsl:text>
+    </a>
+    <xsl:text>: </xsl:text>
+    <xsl:apply-templates/>
+    <xsl:text>]</xsl:text>
+  </xsl:template>
+
+  <!-- termref: reference to a defined term -->
+  <xsl:template match="termref">
+    <a title="{id(@def)/@term}">
+      <xsl:attribute name="href">
+        <xsl:call-template name="href.target">
+          <xsl:with-param name="target" select="id(@def)"/>
+        </xsl:call-template>
+      </xsl:attribute>
+      <xsl:apply-templates/>
+    </a>
+  </xsl:template>
+
+  <!-- tfoot: see table -->
+  <!-- th: see table -->
+  <!-- thead: see table -->
+
+  <!-- title: title of the specification -->
+  <!-- called directly within header -->
+
+  <!-- titleref: reference to the title of any work -->
+  <!-- if a URL is given, link it -->
+  <xsl:template match="titleref">
+    <xsl:choose>
+      <xsl:when test="@href">
+        <a href="{@href}">
+          <cite>
+            <xsl:apply-templates/>
+          </cite>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <cite>
+          <xsl:apply-templates/>
+        </cite>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <!-- tr: see table -->
+
+  <!-- typedef: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- typename: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- ulist: unordered list -->
+  <xsl:template match="ulist">
+    <ul>
+      <xsl:apply-templates/>
+    </ul>
+  </xsl:template>
+
+  <!-- union: -->
+  <!-- IDL stuff isn't handled yet -->
+
+  <!-- var: a variable -->
+  <xsl:template match="var">
+    <var>
+      <xsl:apply-templates/>
+    </var>
+  </xsl:template>
+
+  <!-- vc: validity check reference in a formal production -->
+  <xsl:template match="vc">
+    <xsl:choose>
+      <xsl:when test="preceding-sibling::*[1][name()='rhs']">
+        <td>
+         <xsl:if test="@diff and $show.diff.markup='1'">
+           <xsl:attribute name="class">
+             <xsl:text>diff-</xsl:text>
+             <xsl:value-of select="@diff"/>
+           </xsl:attribute>
+         </xsl:if>
+          <a>
+            <xsl:attribute name="href">
+              <xsl:call-template name="href.target">
+                <xsl:with-param name="target" select="id(@def)"/>
+              </xsl:call-template>
+            </xsl:attribute>
+            <xsl:text>[VC: </xsl:text>
+            <xsl:apply-templates select="id(@def)/head" mode="text"/>
+            <xsl:text>]</xsl:text>
+          </a>
+        </td>
+      </xsl:when>
+      <xsl:otherwise>
+        <tr valign="baseline">
+          <td/><td/><td/><td/>
+          <td>
+           <xsl:if test="@diff and $show.diff.markup='1'">
+             <xsl:attribute name="class">
+               <xsl:text>diff-</xsl:text>
+               <xsl:value-of select="@diff"/>
+             </xsl:attribute>
+           </xsl:if>
+            <a>
+              <xsl:attribute name="href">
+                <xsl:call-template name="href.target">
+                  <xsl:with-param name="target" select="id(@def)"/>
+                </xsl:call-template>
+              </xsl:attribute>
+              <xsl:text>[VC: </xsl:text>
+              <xsl:apply-templates select="id(@def)/head" mode="text"/>
+              <xsl:text>]</xsl:text>
+            </a>
+          </td>
+        </tr>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <!-- vcnote: validity check note after a formal production -->
+  <xsl:template match="vcnote">
+    <div class="constraint">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- version: version of this spec -->
+  <!-- called directly from header -->
+
+  <!-- w3c-designation: canonical name for this spec -->
+  <!-- not used for formatting -->
+
+  <!-- w3c-doctype: type of document the specification is -->
+  <!-- used by header template to select CSS stylesheet for output
+       HTML -->
+
+  <!-- wfc: well-formedness check reference in a formal production -->
+  <xsl:template match="wfc">
+    <xsl:choose>
+      <xsl:when test="preceding-sibling::*[1][name()='rhs']">
+        <td>
+         <xsl:if test="@diff and $show.diff.markup='1'">
+           <xsl:attribute name="class">
+             <xsl:text>diff-</xsl:text>
+             <xsl:value-of select="@diff"/>
+           </xsl:attribute>
+         </xsl:if>
+          <a>
+            <xsl:attribute name="href">
+              <xsl:call-template name="href.target">
+                <xsl:with-param name="target" select="id(@def)"/>
+              </xsl:call-template>
+            </xsl:attribute>
+            <xsl:text>[WFC: </xsl:text>
+            <xsl:apply-templates select="id(@def)/head" mode="text"/>
+            <xsl:text>]</xsl:text>
+          </a>
+        </td>
+      </xsl:when>
+      <xsl:otherwise>
+        <tr valign="baseline">
+          <td/><td/><td/><td/>
+          <td>
+           <xsl:if test="@diff and $show.diff.markup='1'">
+             <xsl:attribute name="class">
+               <xsl:text>diff-</xsl:text>
+               <xsl:value-of select="@diff"/>
+             </xsl:attribute>
+           </xsl:if>
+            <a>
+              <xsl:attribute name="href">
+                <xsl:call-template name="href.target">
+                  <xsl:with-param name="target" select="id(@def)"/>
+                </xsl:call-template>
+              </xsl:attribute>
+              <xsl:text>[WFC: </xsl:text>
+              <xsl:apply-templates select="id(@def)/head" mode="text"/>
+              <xsl:text>]</xsl:text>
+            </a>
+          </td>
+        </tr>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <!-- wfcnote: well-formedness check note after formal production -->
+  <xsl:template match="wfcnote">
+    <div class="constraint">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+
+  <!-- xnt: external non-terminal -->
+  <!-- xspecref: external specification reference -->
+  <!-- xtermref: external term reference -->
+  <!-- just link to URI provided -->
+  <xsl:template match="xnt | xspecref | xtermref">
+    <a href="{@href}">
+      <xsl:apply-templates/>
+    </a>
+  </xsl:template>
+
+  <!-- year: year of spec -->
+  <!-- only used in pudate; called directly from header template -->
+
+  <!-- Silly HTML elements used for pasting stuff in; shouldn't ever
+       show up in a spec, but they're easy to handle and you just
+       never know. -->
+  <xsl:template match="a|div|em|h1|h2|h3|h4|h5|h6|li|ol|pre|ul">
+    <xsl:copy>
+      <xsl:for-each select="@*">
+        <xsl:copy>
+          <xsl:apply-templates/>
+        </xsl:copy>
+      </xsl:for-each>
+      <xsl:apply-templates/>
+    </xsl:copy>
+  </xsl:template>
+
+  <!-- legacy XML spec stuff -->
+  <xsl:template match="htable">
+    <table summary="HTML Table">
+      <xsl:for-each select="@*">
+        <xsl:copy>
+          <xsl:apply-templates/>
+        </xsl:copy>
+      </xsl:for-each>
+      <xsl:apply-templates/>
+    </table>
+  </xsl:template>
+  <xsl:template match="htbody">
+    <tbody>
+      <xsl:for-each select="@*">
+        <xsl:copy>
+          <xsl:apply-templates/>
+        </xsl:copy>
+      </xsl:for-each>
+      <xsl:apply-templates/>
+    </tbody>
+  </xsl:template>
+  <xsl:template match="key-term">
+    <b><xsl:apply-templates/></b>
+  </xsl:template>
+  <xsl:template match="statusp">
+    <p>
+      <xsl:apply-templates/>
+    </p>
+  </xsl:template>
+
+  <!-- legacy DocBook stuff -->
+  <xsl:template match="itemizedlist">
+    <ul>
+      <xsl:apply-templates/>
+    </ul>
+  </xsl:template>
+  <xsl:template match="listitem">
+    <li>
+      <xsl:apply-templates/>
+    </li>
+  </xsl:template>
+  <xsl:template match="orderedlist">
+    <ol>
+      <xsl:apply-templates/>
+    </ol>
+  </xsl:template>
+  <xsl:template match="para">
+    <p>
+      <xsl:apply-templates/>
+    </p>
+  </xsl:template>
+
+  <!-- mode: divnum -->
+  <xsl:template mode="divnum" match="div1">
+    <xsl:number format="1 "/>
+  </xsl:template>
+
+  <xsl:template mode="divnum" match="back/div1 | inform-div1">
+    <xsl:number count="div1 | inform-div1" format="A "/>
+  </xsl:template>
+
+  <xsl:template mode="divnum"
+    match="front/div1 | front//div2 | front//div3 | front//div4 | front//div5"/>
+
+  <xsl:template mode="divnum" match="div2">
+    <xsl:number level="multiple" count="div1 | div2" format="1.1 "/>
+  </xsl:template>
+
+  <xsl:template mode="divnum" match="back//div2">
+    <xsl:number level="multiple" count="div1 | div2 | inform-div1"
+      format="A.1 "/>
+  </xsl:template>
+
+  <xsl:template mode="divnum" match="div3">
+    <xsl:number level="multiple" count="div1 | div2 | div3"
+      format="1.1.1 "/>
+  </xsl:template>
+
+  <xsl:template mode="divnum" match="back//div3">
+    <xsl:number level="multiple"
+      count="div1 | div2 | div3 | inform-div1" format="A.1.1 "/>
+  </xsl:template>
+
+  <xsl:template mode="divnum" match="div4">
+    <xsl:number level="multiple" count="div1 | div2 | div3 | div4"
+      format="1.1.1.1 "/>
+  </xsl:template>
+
+  <xsl:template mode="divnum" match="back//div4">
+    <xsl:number level="multiple"
+      count="div1 | div2 | div3 | div4 | inform-div1"
+      format="A.1.1.1 "/>
+  </xsl:template>
+
+  <xsl:template mode="divnum" match="div5">
+    <xsl:number level="multiple"
+      count="div1 | div2 | div3 | div4 | div5" format="1.1.1.1.1 "/>
+  </xsl:template>
+
+  <xsl:template mode="divnum" match="back//div5">
+    <xsl:number level="multiple"
+      count="div1 | div2 | div3 | div4 | div5 | inform-div1"
+      format="A.1.1.1.1 "/>
+  </xsl:template>
+
+  <!-- mode: notes -->
+  <xsl:template mode="notes" match="footnote">
+    <xsl:variable name="this-note-id">
+      <xsl:choose>
+        <xsl:when test="@id">
+          <xsl:value-of select="@id"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="generate-id(.)"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <dt>
+      <a name="{$this-note-id}" href="#FN-ANCH-{$this-note-id}">
+        <xsl:number level="any" format="[1]"/>
+      </a>
+    </dt>
+    <dd>
+      <xsl:apply-templates/>
+    </dd>
+  </xsl:template>
+
+  <!-- mode: number -->
+  <xsl:template mode="number" match="prod">
+    <xsl:text>[</xsl:text>
+    <xsl:apply-templates select="." mode="number-simple"/>
+    <xsl:text>]</xsl:text>
+  </xsl:template>
+
+  <xsl:template mode="number" match="prod[@diff='add']">
+    <xsl:text>[</xsl:text>
+    <xsl:apply-templates select="preceding::prod[not(@diff='add')][1]"
+      mode="number-simple"/>
+<!--
+  Once again, this could be done right here, but XT won't hear of it.
+    <xsl:number level="any" count="prod[not(@diff='add')]"/>
+  -->
+    <xsl:number level="any" count="prod[@diff='add']"
+      from="prod[not(@diff='add')]" format="a"/>
+    <xsl:text>]</xsl:text>
+  </xsl:template>
+
+  <!-- mode: number-simple -->
+  <xsl:template mode="number-simple" match="prod">
+    <xsl:number level="any" count="prod[not(@diff='add')]"/>
+  </xsl:template>
+
+  <!-- mode: ref -->
+  <xsl:template match="lhs" mode="ref">
+    <tr valign="baseline">
+      <td/>
+      <td>
+       <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
+         <xsl:attribute name="class">
+           <xsl:text>diff-</xsl:text>
+           <xsl:value-of select="ancestor-or-self::*/@diff"/>
+         </xsl:attribute>
+       </xsl:if>
+       <xsl:if test="../@id">
+         <a name="{../@id}"/>
+       </xsl:if>
+       <code><xsl:apply-templates/></code>
+      </td>
+      <td>
+       <xsl:if test="ancestor-or-self::*/@diff and $show.diff.markup='1'">
+         <xsl:attribute name="class">
+           <xsl:text>diff-</xsl:text>
+           <xsl:value-of select="ancestor-or-self::*/@diff"/>
+         </xsl:attribute>
+       </xsl:if>
+        <xsl:text>&#xa0;&#xa0;&#xa0;::=&#xa0;&#xa0;&#xa0;</xsl:text>
+      </td>
+      <xsl:apply-templates
+        select="following-sibling::*[1][name()='rhs']"/>
+    </tr>
+  </xsl:template>
+
+  <xsl:template mode="ref" match="prod">
+    <xsl:apply-templates select="lhs" mode="ref"/>
+    <xsl:apply-templates
+      select="rhs[preceding-sibling::*[1][name()!='lhs']] |
+              com[preceding-sibling::*[1][name()!='rhs']] |
+              constraint[preceding-sibling::*[1][name()!='rhs']] |
+              vc[preceding-sibling::*[1][name()!='rhs']] |
+              wfc[preceding-sibling::*[1][name()!='rhs']]"/>
+  </xsl:template>
+
+  <!-- mode: text -->
+  <!-- most stuff processes just as text here, but some things should
+       be hidden -->
+  <xsl:template mode="text" match="ednote | footnote"/>
+
+  <!-- mode: toc -->
+  <xsl:template mode="toc" match="div1">
+    <xsl:apply-templates select="." mode="divnum"/>
+    <a>
+      <xsl:attribute name="href">
+        <xsl:call-template name="href.target">
+          <xsl:with-param name="target" select="."/>
+        </xsl:call-template>
+      </xsl:attribute>
+      <xsl:apply-templates select="head" mode="text"/>
+    </a>
+    <br/>
+    <xsl:apply-templates select="div2" mode="toc"/>
+  </xsl:template>
+
+  <xsl:template mode="toc" match="div2">
+    <xsl:text>&#xa0;&#xa0;&#xa0;&#xa0;</xsl:text>
+    <xsl:apply-templates select="." mode="divnum"/>
+    <a>
+      <xsl:attribute name="href">
+        <xsl:call-template name="href.target">
+          <xsl:with-param name="target" select="."/>
+        </xsl:call-template>
+      </xsl:attribute>
+      <xsl:apply-templates select="head" mode="text"/>
+    </a>
+    <br/>
+    <xsl:apply-templates select="div3" mode="toc"/>
+  </xsl:template>
+
+  <xsl:template mode="toc" match="div3">
+    <xsl:text>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</xsl:text>
+    <xsl:apply-templates select="." mode="divnum"/>
+    <a>
+      <xsl:attribute name="href">
+        <xsl:call-template name="href.target">
+          <xsl:with-param name="target" select="."/>
+        </xsl:call-template>
+      </xsl:attribute>
+      <xsl:apply-templates select="head" mode="text"/>
+    </a>
+    <br/>
+    <xsl:apply-templates select="div4" mode="toc"/>
+  </xsl:template>
+
+  <xsl:template mode="toc" match="div4">
+    <xsl:text>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</xsl:text>
+    <xsl:apply-templates select="." mode="divnum"/>
+    <a>
+      <xsl:attribute name="href">
+        <xsl:call-template name="href.target">
+          <xsl:with-param name="target" select="."/>
+        </xsl:call-template>
+      </xsl:attribute>
+      <xsl:apply-templates select="head" mode="text"/>
+    </a>
+    <br/>
+    <xsl:apply-templates select="div5" mode="toc"/>
+  </xsl:template>
+
+  <xsl:template mode="toc" match="div5">
+    <xsl:text>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</xsl:text>
+    <xsl:apply-templates select="." mode="divnum"/>
+    <a>
+      <xsl:attribute name="href">
+        <xsl:call-template name="href.target">
+          <xsl:with-param name="target" select="."/>
+        </xsl:call-template>
+      </xsl:attribute>
+      <xsl:apply-templates select="head" mode="text"/>
+    </a>
+    <br/>
+  </xsl:template>
+
+  <xsl:template mode="toc" match="inform-div1">
+    <xsl:apply-templates select="." mode="divnum"/>
+    <a>
+      <xsl:attribute name="href">
+        <xsl:call-template name="href.target">
+          <xsl:with-param name="target" select="."/>
+        </xsl:call-template>
+      </xsl:attribute>
+      <xsl:apply-templates select="head" mode="text"/>
+    </a>
+    <xsl:text> (Non-Normative)</xsl:text>
+    <br/>
+    <xsl:apply-templates select="div2" mode="toc"/>
+  </xsl:template>
+
+  <xsl:template name="css">
+    <style type="text/css">
+      <xsl:text>
+code           { font-family: monospace; }
+
+div.constraint,
+div.issue,
+div.note,
+div.notice     { margin-left: 2em; }
+
+dt.label       { display: run-in; }
+
+li p           { margin-top: 0.3em;
+                 margin-bottom: 0.3em; }
+      </xsl:text>
+      <xsl:value-of select="$additional.css"/>
+    </style>
+    <link rel="stylesheet" type="text/css">
+      <xsl:attribute name="href">
+        <xsl:text>W3C-</xsl:text>
+        <xsl:choose>
+          <xsl:when test="/spec/@w3c-doctype='wd'">WD</xsl:when>
+          <xsl:when test="/spec/@w3c-doctype='rec'">REC</xsl:when>
+          <xsl:when test="/spec/@w3c-doctype='pr'">REC</xsl:when>
+          <xsl:when test="/spec/@w3c-doctype='cr'">REC</xsl:when>
+          <xsl:otherwise>NOTE</xsl:otherwise>
+        </xsl:choose>
+        <xsl:text>.css</xsl:text>
+      </xsl:attribute>
+    </link>
+  </xsl:template>
+
+  <xsl:template name="href.target">
+    <xsl:param name="target" select="."/>
+
+    <xsl:text>#</xsl:text>
+
+    <xsl:choose>
+      <xsl:when test="$target/@id">
+        <xsl:value-of select="$target/@id"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="generate-id($target)"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+</xsl:transform>