Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 26th, 2007, 09:50 PM
Authorized User
 
Join Date: Apr 2007
Location: , , .
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/>?

Reply With Quote
  #2 (permalink)  
Old April 27th, 2007, 02:06 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
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)
Reply With Quote
  #3 (permalink)  
Old April 27th, 2007, 03:38 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
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
Reply With Quote
  #4 (permalink)  
Old April 27th, 2007, 08:22 AM
Authorized User
 
Join Date: Apr 2007
Location: , , .
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!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:20 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.