aspose file tools*
The moose likes XML and Related Technologies and the fly likes XSLT - empty tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XSLT - empty tag" Watch "XSLT - empty tag" New topic
Author

XSLT - empty tag

Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
I use XSLT to transform XML to XHTML, So when a particular tag NODE_VAL in XML is empty, I render a textarea tag as below


But the output HTML is different in different runtimes (may be the XALAN.jar is the culprit but cannot control it)
in some instances the XHTML looks like

and the browser happily renders a TEXTAREA widget
but in some instances the XHTML looks like (empty tag)

and the browser either is not displaying the widget or is displaying the wrapping HTML tags (example if the textarea is wrapped in div tag, the div tags are seen in the text area)

What should I code differently in XSLT to always render the XHTML ase


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

If you are generating XML (which is what XHTML is) then you have no way of controlling how empty elements are rendered in the output, and it shouldn't make any difference anyway.

So if it does make a difference (and from what you say, it does) then it looks to me like the browser isn't treating your output as XHTML, but just as HTML. Perhaps you should investigate why that is.
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
According to the SME of my other forum POST
http://www.coderanch.com/t/452949/HTML-JavaScript/textarea-empty-tag
I should not render the empty tags in XHTML
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

You're between a rock and a hard place. You can try sending the mdeia type of application/xhtml+xml but If that doesn't work you may be without paddle.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
I tried that mime type too, and IE7 doesn't understand it
Guess I have to code some workarounds
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
I got around this issue, with a bit of hack in code by placing a known token in the textarea and removing it from the javascript on page load.
So for now the page is in business.
Thanks for your analysis.
 
Don't get me started about those stupid light bulbs.
 
subject: XSLT - empty tag