Can a xml be well formed having not empty elements self closed?
Anything like this:
<team>Chicago Bulls<playerA/>23<playerB/>43</team>
instead of:
<team>Chicago Bulls<playerA>23</playerA><playerB>43</playerB></team>
Would it be well formed and where I could read about it? Mostly from w3c.
Thanks in advance
Yes, both of your examples are well-formed, but to precede a player number with a
playerelement rather than place it in the contents of theplayerelement would be a very poor design decision as it would fail to leverage the natural hierarchy that XML tools and developers would expect.You can read more about well-formedness,
but do not expect to see your point addressed explicitly because your question is less about well-formedness than it is about design.
Historical Note
XML's predecessor, SGML, had a notion of omitted end tags, which might be related to the motivation for your question. Instead of as in your first example where you use self-closing tags (which produce empty elements, to be clear),
the
playerAandplayerBelements could be defined to have an omitted end tags, allowing the following markup:Your self-closing
playerelements have been replaced by open tags with omitted end tags. This would not be well-formed XML.