[jdom-interest] "&" char in Javascript generated by JDOM

Federico fmeschini at tin.it
Fri Nov 29 09:06:23 PST 2002


Hi all,

I've written a java class for the automatic creation of a number of
HTML files. I use the package JDOM for the creation of the HTML
elements in the file. I have to insert a javascript function in the head 
section, so I
creat a <script> element and attach it into the <head> element.
Then I set the text content of the <script> element, with the
javascript I need, using the escape char for the linee feeds and the
quotes.

But the javascript contains the "&&" chars and when I create the html
files they have all become "&amp;" and so the file call for an error
in the <script> element.

So I should obtain to avoid the transformation from to "&" to "&amp;"

Asking to an XML newsgroup I've found that if I'm creating an XHTML (XML) 
file escaping the ampersands is
correct and any XHTML processor must accept them. But if I'm creating HTML 
(SGML) , I should need a serializer which knows about the
differences between HTML (SGML) and XHTML (XML).

What kind of class of the JDOM package can I use to obtain such serializer?

Thank you
Federico




More information about the jdom-interest mailing list