Convert xml:lang attribute when serializing HTML.

Description

Improve the HTML serializer to convert xml:lang attributes.

XML has the xml:lang attribute, but HTML5 has the lang attribute.

  • HTML5 prohibits xml:lang in the XML namespace.

  • HTML5 allows xml:lang in no namespace (it's unclear how that would even come about), but it has no effect, but if present there must also be a lang attribute with the same value (compared in an ASCII case-insensitive manner).

See Can someone explain what the xml:lang attribute does in HTML5? for more discussion. See also Declaring language in HTML.

The HTML serializer should process xml:lang attributes specially:

  • If there is no lang attribute, the xml:lang attribute should be serialized as lang.

  • If there is a lang attribute with a different value, an error should be emitted. (To be implemented in JAVA-187.)

  • If there is a lang attribute with the same value, the xml:lang attribute should be silently ignored.

It should be straightforward to have unit tests for all these scenarios.

Environment

None

Assignee

Garret Wilson

Reporter

Garret Wilson

Labels

None

Components

Fix versions

Affects versions

Priority

Critical
Configure