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
diff --git a/ChangeLog b/ChangeLog
index a5c154d..a09b67c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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
diff --git a/c14n.c b/c14n.c
index 0088d16..5f18581 100644
--- a/c14n.c
+++ b/c14n.c
@@ -793,7 +793,7 @@
          * 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) {
diff --git a/xmllint.c b/xmllint.c
index b92b533..2a57385 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -173,6 +173,7 @@
 #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 @@
 		    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 @@
     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 @@
 	    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")) ||