I'm trying to generate HTML using a SAX TransformHandler. The problem
I'm having is related to the xalan transformer using the shorthand
notation when it writes out an empty textarea tag. My code works fine
when xalan.jar is not in my classpath. But when xalan.jar is in the
classpath, the generated html incorrectly uses the shorthand notation
for writing out an empty textarea tag.
Correct output:
C:\test>java Test
com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerImpl
<html>
<body>
<textarea></textarea>GoodBye</body>
</html>
Incorrect output:
C:\test>java -classpath .;/tomcat5/common/lib/xalan.jar Test
org.apache.xalan.transformer.TransformerIdentityIm pl
<?xml version="1.0" encoding="UTF-8"?>
<html>
<body>
<textarea/>GoodBye</body>
</html>
As you can see from the above example, when xalan is involved, the
generated output results in HTML that confuses IE. Is there a way to
force xalan into NOT using the short hand notation for the textarea
tag?
Here's the source code of my program:
public static void main( String [] args )
{
try {
// prepare the output transform handler
SAXTransformerFactory tf =
(SAXTransformerFactory) TransformerFactory.newInstance();
TransformerHandler transformerHandler =
tf.newTransformerHandler();
Transformer serializer = transformerHandler.getTransformer();
System.out.println( serializer.getClass().getName() );
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
transformerHandler.setResult( new StreamResult( System.out ) );
transformerHandler.startDocument();
Attributes noAtts = new AttributesImpl();
transformerHandler.startElement("", "", "html", noAtts );
transformerHandler.startElement("", "", "body", noAtts );
transformerHandler.startElement(
"", "", "textarea", noAtts );
transformerHandler.endElement("", "", "textarea" );
String msg = "GoodBye" ;
transformerHandler.characters( msg.toCharArray(),
0, msg.length() );
transformerHandler.endElement("", "", "body" );
transformerHandler.endElement("", "", "html" );
transformerHandler.endDocument();
}
catch ( Exception e ) {
e.printStackTrace();
}
} 5 1746
I'm still looking for an answer to this one. My opinion on the matter
is that <textarea/> should be considered perfectly legal xhtml.
However, IE 6.0, isn't smart enough to handle it. That's why I was
looking for a possible work around that doesn't involve forcing a space
between the start and end of the element.
John wrote: I'm still looking for an answer to this one. My opinion on the matter is that <textarea/> should be considered perfectly legal xhtml. However, IE 6.0, isn't smart enough to handle it. That's why I was looking for a possible work around that doesn't involve forcing a space between the start and end of the element.
Exactly, both <textarea></textarea> and <textarea/> are equivalent
and valid xhtml.
Couldn't you just leave out the textarea at all?
Gerald
John wrote: I'm still looking for an answer to this one. My opinion on the matter is that <textarea/> should be considered perfectly legal xhtml. However, IE 6.0, isn't smart enough to handle it. That's why I was looking for a possible work around that doesn't involve forcing a space between the start and end of the element.
another idea: let your xhtml validate by the w3c validator.
if it is not valid xhtml then the browser will switch to
quirks-mode (see FAQ at http://www.quirksmode.org/)
HTH
Gerald
John wrote: I'm still looking for an answer to this one. My opinion on the matter is that <textarea/> should be considered perfectly legal xhtml.
1. The subject contains HTMLSerializer. The serializer for _HTML_ should
not create <textarea/>.
2. According to the XML spec you should only use the empty element
notation for elements that are empty by definition, which textarea is not.
However, IE 6.0, isn't smart enough to handle it.
IE 6.0 does not know XHTML.
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
John wrote: I'm still looking for an answer to this one. My opinion on the matter is that <textarea/> should be considered perfectly legal xhtml.
It's legal as XML, but violates the notorious Appendix C of XHTML.
So it's not legal to serve on the Web as "text/html".
However, IE 6.0, isn't smart enough to handle it.
Indeed. But if you serve it as text/html then XML rules don't apply,
so IE is within its rights not treating <foo/> as <foo></foo>.
That's why I was looking for a possible work around that doesn't involve forcing a space between the start and end of the element. http://apache.webthing.com/mod_xhtml/
--
Nick Kew This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: al dav |
last post by:
Hi all
ok i am not a java programmer I am a sys-admin, my users want xalan and have
already got j2sdk_1.4.2
so i have downloaded it and set the CLASS_PATH
export...
|
by: Guillaume Jeudy |
last post by:
Hi,
I'm trying to serialize a DOM constructed from the following URL which
is subject to change very frequently:
...
|
by: Fisch von Gestern |
last post by:
I have tried to run the extension function/element examples provided
with the Xalan-J download. I believe that my classpath is correct,
and that my versions are up-to-date. However, I can't get...
|
by: Ganesh Gella |
last post by:
Hi All,
I am planning to use Xalan to transform XML data by applying xls
stylesheets.
Here tricky part is, Xalan provides several C++ APIs, which are very
much useful if our requirement is...
|
by: Dr. Roger Wießner |
last post by:
Hello!
I am a newbie to XSLT and need a freeware/GNU Tool
to get experience with this new topic.
Which one is a good XSLT? Xalan or Saxon, or which
one else?
Thank you a lot!
|
by: RC |
last post by:
First, let me say I couldn't find a group discuss
XML/XSLT. So I only choose the closest groups to
post this message.
Here is part of my *.xsl file
<xsl:stylesheet...
|
by: terry.jeske |
last post by:
Hello,
I am trying to upgrade an application that was previously running on
Xalan 1.4.2, to 2.7.0.
I have worked out the build issues and now the application compiles
with the new xalan and...
|
by: Avalon1178 |
last post by:
Hi,
I recently downloaded the xalan-c source code in
http://mirrors.ccs.neu.edu/Apache/dist/xml/xalan-c
I followed the instructions from the apache site on how to build it (I
already have...
|
by: henribastien |
last post by:
I'm trying to return an array from a xalan extension but so far I have
made no progress. What I would like to return is something like that
<entry id="red">201</entry>
<entry...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |