w3c / qtspecs

XSLT and XQuery Specifications - the source used to build the specs, and the errata
Other
30 stars 25 forks source link

[ser31] ancestor in xhtml prefix normalization #11

Open benibela opened 4 years ago

benibela commented 4 years ago

XSLT and XQuery Serialization 3.1 says in 6 XHTML Output Method

[Definition: During prefix normalization, any element node in the instance of the data model that is to be serialized that is in one of the XHTML namespace, the SVG namespace or the MathML namespace has its name replaced by the local part of its name. Such an element node is given a default namespace node whose value is the element's namespace URI. Any namespace node for any of those three namespaces that was previously present on any element node in the instance of the data model is also removed, unless the prefix that that namespace node declared is used as the prefix on the name of an attribute on that element or an ancestor of that element.]

Should that not be "a descendant", since ancestors are not affected by namespace nodes?

michaelhkay commented 4 years ago

My first instinct was to agree with you, but I think it's correct.

Consider <svg:a xmlns:svg="zz"><svg:b svg:att="3"><svg:c/></svg:b></svg:a>. In the final result the a element won't have a namespace node for the svg namespace, because it doesn't need one. The b element will have such a namespace node, because it has an attribute in the svg namespace. The c element will have such a namespace node, inherited from its parent element: or in the language of this paragraph, retained because an ancestor has an attribute in the svg namespace.

(It helps to know something of the people who wrote the spec. This is almost certainly drafted by Henry Zongaro. Henry writes very precisely and rarely gets such things wrong. He also writes very concisely: he rarely says anything twice, and rarely adds any kind of gloss or note to say "yes I really meant that"; he demands that his readers pay very careful attention to every word).