Canonical XML (c14n)

Prepare XML documents for plain-text comparisons and digital signatures

Canonical XML lets you create a physical representation of an XML document that allows for the variations in XML syntax without changing the meaning. Discover more about this standard method, which is useful for testing and digital signatures, among other things.

Contributors:  W3C

25 April 2007 (First published 06 February 2007)

Canonical XML lets you create a physical representation of an XML document that allows for the variations in XML syntax without changing the meaning. Discover more about this standard method, which is useful for testing and digital signatures, among other things.

Canonical XML Version 1.0 [W3C Recommendation] is a standard method for generating a physical representation of an XML document, called the canonical form, that accounts for the variations allowed in XML syntax without changing meaning. For example, attribute order in XML is insignificant, so if one document has all its attributes sorted in alphabetical order and another is the same except that its attributes are sorted in some different way, then both documents are identical as far as XML 1.0 is concerned, despite the difference in the physical representation. This presents some practical problems. For example, say you want to have a digitally encrypted signature of a document to ensure that it isn't tampered with. A rearrangement of the attributes would break the signature, even though as far as XML standards are concerned, the document has not really changed. The solution is to convert documents to canonical form (a process called "canonicalization (c14n)") before signature, text comparison, or any other such operation. This ensures that changes insignificant in XML will be correctly accommodated. Work has begun on Canonical XML 1.1 [in development], which addresses several important problems with the 1.0 specification.

Sometimes the XML that needs to be compared or signed is actually just a portion of a bigger document. Even then, c14n generally must account for the entire source document in order to handle details such as namespace declarations. If you require c14n to be strictly limited to a document subset, then you must use the related algorithm Exclusive XML Canonicalization Version 1.0 [W3C Recommendation].

Resources

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML
ArticleID=193463
SummaryTitle=Canonical XML (c14n)
publish-date=04252007