Empty Tags

Henry Thompson ht at cogsci.ed.ac.uk
Tue Jan 27 09:25:38 GMT 1998

Bill Wendling <wendling at ganymede.isdn.uiuc.edu> writes:

> Is there a way in XML to make a tag conditionally empty?  That is, if you
> have this declaration:
> <!ELEMENT syntax - - (attr)*>
> <!ATTLIST syntax TYPE (brief | full) brief>
> if the attrset attribute of syntax has a value, could the user type it as:
> <syntax attrset="foo"/>
> instead of
> <syntax attrset="foo">
> </syntax>

Both of those are valid (and I use the word carefully) XML regardless
of the declaration of the attribute and almost* regardless of the
content model of the element.  The proposed recommendation text reads

  "Empty-element tags may be used for any element which has no content,
   whether or not it is declared using the keyword EMPTY."

So you can write what you wanted, but you can't get a guarantee that
you've only used the empty tag when the attribute is present.

*The only case either would be invalid is when both would be invalid,
e.g. because the content model for 'syntax' and some REQUIRED content.

Henry S. Thompson, Human Communication Research Centre, University of Edinburgh
      2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
               Fax: (44) 131 650-4587, e-mail: ht at cogsci.ed.ac.uk  
                      URL: http://www.cogsci.ed.ac.uk/~ht/

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