Commit 2650df1a authored by Aleksey Sanin's avatar Aleksey Sanin

fixed xml attributes processing bug in exc c14n added --exc-c14n command

* c14n.c: fixed xml attributes processing bug in exc c14n
* xmllint.c: added --exc-c14n command line option
parent fbb619f4
2005-06-06 Aleksey Sanin <aleksey@aleksey.com>
* c14n.c: fixed xml attributes processing bug in exc c14n
* xmllint.c: added --exc-c14n command line option
Mon Jun 6 06:43:33 PDT 2005 William Brack <wbrack@mmm.com.hk>
* xpath.c, pattern.c: Enhanced xmlXPathRunStreamEval, fixed
......
......@@ -793,7 +793,7 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
* default namespace (XML Namespaces: "default namespaces
* do not apply directly to attributes")
*/
if((attr->ns != NULL) && xmlC14NIsVisible(ctx, attr, cur)) {
if((attr->ns != NULL) && !xmlC14NIsXmlNs(attr->ns) && xmlC14NIsVisible(ctx, attr, cur)) {
already_rendered = xmlExcC14NVisibleNsStackFind(ctx->ns_rendered, attr->ns, ctx);
xmlC14NVisibleNsStackAdd(ctx->ns_rendered, attr->ns, cur);
if(!already_rendered && visible) {
......
......@@ -173,6 +173,7 @@ static int nocatalogs = 0;
#endif
#ifdef LIBXML_C14N_ENABLED
static int canonical = 0;
static int exc_canonical = 0;
#endif
#ifdef LIBXML_READER_ENABLED
static int stream = 0;
......@@ -1480,6 +1481,19 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
progresult = XMLLINT_ERR_OUT;
}
} else
if (exc_canonical) {
xmlChar *result = NULL;
int size;
size = xmlC14NDocDumpMemory(doc, NULL, 1, 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
if (memory) {
......@@ -1857,7 +1871,8 @@ static void usage(const char *name) {
printf("\t--encode encoding : output in the given encoding\n");
printf("\t--dropdtd : remove the DOCTYPE of the input docs\n");
#endif /* LIBXML_OUTPUT_ENABLED */
printf("\t--c14n: save in W3C canonical format (with comments)\n");
printf("\t--c14n : save in W3C canonical format (with comments)\n");
printf("\t--exc-c14n : save in W3C exclusive canonical format (with comments)\n");
#ifdef LIBXML_C14N_ENABLED
#endif /* LIBXML_C14N_ENABLED */
printf("\t--nsclean : remove redundant namespace declarations\n");
......@@ -2100,6 +2115,11 @@ main(int argc, char **argv) {
canonical++;
options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD;
}
else if ((!strcmp(argv[i], "-exc-c14n")) ||
(!strcmp(argv[i], "--exc-c14n"))) {
exc_canonical++;
options |= XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD;
}
#endif
#ifdef LIBXML_CATALOG_ENABLED
else if ((!strcmp(argv[i], "-catalogs")) ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment