[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] how to close html tags : link, meta,...


Subject: RE: [xsl] how to close html tags : link, meta,...
From: Chris Loschen <loschen@xxxxxxxxxxxxx>
Date: Wed, 13 Aug 2003 12:37:14 -0400

Quoting from the XML Spec:



<quote>

Tags for Empty Elements

[44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>' [WFC: Unique Att Spec]

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 should be used, and should only be used, for elements which are declared EMPTY.

</quote>

Many parsers "in the wild" implement the second part of this; that is, they use the empty element tag if and only if the element
is declared as EMPTY in the DTD. However, the spec clearly states that the empty element tag may be used "for any element
which has no content."


XMetaL is one example of a tool which implements the DTD rule -- when it's producing its own XML, this isn't a problem. However,
when it reads perfectly good XML which is set up using empty element shorthand tags (for example, the output from XSLT) and
throws an error, we have a problem.


If my reading of the spec is accurate (and it hasn't been altered by some errata or something), the DTD is not the determining
factor for use of empty element tags, and so the reading below is not correct. However, since some tools do insist on the
interoperability optimization, it would still be desirable to have the option of implementing either of these methods in particular
situations.


At 11:14 AM 8/13/03, you wrote:

> > Sorry to go on but...
> >
> > <div> *is not* declared as empty, so it must be <div></div>
> >
> > <img> *is* declared as empty, therefore it can be <img/> or
<img></img>
> >
> > That is my reading of the spec, please someone tell me if I am
wrong.
>
> In which case I'd say the spec needs to be fixed.
>
> Either div has required content, in which case both "<div/>" and
> "<div></div>" would be non-valid.
>
> If content is not required (which is the case), both notations MUST be
> allowes, otherwise XHTML would not conform to the XML spec.


There's a difference. One is well-formed xml, the other is valid xhtml.


<div/> is well formed xml, but not valid xhtml.

<div></div> is both well-formed xml, and valid xhtml.

One involves a dtd the other doesn't.  There's nothing wrong with the
spec, its just when people see well-formed html they think its xhtml,
which it isnt.




--Chris

----------------------------------------------------------------------------------------
Texterity ~ XML and PDF ePublishing Services
----------------------------------------------------------------------------------------
Chris Loschen, XML Developer
Texterity, Inc.
144 Turnpike Road
Southborough, MA 01772 USA
tel: +1.508.804.3033
fax: +1.508.804.3110
email: loschen@xxxxxxxxxxxxx
http://www.texterity.com/
Texterity: Digital Delivery Made Simple



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




Current Thread
Keywords