[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Where does and doesn't whitespace matter?
- From: Roger L Costello <costello@mitre.org>
- To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
- Date: Thu, 3 Feb 2022 00:23:24 +0000
Hi Folks,
I ignore PIs, CDATA sections, and DOCTYPE.
Is this correct:
1. Whitespace before and after an XML declaration doesn't matter.
2. Start tags
2.1 Whitespace preceding the > and the /> doesn't matter, e.g.,
<foo >
<foo />
2.2. Whitespace before an attribute name doesn't matter, e.g.,
<foo x="1">
2.3 Whitespace surrounding the equals symbol in an attribute doesn't matter, e.g.,
<foo x = "1">
2.4 Whitespace between attributes doesn't matter, e.g.,
<foo x="1" y="2">
2.5 Whitespace in an attribute value _does_ matter, e.g.,
<foo x = " 1 ">
3. End tags
3.1 Whitespace preceding the > doesn't matter, e.g.,
</foo >
4. Element content
4.1 In an element whose content is purely data, the whitespace in the data _does_ matter, e.g.,
<foo> hello, world </foo>
4.2 In an element whose content is elements interleaved with whitespace, the whitespace _does_ matter. With regard to the whitespace in the elements, see steps 2 - 4. Example:
<foo>
<bar> hello, world </bar>
<baz> glob </baz>
</foo>
The whitespace between <foo> and <bar> _does_ matter. The whitespace between </bar> and <baz> _does_ matter. The whitespace between </baz> and </foo> _does_ matter. See steps 2 - 4 regarding what whitespace in <bar> hello, world </bar> matters and what whitespace in <baz> glob </baz> matters.
5. Root element:
5.1 Whitespace after the end tag doesn't matter.
Do you agree? Am I missing anything?
/Roger
4. White
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]