title: What is an empty element?
body: <p>According to the XML spec, this is the definition of an empty element:</p>
  
  <blockquote>
    <p>An element with no content is said to be empty.] The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag.</p>
  </blockquote>
  
  <p>(see: <a href="http://www.w3.org/TR/REC-xml/#NT-content" rel="noreferrer">http://www.w3.org/TR/REC-xml/#NT-content</a>)</p>
  
  <p>Now, I have no problem understanding empty-element tags: <code>&lt;i-am-empty/&gt;</code> and no misunderstanding is possible. But it seems to me the standard contradicts itself in the other case: on the one hand it says that any tag with no <code>content</code> is empty, on the other hand it says that this can be represented by a start-tag followed immediately by an end-tag. But if we look at the definition of <code>content</code>:</p>
  
  <pre><code>[43] content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*
  </code></pre>
  
  <p>It seems to me that <code>content</code> consists of two optional parts, <code>CharData?</code> and a group <code>()*</code>. But since both these parts are optional, it would mean that nothing (as in, absence of characters) matches this production. SO if I would try to match this definition of content to whatever is inside <code>&lt;am-i-empty-or-not&gt;&lt;/am-i-empty-or-not&gt;</code> I would get a positive match. So, on the one hand this is an empty tag because it is "a start-tag immediately followed by an end-tag", on the other hand it is not empty because between the tags I can positively match the definition of production rule [43] for content, in which case it contains content, which means it can't be empty.</p>
  
  <p>Can anybody explain what rules take precedence? Does anybody know about any DOM or parser implementations that have differrent opinions on this?</p>