Empty elements

David Megginson ak117 at freenet.carleton.ca
Thu Feb 12 14:38:40 GMT 1998


Jani Jaakkola writes:

 > Yes, but in SGML and XML element type which has been declared empty
 > in the DTD and therefore is marked with <Para/> tag in XML
 > is different thing from element which just happens to be
 > empty (e.g <para></para>).

Actually, that's not generally the case in XML.  Here's what the REC
says (Section 3.1 "Start-Tags, End-Tags, and Empty-Element Tags"):

   Empty-element tags may be used for any element which has no content,
   whether or not it is declared using the keyword EMPTY. For
   interoperability, the empty-element tag must be used, and can only be
   used, for elements which are declared EMPTY.

   Examples of empty elements:

   <IMG align="left"
    src="http://www.w3.org/Icons/WWW/w3c_home" />
   <br></br>
   <br/>

Here's the definition of "for interoperability":

   for interoperability
          A non-binding recommendation included to increase the chances
          that XML documents can be processed by the existing installed
          base of SGML processors which predate the WebSGML Adaptations
          Annex to ISO 8879.

In other words, XML processors may (and should) treat

  <br></br>

and

  <br/>

as equivalent, but document authors might want to make the distinction
so that pre-WebSGML SGML parsers can handle their documents.

That begs the question of the processor's information set, however --
a processor designed for use with repositories or with editors, for
example, needs to preserve lexical as well as structural information
about the XML document, such as comments, general entity references
(even within attribute values), specified vs. defaulted attribute
values, CDATA sections, whitespace within tags, etc.

SAX as it currently stands is not designed to preserve most lexical
information; in the future, we may devise a SAX level-2 to return this
information, but since most applications that need it will probably
use a DOM anyway, the demand may not be strong enough.


All the best,


David

-- 
David Megginson                 ak117 at freenet.carleton.ca
Microstar Software Ltd.         dmeggins at microstar.com
      http://home.sprynet.com/sprynet/dmeggins/

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list