Re: [xsl] XSLT for usable yet valid XHTML

Subject: Re: [xsl] XSLT for usable yet valid XHTML
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Wed, 06 Apr 2005 08:06:22 -0700
Do you want to strip emtpy elements (that are not supposed to be empty) or do you want to leave them in but not have them closed?

You could just use your company's CMS...

"The advantages of Axiom's superior coding

Does your website meet federal section 508 accessibility requirements? Is your website ready for new devices like Palm and wireless? Does your site simply break when viewed with different browsers, or on a Macintosh? Is your website ready to interoperate with other sites or applications via XML?

Axiom sites are built with exceptional attention to coding and compatibility. Our use of XHTML, CSS1 and CSS2 style sheets, and unique code lets us build sites with advanced features easily. We have integrated our site design and build process with the CMS features, making it possible to change the sites visual presentation instantly, or support other devices, without significant further programming."

-Rob



Jonah Gold wrote:
Hi - First off, greetings as I am new to this list. I may not be sticking
around too long though, I should warn, as I may not be doing XSL dev
full-time too much longer. But so long as I'm here I have a question.


We are using XSLT 1.0, parsed by jd.xslt, to transform XML into XHTML.
For output we are currently using <xsl:output method="html" etc... >

This obviously doesn't produce valid xhtml - the slash is removed from
singleton tags, 'checked="checked"' is transformed to simply 'checked',
and some other similar things. This is not surprising, since our method
is set to "html", which defaults to html 4, but ideally we would like
this not to be the case - we are fairly interested in making our XHTML
as valid as possible.

So why, you ask, are we not using 'method="xml"'? This would solve the
above problems, true, but we've had problems with it because our content
is variable enough that we may have the situation of empty tags (i.e.
'<h3></h3>') being converted into singleton tags (i.e. <h3/>) by the
parser, which, while valid XHTML, is viewed as an open tag without
closure by practically all current web browsers. It is a possibility
that we might be able to, say, append a '&nbsp;' to every tag set that
might ever be empty, to prevent them from collapsing in this manner, but
we'd really rather not, as it will mess up some formatting and generally
be a pain.

My question - is there any compromise we can find between these two
problems, making our XHTML valid (or at least less invalid) but not
causing empty tags to collapse into singletons? I am fairly new to XSLT,
so apologies if this is an obvious or ill-advised question. But any
advice anyone has would be appreciated.

Thanks!

--
jonah

Current Thread