Ugh. This may spell bad news: see inline comments. If you are comfortable in java as well as javascript (at least reasonably so) you may want to look into using a java based javascript interpreter - looking into the cocoon javascript generator (org.apache.cocoon.components.language.markup.xsp.JSGenerator) and other JS related sources around there in the source tree it looks like cocoon is using Rhino (http://www.mozilla.org/rhino/). Then, you can write your xsp in java (which has far more features and users) but still execute arbitrary javascript code when you find it. That said, I think you're on a potentially very confusing path because of all the places javascript can be in an html page, and all the DOM objects it's likely to reference.
Still, this may work and I'd be very interested to hear how it goes and help as I can - but I've never touched Rhino and can't right now. Geoff (more comments below) --- Anna Afonchenko <[EMAIL PROTECTED]> wrote: > 1. First of all I tried to give the eval() function > some simple string that > I declared inside the <xsp:logic> tag: someStr = > "document.write('<center>Hello</center>')"; > If I write this string inside the > <xsp:expr>document.text</xsp:expr>, the > output is: > > <?xml version="1.0" encoding="UTF-8" ?> > <page xmlns:xsp="http://apache.org/xsp" > xmlns:xsp-request="http://apache.org/xsp/request/2.0" > xmlns:util="http://apache.org/xsp/util/2.0"> > <p><center>Hello</center></p> > </page> > > which is great, but when I looked in the source > code, I found out that the > <center>Hello</center> string > is written using entities, e.g. it is not a node-set > of the output xml > document. Right, sorry about that. I had seen in another email that you were using <util:include-expr> so I left that part out for simplicity but forgot to comment as such. > > Trying to enclose the <xsp:expr> tag inside the > <util:include-expr> tag: > > <util:include-expr><util:expr><xsp:expr>document.text</xsp:expr></util:expr> > </util:include-expr> > the surprising output is: > > <?xml version="1.0" encoding="UTF-8" ?> > <page xmlns:xsp="http://apache.org/xsp" > xmlns:xsp-request="http://apache.org/xsp/request/2.0" > xmlns:util="http://apache.org/xsp/util/2.0"> > <p> > <util:include-expr> > <util:expr><center>Hello</center></util:expr> > </util:include-expr> > </p> > </page> > This is strange. Do > you have any idea how > can I avoid outputting the result as a string (with > entities) rather that > outputting it as a node-set? Not surprising - just checked and javascript xsp's have only request, response and session logicsheets. I don't know if it's possible to recreate the include expression functionality in javascript - you may want to send a very specific question on that to this list, making clear that you know it doesn't yet exist. > > > 2. How can I retrieve the content of some html file > from xsp with > javascript? I don't know if you can - you can't from a browser, but that may be only because of the security limitations imposed. > And parse it? See above. > Is it possible that there are > problem using util > library from xsp with javascript? Right. It doesn't exist in javascript. Geoff __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus – Powerful. Affordable. Sign up now. http://mailplus.yahoo.com --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>