Thank you Ryan. Now what I get when I run the pipeline, what I see is the result of running the javascript. But what I really need is the "source" of this javascript, e.g. if the javascript code was: document.write("<center><font size=+3>"); document.write("This HTML-document has been created "); document.write("with the help of JavaScript!"); document.write("</font></center>");
I want to get as a result the xhtml tree fragment that is created, e.g. I want to get back: <center> <font size=+3> This HTML-document has been created with the help of JavaScript! </font> </center> e.g. I want to see the actual HTML code that was used in javascript to create the given page, and not the result of executing it. Is it doable in Cocoon/XSP? Thank you very much for your help. Anna ----- Original Message ----- From: "Ryan Agler" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, November 21, 2002 4:26 PM Subject: RE: JavaScript problems in XSP Hi Anna, Client-side (in your web browser) JavaScript is a completely different beast than server-side (on your web server) JavaScript. In server-side JavaScript, there are no windows, DHTML, or much any other properties or methods you would use to manipulate a browser for dynamic content. To use Cocoon to achieve your task, the first step would to define "given-file.html" in your sitemap, and make sure its serialized in well-formed XHTML. Then you could use the Cinclude transformer to import given-file.html, kind of like this (myfile.xsp): <?xml version="1.0"?> <xsp:page language="java" xmlns:xsp=http://apache.org/xsp> <page xmlns:cinclude="http://apache.org/cocoon/include/1.0"> <p> <cinclude:include src="cocoon:/given-file.html" /> </p> </page> </xsp:page> and in your sitemap.xmap: <map:match pattern="given-file.html"> <map:generate type="serverpages" src="docs/given-file.xsp" /> <map:transform src="stylesheets/given-file.xsl" /> <map:serialize type="xhtml"/> </map:match> <map:match pattern="myfile.xsl"> <map:generate type="serverpages" src="docs/myfile.xsp" /> <map:transform type="cinclude"/> <map:transform src="stylesheets/myfile.xsl" /> <map:serialize /> </map:match> HTH +Ryan -----Original Message----- From: Anna Afonchenko [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 21, 2002 7:43 AM To: [EMAIL PROTECTED] Subject: Javascript problems in XSP Hi All. This is my first post, so don't be angry with me if I do something wrong. I am using XSP on Cocoon 2.0.3, and I want to do the following: given a name of the html file that contains javascript, I want to get the result of this javascript and put it inside some element in XSP. But when I write the following code in XSP using javascript: <p> <xsp:logic> var js = window.open("given-file.html"); var result = js.document.body.innerHTML; </xsp:logic> <xsp:expr>result</xsp:expr> </p> nothing happens (even doesn't give any error). If I am using this code inside an html file's script tag, it works fine. If I am trying some simple Javascript functions in XSP (e.g. Date()), it works. Maybe there is some problem with opening files in XSP? Can somebody please tell me what am I doing wrong and how can I get the result of javascript code executed in some given file? Thank you very much in advance. Anna --------------------------------------------------------------------- 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]> --------------------------------------------------------------------- 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]>