]> granicus.if.org Git - libexpat/commitdiff
Add command-line arg "-N" to xmlwf to add notations to test output
authorRhodri James <rhodri@kynesim.co.uk>
Wed, 2 Aug 2017 15:09:13 +0000 (16:09 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Tue, 22 Aug 2017 20:21:10 +0000 (22:21 +0200)
...and use it in xmltest.sh

expat/doc/xmlwf.xml
expat/tests/xmltest.sh
expat/xmlwf/xmlwf.c

index 1444ec1a4ccb4fbbdb15d0ae7a0e9d80caa8731d..5e2a4ae94ab398d2691d021657058d806f8d3639 100644 (file)
@@ -58,6 +58,7 @@
 
          <arg><option>-r</option></arg>
          <arg><option>-t</option></arg>
+          <arg><option>-N</option></arg>
 
          <arg><option>-v</option></arg>
 
@@ -159,8 +160,8 @@ supports both.
   representations of the input files.
   By default, <option>-d</option> outputs a canonical representation
   (described below).
-  You can select different output formats using <option>-c</option>
-  and <option>-m</option>.
+  You can select different output formats using <option>-c</option>,
+  <option>-m</option> and <option>-N</option>.
          </para>
          <para>
   The output filenames will
@@ -219,6 +220,17 @@ supports both.
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>-N</option></term>
+        <listitem>
+          <para>
+  Adds a doctype and notation declarations to canonical XML output.
+  This matches the example output used by the formal XML test cases.
+  Requires <option>-d</option> to specify an output file.
+          </para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><option>-p</option></term>
         <listitem>
index e50093285af5a8a24cbb1f626985f61fd201906c..8b330f9c6a3c919bf46bd7eb80dd78d0ee84cd22 100755 (executable)
@@ -53,7 +53,7 @@ RunXmlwfNotWF() {
 RunXmlwfWF() {
   file="$1"
   reldir="$2"
-  $XMLWF -p -d "$OUTPUT$reldir" "$file" > outfile || return $?
+  $XMLWF -p -N -d "$OUTPUT$reldir" "$file" > outfile || return $?
   read outdata < outfile 
   if test "$outdata" = "" ; then 
       if [ -f "out/$file" ] ; then 
index 93a22f57f7204eaa2fcf53b43328e43f31093c02..68acfd101b98148a926ddee4b5a438626f44ccd2 100644 (file)
@@ -454,6 +454,9 @@ notationDecl(void *UNUSED_P(userData),
       return;
     }
   }
+  else {
+    entry->publicId = NULL;
+  }
 
   entry->next = notationListHead;
   notationListHead = entry;
@@ -848,7 +851,7 @@ static void
 usage(const XML_Char *prog, int rc)
 {
   ftprintf(stderr,
-           T("usage: %s [-s] [-n] [-p] [-x] [-e encoding] [-w] [-d output-dir] [-c] [-m] [-r] [-t] [file ...]\n"), prog);
+           T("usage: %s [-s] [-n] [-p] [-x] [-e encoding] [-w] [-d output-dir] [-c] [-m] [-r] [-t] [-N] [file ...]\n"), prog);
   exit(rc);
 }
 
@@ -863,6 +866,7 @@ tmain(int argc, XML_Char **argv)
   int outputType = 0;
   int useNamespaces = 0;
   int requireStandalone = 0;
+  int requiresNotations = 0;
   enum XML_ParamEntityParsing paramEntityParsing = 
     XML_PARAM_ENTITY_PARSING_NEVER;
   int useStdin = 0;
@@ -920,6 +924,10 @@ tmain(int argc, XML_Char **argv)
       outputType = 't';
       j++;
       break;
+    case T('N'):
+      requiresNotations = 1;
+      j++;
+      break;
     case T('d'):
       if (argv[i][j + 1] == T('\0')) {
         if (++i == argc)
@@ -1057,8 +1065,10 @@ tmain(int argc, XML_Char **argv)
         XML_SetCharacterDataHandler(parser, characterData);
 #ifndef W3C14N
         XML_SetProcessingInstructionHandler(parser, processingInstruction);
-        XML_SetDoctypeDeclHandler(parser, startDoctypeDecl, endDoctypeDecl);
-        XML_SetNotationDeclHandler(parser, notationDecl);
+        if (requiresNotations) {
+          XML_SetDoctypeDeclHandler(parser, startDoctypeDecl, endDoctypeDecl);
+          XML_SetNotationDeclHandler(parser, notationDecl);
+        }
 #endif /* not W3C14N */
         break;
       }