Home > Net >  Default javax.xml.transform.Transformer changed output for "br" element to XML
Default javax.xml.transform.Transformer changed output for "br" element to XML

Time:06-12

A small but change happened in JDK 8 (AdoptOpenJDK / Temurin) between u292 and u332. In u332, DOM to XML conversion of a br DOM element emits the string <br />. In u292, the Transformer emits the string without the space: <br/>.

In the XML specification I found the rules for Tags for empty elements (https://www.w3.org/TR/xml/#d0e2480). Do I understand correctly that <br/> did not comply with the specification? (as there must be at least one whitespace between slash and closing greater-than sign)

CodePudding user response:

No, there may be, but need not be, whitespace immediately preceding the />:

Tags for Empty Elements

[44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>' [WFC: Unique Att Spec]

The ? in S? means that S (whitespace) may optionally appear.

Software should not depend upon the presence or absence whitespace there.

  • Related