RFC 5261, "An Extensible Markup Language (XML) Patch Operations Framework Utilizing XML Path Language (XPath) Selectors", September 2008Source of RFC: simple (rai)
Errata ID: 3478
Status: Held for Document Update
Reported By: Erik Wilde
Date Reported: 2013-02-07
Held for Document Update by: Gonzalo Camarillo
Section 4.4.3 says:
4.4.3. Replacing a Namespace Declaration URI An example for a replacement of a namespace URI: <replace sel="doc/namespace::pref">urn:new:xxx</replace> This will replace the URI value of 'pref' prefixed namespace node with "urn:new:xxx". The parent node of the namespace declaration MUST be the <doc> element, otherwise an error occurs.
It should say:
4.4.3. Replacing a Namespace URI An example for a replacement of a namespace URI: <replace sel="doc/namespace::pref">urn:new:xxx</replace> This will replace the URI of the namespace associated with the 'pref' prefix with "urn:new:xxx". The parent node of the namespace declaration MUST be the <doc> element, otherwise an error occurs. Replacing the namespace at the element where it is declared MUST also change all namespace nodes derived from this declaration in descendant elements.
The spec uses the terms "namespace declaration" and "namespace" almost interchangeably, which is incorrect. It is impossible to select (and thus patch) *namespace declarations* using XPath. When selecting and replacing a *namespace*, then it should be taken into account that the *namespace declaration* very likely has resulted in numerous namespace nodes, attached to child elements of the element where the namespace was declared. It is likely that the spec intended to specify a "recursive replace" of the resulting namespace nodes of a namespace declaration, and this is what the corrected text suggests. The original text is mixing terminology, hard to read, and ambiguous in its meaning.
If the spec text instead tried to specify that really only this one namespace node should be changed, then this can lead to rather strange effects in the resulting document, since the XPath tree now has "orphan" namespace nodes, which then need to be serialized and namespace declarations in locations where previously no namespace declarations occurred.
One way or the other, this ambiguity needs to be clarified to make the spec easier to read and implement.