mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
added a --c14n option to canonicalize the output should close the RFE
* xmllint.c: added a --c14n option to canonicalize the output should close the RFE #143226 Daniel
This commit is contained in:
parent
1f8658a76f
commit
25048d8262
@ -1,3 +1,8 @@
|
|||||||
|
Sun Aug 15 00:41:12 CEST 2004 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xmllint.c: added a --c14n option to canonicalize the output
|
||||||
|
should close the RFE #143226
|
||||||
|
|
||||||
Sat Aug 14 23:50:10 CEST 2004 Daniel Veillard <daniel@veillard.com>
|
Sat Aug 14 23:50:10 CEST 2004 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* tree.c: Dodji pointed out a bug in xmlGetNodePath()
|
* tree.c: Dodji pointed out a bug in xmlGetNodePath()
|
||||||
|
29
xmllint.c
29
xmllint.c
@ -168,6 +168,9 @@ static int dropdtd = 0;
|
|||||||
static int catalogs = 0;
|
static int catalogs = 0;
|
||||||
static int nocatalogs = 0;
|
static int nocatalogs = 0;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef LIBXML_C14N_ENABLED
|
||||||
|
static int canonical = 0;
|
||||||
|
#endif
|
||||||
#ifdef LIBXML_READER_ENABLED
|
#ifdef LIBXML_READER_ENABLED
|
||||||
static int stream = 0;
|
static int stream = 0;
|
||||||
static int walker = 0;
|
static int walker = 0;
|
||||||
@ -1209,6 +1212,21 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef LIBXML_C14N_ENABLED
|
||||||
|
if (canonical) {
|
||||||
|
xmlChar *result = NULL;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
size = xmlC14NDocDumpMemory(doc, NULL, 0, NULL, 1, &result);
|
||||||
|
if (size >= 0) {
|
||||||
|
write(1, result, size);
|
||||||
|
xmlFree(result);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Failed to canonicalize\n");
|
||||||
|
progresult = XMLLINT_ERR_OUT;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_SYS_MMAN_H
|
||||||
if (memory) {
|
if (memory) {
|
||||||
xmlChar *result;
|
xmlChar *result;
|
||||||
@ -1228,6 +1246,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
|||||||
}
|
}
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
fprintf(stderr, "Failed to save\n");
|
fprintf(stderr, "Failed to save\n");
|
||||||
|
progresult = XMLLINT_ERR_OUT;
|
||||||
} else {
|
} else {
|
||||||
write(1, result, len);
|
write(1, result, len);
|
||||||
xmlFree(result);
|
xmlFree(result);
|
||||||
@ -1579,6 +1598,9 @@ static void usage(const char *name) {
|
|||||||
printf("\t--encode encoding : output in the given encoding\n");
|
printf("\t--encode encoding : output in the given encoding\n");
|
||||||
printf("\t--dropdtd : remove the DOCTYPE of the input docs\n");
|
printf("\t--dropdtd : remove the DOCTYPE of the input docs\n");
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
|
printf("\t--c14n: save in W3C canonical format (with comments)\n");
|
||||||
|
#ifdef LIBXML_C14N_ENABLED
|
||||||
|
#endif /* LIBXML_C14N_ENABLED */
|
||||||
printf("\t--nsclean : remove redundant namespace declarations\n");
|
printf("\t--nsclean : remove redundant namespace declarations\n");
|
||||||
printf("\t--testIO : test user I/O support\n");
|
printf("\t--testIO : test user I/O support\n");
|
||||||
#ifdef LIBXML_CATALOG_ENABLED
|
#ifdef LIBXML_CATALOG_ENABLED
|
||||||
@ -1806,6 +1828,13 @@ main(int argc, char **argv) {
|
|||||||
xmlParserDebugEntities = 1;
|
xmlParserDebugEntities = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef LIBXML_C14N_ENABLED
|
||||||
|
else if ((!strcmp(argv[i], "-c14n")) ||
|
||||||
|
(!strcmp(argv[i], "--c14n"))) {
|
||||||
|
canonical++;
|
||||||
|
options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef LIBXML_CATALOG_ENABLED
|
#ifdef LIBXML_CATALOG_ENABLED
|
||||||
else if ((!strcmp(argv[i], "-catalogs")) ||
|
else if ((!strcmp(argv[i], "-catalogs")) ||
|
||||||
(!strcmp(argv[i], "--catalogs"))) {
|
(!strcmp(argv[i], "--catalogs"))) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user