Special Considerations for Attributes

§6.3 of the W3C Recommendation “Namespaces in XML 1.0 (Second Edition)” makes a distinction between prefixed attributes and unprefixed attributes sharing the same local name. Given an element whose expanded name refers to namespace N, an unprefixed attribute with local name L is distinct from a prefixed attribute with local name L and namespace N. The existence of this distinction is important in defining correct subsumption behavior for markup consumers.

A subsuming namespace might extend a pre-existing element local name with a new unprefixed attribute. Similarly, a subsuming namespace might create a new attribute designed for prefixed use.

Note:

Assume that the namespace associated with prefix v2 subsumes the namespace associated with v1. Suppose a markup consumer that understands the v2 namespace encounters markup of the following form:

<v1:OldElement mc:Ignorable=”v2” v2:NewAttribute=”value” />

How should that markup consumer interpret that markup? Should it be considered equivalent to the following markup?

<v2:OldElement NewAttribute=”value” />

Or should it be considered equivalent to the following markup?

<v2:OldElement v2:NewAttribute=”value” />

According to “Namespaces in XML 1.0 (Second Edition)”, these two potential pieces of markup are not equivalent. Additionally, the XML Schema specification allows for the construction of different XSD schemas that validate one, the other, or both of these constructs. ]

When processing an element from an older namespace that carries a prefixed attribute from a newer, subsuming namespace, a markup consumer shall decide whether to treat the new attribute as if its expanded name refers to the new namespace or as if its expanded name refers to no namespace. If a subsuming namespace adds a new attribute or permissible attribute value to an element that was present in the subsumed namespace, the markup specification that defines the subsuming namespace shall state which of the two subsumption behaviors shall be used by markup consumers and assumed by markup producers.

Note:

In order to support a preprocessing model for Markup Compatibility elements and attributes, specifications should restrict the use of any combination of prefixed and unprefixed attributes with the same local name.

A namespace should not be subsumed by a newer namespace if the older namespace includes both a prefixed attribute and an unprefixed attribute sharing its local name but having a different type or different semantics.

A subsuming namespace should not include both a prefixed attribute and an unprefixed attribute sharing its local name but having a different type or different semantics.