xmlcryptographyxml-signaturecanonicalization

XML namespace location after canonical form


Does turning XML into its Canonical involve the process of moving common/repeated XML namespaces in an XML document into a parent XML node?

The W3 XML specification for the C14N11 transform in section 4 and the subsets of it briefly goes over this, but it's hard to digest.

Am I correct in reading the specification that duplicate namespaces are propagated up?

For example:

<Message xmlns="urn:abc">
    <head:CreatedDate xmlns:head="urn:iso:std:iso:20022:tech:xsd:head.001.001.01">2020-05-28T00:00:00</head:CreatedDate >
    <head:Two xmlns:head="urn:iso:std:iso:20022:tech:xsd:head.001.001.01"></head:Two>
</Message>

Would turn into:

<Message xmlns="urn:abc" xmlns:head="urn:iso:std:iso:20022:tech:xsd:head.001.001.01">
    <head:CreatedDate>2020-05-28T00:00:00</head:CreatedDate>
    <head:Two></head:Two>
</Message>

After XML is in its Canonical form?


Solution

  • None of this has anything to do with schemas. Schemas and namespaces are quite different things.

    There's nothing in the C14N spec that says namespace declarations should be propagated upwards. All it says is that if the same namespace is present on a parent element and a child element, the one on the child is discarded.