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 26th, 2007, 09:50 PM
Authorized User
 
Join Date: Apr 2007
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default Saxon - Prevent closing of empty elements?

When I run my stylesheets via Saxon, <div></div> gets turns into <div/>. This throws off the rendering in IE and Firefox. MSXSL preserves the <div></div>.

Is there a way to prevent Saxon from merging <div></div> into <div/>?

 
Old April 27th, 2007, 02:06 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If you need HTML then set method attribute on the xsl:output element to html, although this shouldn't be necessary if the document element is html in the empty namespace. If you actually want XHTML then it shouldn't matter about the closed elements and you should use xml as the xsl:output method in XSLT 1.0 or xhtml in version 2.0.

--

Joe (Microsoft MVP - XML)
 
Old April 27th, 2007, 03:38 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

As Joe says: (a) make sure you are using the method="html" output method, and (b) make sure your div elements are not in a namespace (such as the XHTML namespace).

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 27th, 2007, 08:22 AM
Authorized User
 
Join Date: Apr 2007
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ah, thanks! Switching to method="html" fixed the empty divs. That made sense.

However, I'm now getting some blank lines in the output when I use indent="yes" (and when I use indent="no" the tags tend to be crammed onto one line). That's not a big deal, as long as I can get my "tidy" template working. Of course, my "tidy" template requires me to pass the generated html as a node set, which brings me back to the node-set issue, but that's discussed in another topic...

Anyway, thanks again!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Elements (EMPTY) and Attributes #Required Ian ORourke XML 10 July 14th, 2016 10:07 PM
Prevent converting empty textbox string to date. fizzerchris ASP.NET 2.0 Basics 2 May 18th, 2007 06:52 PM
remove empty elements but not ones with attributes dupdup XSLT 1 March 3rd, 2007 07:02 PM
How to create end tag on empty elements rjonk XSLT 1 July 21st, 2006 01:18 PM
XSLT: Empty elements not copied Borg0011 XSLT 0 July 18th, 2006 06:57 AM





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