Empty-Element Tags

Developers trained in database theory often latch onto the empty-element tag (e.g., <para/>) as a way to indicate a null value, which they rightly consider to be distinct from 0 or the empty string. From their perspective this makes sense. <para>AA</para> is a para element whose value is the string “AA”. <para>A</para> is a para element whose value is the string “A”. <para></para> is a para element whose value is the empty string. Finally, <para/> is a para element whose value is null.

This is all perfectly sensible, but it does not reflect the way XML parsers actually behave. An XML parser will produce exactly the same data from <para></para> as from <para/>. There is no detectable difference between the two. They both have ...

Get Effective XML: 50 Specific Ways to Improve Your XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.