XML Canonicalization 1.0 vs 1.1 Differences
XML Canonicalization converts XML documents into a standardized
physical form so that logically equivalent documents yield identical
byte sequences, which is essential for XML digital signatures. While
Canonicalization 1.0 (C14N 1.0) established the foundational rules for
sorting attributes, standardizing whitespace, and normalizing
namespaces, it introduced significant flaws when processing subdocuments
and document subsets. Canonicalization 1.1 (C14N 1.1) was developed
specifically to address these limitations by refining the inheritance
and processing of xml:id, xml:base, and other
xml: prefixed attributes without breaking existing 1.0
implementations.
Handling of xml:id
Attributes
In C14N 1.0, all inherited attributes in the xml
namespace are copied into the root of an extracted subdocument. This
caused a critical issue with xml:id: if an ancestor element
had an xml:id, extracting a child subdocument would inherit
that xml:id, leading to duplicate IDs or invalid ID
assignments in the canonicalized fragment.
C14N 1.1 changes this behavior by ensuring that xml:id
attributes are not inherited by child elements when subsetting an XML
document, preserving document validity and uniqueness.
Resolution and
Inheritance of xml:base
The handling of relative URIs and xml:base attributes is
one of the most prominent changes in C14N 1.1:
- C14N 1.0: When a subdocument is extracted,
xml:baseattributes are inherited plainly as simple string values. If an ancestor element used a relative URI inxml:base, the resulting canonicalized subdocument would fail to maintain the proper URI context because the relative path was not resolved against previous ancestor bases. - C14N 1.1: Implements a fix-up algorithm for
xml:base. When extracting a subdocument, C14N 1.1 recalculates and joins allxml:basevalues through the ancestor hierarchy to produce a corrected, properly resolved base URI for the output root element.
General xml:
Attribute Inheritance
C14N 1.0 treated all xml:* attributes uniformly with a
generic inheritance model. C14N 1.1 categorizes xml:*
attributes into distinct groups with specific rules:
- Simple Inheritance: Attributes like
xml:langandxml:spaceare inherited directly from the nearest ancestor if not explicitly defined on the element. - No Inheritance: Attributes like
xml:idare never inherited. - Value-Fixup Inheritance: Attributes like
xml:baseare resolved and rewritten based on URI resolution rules.
Performance and Implementation Impact
Because C14N 1.1 requires traversing ancestor trees to compute merged base URIs and selectively filter attributes, it involves slightly more processing overhead than 1.0 when canonicalizing node-sets or subdocuments. However, for full-document canonicalization where no node-subsetting is applied, C14N 1.0 and C14N 1.1 produce identical results.