diff --git a/expat/doc/reference.html b/expat/doc/reference.html index 1237666d..ab6c84fa 100644 --- a/expat/doc/reference.html +++ b/expat/doc/reference.html @@ -395,6 +395,46 @@ the shared variables. You can then tell expat (with the +

XML Version

+ +

Expat is an XML 1.0 parser, and as such never complains based on +the value of the version psuedo-attribute in the XML +declaration, if present.

+ +

If an application needs to check the version number (to support +alternate processing), it should use the XML_SetXmlDeclHandler function to +set a handler that uses the information in the XML declaration to +determine what to do. This example shows how to check that only a +version number of "1.0" is accepted:

+ +
+static int wrong_version;
+static XML_Parser parser;
+
+static void
+xmldecl_handler(void            *userData,
+                const XML_Char  *version,
+                const XML_Char  *encoding,
+                int              standalone)
+{
+  static const XML_Char Version_1_0[] = {'1', '.', '0', 0};
+
+  int i;
+
+  for (i = 0; i < (sizeof(Version_1_0) / sizeof(Version_1_0[0])); ++i) {
+    if (version[i] != Version_1_0[i]) {
+      wrong_version = 1;
+      /* also clear all other handlers: */
+      XML_SetCharacterDataHandler(parser, NULL);
+      ...
+      return;
+    }
+  }
+  ...
+}
+
+

Namespace Processing

When the parser is created using the