On 14/06/12 11:04, Alain Ketterlin wrote:
> "japisoft" <
con...@japisoft.com> writes:
>
>> When your document is parsed, the final result has no difference. But
>> from the schema/DTD view, there's a
>> difference because
>>
>> <!ELEMENT somework EMPTY>
>>
>> and
>>
>> <!ELEMENT somework (#PCDATA)>
>>
>> are not equal, so write :
>>
>> <someword></someword>
>>
>> is equal to
>>
>> <someword/>
>>
>> is only true if the content type is (#PCDATA) or
>
> Do you have a source for this claim?
It's been a long time, but I think you'll find the discussion in the
archives of the XML SIG at the time. I seem to remember we did it to
death and the consensus was that XML should not distinguish between the
two forms.
> I think it's wrong. (Not the fact
> that #PCDATA and EMPTY are different, the fact that there is a
> difference between the two forms of empty elements.)
Officially there is no difference. In practice, if your parser has
access to a DTD or Schema, it would be possible for it to detect if
content was allowed or not.
> The XML recommandation says: "If an element is empty, it must be
> represented either by a start-tag immediately followed by an end-tag or
> by an empty-element tag." (Section 3.1)
>
> The only difference I know of is mentioned in the next paragraph: "For
> interoperability, the empty-element tag must be used, and can only be
> used, for elements which are declared EMPTY." And "For interoperability"
> is defined earlier as non-binding.
It is still regarded as good practice in the publishing field, where the
semantics of potential mixed content can be important. It also serves as
a reminder to those who examine the markup that the element type cannot
have any content, rather than the current element just being empty by
chance.
///Peter