Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 4th, 2005, 10:39 AM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default empty tags vs. singletons

Hello. New here, with a question that I've been able to turn up frustratingly little on -

We are using XSLT, parsed by jd.xslt, to transform XML into XHTML. We are currently using

<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd"/>

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", but ideally we would like this not to be the case.

So why, you ask, are we not using 'method="xml"'? This would solve the above problem, 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 not accepted by practically any current web browser. 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 but making empty tags not 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
 
Old April 9th, 2005, 07:37 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

In my opinion you're wasting your time trying to output xhtml unless you can define the target browser. With IE not supporting it you're fighting all the way...
This has been discussed many times and I've never seen a satisfactory solution.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Names within tags ? tjclifford XSLT 3 June 10th, 2008 08:33 AM
Using meta tags amatytfc ASP.NET 2.0 Basics 1 August 6th, 2007 05:47 PM
Empty tags in resulting html? C.R. Chambers XSLT 6 July 22nd, 2005 03:59 PM
Help! Empty paragraph tags! abq23 PHP How-To 1 June 15th, 2004 08:57 PM
Where Are The Rant Tags? Ben Horne Forum and Wrox.com Feedback 4 March 12th, 2004 10:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.