From 0da3d1b5bf0e55485043fa4412c4108b251126d4 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Wed, 2 Aug 2017 16:09:13 +0100 Subject: [PATCH] Add command-line arg "-N" to xmlwf to add notations to test output ...and use it in xmltest.sh --- expat/doc/xmlwf.xml | 16 ++++++++++++++-- expat/tests/xmltest.sh | 2 +- expat/xmlwf/xmlwf.c | 16 +++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/expat/doc/xmlwf.xml b/expat/doc/xmlwf.xml index 1444ec1a..5e2a4ae9 100644 --- a/expat/doc/xmlwf.xml +++ b/expat/doc/xmlwf.xml @@ -58,6 +58,7 @@ + @@ -159,8 +160,8 @@ supports both. representations of the input files. By default, outputs a canonical representation (described below). - You can select different output formats using - and . + You can select different output formats using , + and . The output filenames will @@ -219,6 +220,17 @@ supports both. + + + + + Adds a doctype and notation declarations to canonical XML output. + This matches the example output used by the formal XML test cases. + Requires to specify an output file. + + + + diff --git a/expat/tests/xmltest.sh b/expat/tests/xmltest.sh index e5009328..8b330f9c 100755 --- a/expat/tests/xmltest.sh +++ b/expat/tests/xmltest.sh @@ -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 diff --git a/expat/xmlwf/xmlwf.c b/expat/xmlwf/xmlwf.c index 93a22f57..68acfd10 100644 --- a/expat/xmlwf/xmlwf.c +++ b/expat/xmlwf/xmlwf.c @@ -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; }