|
| <prev next> |
Re: [xmlc] Javascript output into XHTML: msg#00043java.enhydra.xmlc
Excellent! You got it! Here's the working code, for posterity: --- import org.enhydra.xml.xhtml.dom.xerces.XHTMLDocumentBase; import org.enhydra.xml.xhtml.dom.xerces.XHTMLScriptElementImpl; import org.enhydra.xml.xmlc.html.HTMLObject; // <--snip--> final HTMLObject page; // <--snip--> final XHTMLDocumentBase documentBase = (XHTMLDocumentBase) page.getDocument(); final XHTMLScriptElement script = new XHTMLScriptElementImpl(documentBase, "", "script"); script.setAttribute("type", "text/javascript"); script.appendChild(page.createTextNode("/*")); script.appendChild(page.createCDATASection("*/\n"+javascript+"\n/*")); script.appendChild(page.createTextNode("*/")); --- And just for humor value, I'll show the javascript workaround I was using until you posted the answer... (the Iterator class is moderately elegant, if you ask me) stupidXhtmlHack.js: --- // --------------------------------------------------------- // XML Entity avoidance methods // --------------------------------------------------------- function Iterator(array) { this.array = array; this.index = 0; this.hasNext = Iterator_hasNext; this.next = Iterator_next; } function Iterator_hasNext() { return this.index + 1 < this.array.length; } function Iterator_next() { this.index++; return this.array[this.index]; } function and(a, b) { return a && b; } function lessThan(a, b) { return a < b; } function lessThanOrEqual(a, b) { return a <= b; } function greaterThan(a, b) { return a > b; } function greaterThanOrEqual(a, b) { return a >= b; } --- :-) Thanks! Erik --- Justin Akehurst <akehurst@xxxxxxxxx> wrote: > 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 __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com -- 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: | Re: [xmlc] Javascript output into XHTML, Justin Akehurst |
|---|---|
| Previous by Thread: | Re: [xmlc] Javascript output into XHTML, Justin Akehurst |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |