Re: [xsl] <empty /> vs <empty></empty?

Subject: Re: [xsl] <empty /> vs <empty></empty?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 11 Dec 2005 08:27:53 -0500
At 2005-12-11 14:21 +1100, Eric Scheid wrote:
Is there any way to control whether empty elements appear as
<empty></empty>, instead of <empty/>?

No, that is outside the specification. A vendor might offer that as a feature, but there is no control in the W3C spec.

My problem is that some browsers don't like <div/> or <a name="x"/>, not
recognising that they both begin and *end* there, thinking instead they are
opening tags only.

Indeed ... in my class I use the following as an example (note that one has to first substitute "< " with "<" as I've escaped the markup so this will work in mailers):

< ?xml version="1.0" encoding="utf-8"?>
< !DOCTYPE html
 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
< html xmlns="";>
< head>
 < title>test< /title>
 < meta http-equiv=
       "Content-type" content='text/html; charset="utf-8"' />
< /head>
< body>
< div>Div is normal< /div>
< div style="font-style:italic">Div is italic< /div>
< div style="text-decoration:underline" />
< div>No underline< /div>
< div style="font-weight:bold">< /div>
< div>No underline or bold< /div>
< /body>
< /html>

The above works just fine in Opera and in Firefox, but not in Internet Explorer.

This presents a problem when the transformation doesn't find content and ends up producing the empty element in the result tree: the formatting for that empty element "bleeds" to the end of the document.

As a workaround, I believe I can do this:
    <a name="x"><xsl:comment> empty </xsl:comment></a>

Kewl! I hadn't thought of forcing it that way. Thanks!

. . . . . . . . . Ken

Upcoming XSLT/XSL-FO hands-on courses:  Denver,CO March 13-17,2006
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05
Legal business disclaimers:

Current Thread