Note: The bug description below was extracted from my ticket in my fork of libxml2 @ GitHub and is formatted using markdown.
---- Start of Bug description ---- When running `$ xmllint --c14n11 [other options] [xmlfile]` it doesn't sort the attributes as per the [Canonical XML Version 1.1]( http://www.w3.org/TR/xml-c14n11/) from w3c. Specifically I note that the following specifications are not verified: > * The XML declaration and document type declaration are removed * Lexicographic order is imposed on the namespace declarations and attributes of each element These specifications, already existent in the [previous recomendation]( http://www.w3.org/TR/xml-c14n), hold with the call of `$ xmllint --c14n [other options] [xmlfile]`. #### I/O *Note the order of the attributes and the XML declaration and document type* ##### Input ```xml <?xml version="1.0"?> <root> <!-- I am a comment --> <h:table xmlns:h="http://www.w3.org/TR/html4/"> <h:tr> <h:td c="" a="" z="" >Apples</h:td> <h:td>Bananas</h:td> </h:tr> </h:table> </root> ``` ##### Expected Output ```xml <root> <!-- I am a comment --> <h:table xmlns:h="http://www.w3.org/TR/html4/"> <h:tr> <h:td a="" c="" z="">Apples</h:td> <h:td>Bananas</h:td> </h:tr> </h:table> </root> ``` ##### Actual Output ```xml <?xml version="1.0"?> <root> <!-- I am a comment --> <h:table xmlns:h="http://www.w3.org/TR/html4/"> <h:tr> <h:td c="" a="" z="">Apples</h:td> <h:td>Bananas</h:td> </h:tr> </h:table> </root> ``` ---- End of Bug description ---- In attachment there's the patch that fixes this behaviour. Best regards, Sérgio Batista m...@se.rg.io
From 0e97c3ee2674db2fe466ed0aa191b690c9f5af70 Mon Sep 17 00:00:00 2001 From: Sergio <m...@se.rg.io> Date: Wed, 7 May 2014 19:05:24 +0200 Subject: [PATCH] xmllint was not parsing the --c14n11 flag, fixes #1 --- xmllint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmllint.c b/xmllint.c index 9d46ac5..b297ded 100644 --- a/xmllint.c +++ b/xmllint.c @@ -2580,7 +2580,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) { fprintf(stderr, "Failed to canonicalize\n"); progresult = XMLLINT_ERR_OUT; } - } else if (canonical) { + } else if (canonical_11) { xmlChar *result = NULL; int size; -- 1.9.1
_______________________________________________ xml mailing list, project page http://xmlsoft.org/ xml@gnome.org https://mail.gnome.org/mailman/listinfo/xml