|
Re: [xmlc] Javascript output into XHTML: msg#00042java.enhydra.xmlc
You can probably do something like this: 1) Create a new TextNode, with the contents "//", append as a child to <script> element. 2) Create a new CDataSection, with the contents of your script plus "//" at the end, append as a child to your <script> element. If the "//" doesn't work, try doing "/*" and then in the CData put "*/" as the first thing in there, plus your script, and end with "/*". Then create another TextNode with "*/" and append after the Cdata. -Justin On 9/15/05, i_am_erik@xxxxxxxxx <i_am_erik@xxxxxxxxx> wrote: > This is very frustrating. I want to output some javascript into my document > via XMLC. The problem comes with < and > symbols. They get escaped into, > for example: > --- > <script type="text/javascript"> > for(var i=0;i < someArray.length; i++) > { > // do stuff > } > </script> > --- > This is invalid javascript, and generates an error in all the browsers I've > tried. > > Personally, I find section 4.8 of the XHTML Specification > (http://www.w3.org/TR/xhtml1/#h-4.8) to be rather ridiculous. Why would the > contents of the <script> tag be PCDATA?!? Why would they force you to make > your javascript into CDATA just to do some comparisons or loops? I'd love to > hear any explanations other than "backwards compatibility" for this. > > Note that this is not a problem at all if I make my mime type > "application/xhtml+xml", but then my page only works in Firefox, and I can't > use any innerHTML javascript. The latter, I could eschew, but the former is > a show stopper. > > I can't use the org.w3c.dom.Document.createCDATASection() method, because > that results in something like: > --- > <script type="text/javascript"><![CDATA[ > for(var i=0;i < someArray.length; i++) > { > // do stuff > } > ]]></script> > --- > And that's not valid javascript either! > > From what I can tell from searching internet forums, you have to do something > like: > --- > <script> > <!-- // <![CDATA[ --> > for(var i=0;i < someArray.length; i++) > { > // do stuff > } > <!-- ]]> --> > </script> > --- > Unfortunately, with the DOM methods available to me with XMLC, that's simply > impossible to output. > > As far as I can see, the only solution to this is to put some lessThan(a, b) > and greaterThan(a, b) methods into an included js file. Obviously, this > solution is revolting, and I would love to hear any other suggestions you > might have. > > Cheers, > Erik > > > > > -- > You receive this message as a subscriber of the xmlc@xxxxxxxxxxxxx mailing > list. > To unsubscribe: mailto:xmlc-unsubscribe@xxxxxxxxxxxxx > For general help: mailto:sympa@xxxxxxxxxxxxx?subject=help > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws > > > -- You receive this message as a subscriber of the xmlc@xxxxxxxxxxxxx mailing list. To unsubscribe: mailto:xmlc-unsubscribe@xxxxxxxxxxxxx For general help: mailto:sympa@xxxxxxxxxxxxx?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [xmlc] Javascript output into XHTML, i_am_erik |
|---|---|
| Next by Date: | Re: [xmlc] Javascript output into XHTML, Erik Rasmussen |
| Previous by Thread: | [xmlc] Javascript output into XHTML, i_am_erik |
| Next by Thread: | Re: [xmlc] Javascript output into XHTML, Erik Rasmussen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |